上一讲: 《01_[nvim0.5+从0单排]_neovim安装与Pynvim安装》 https://blog.csdn.net/lxyoucan/article/details/120466390
开始之前要先安装一下git
brew install git
配置
init.vim
mkdir -p ~/.config/nvim
nvim ~/.config/nvim/init.vim
" 配置文件导入 "{{{
"
" 基础使用习惯配置
runtime ./vimrc.vim
" 插件管理
"./lua/plugins.lua
lua require('plugins')
" 按键映射
runtime ./maps.vim
vimrc.vim
"----vim 个人使用习惯配置start------
set encoding=UTF-8
" leader设置成空格
let mapleader=" "
" 使用鼠标
set mouse=c
" 显示行号
set nu
" 相对行号
set relativenumber
" tab=4个空格
set tabstop=4
set shiftwidth=4
" 改变 vim中光标的形状
let g:db_ui_use_nerd_fonts=1
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE)
" 高度光标所在行
"set cursorline
" 设置不换行
"set nowrap
set wrap
" 显示按下的按键
set showcmd
" 按tab显示菜单
set wildmenu
" 不需要备份文件
set nobackup
"----vim 个人使用习惯配置end------
"ssh 远程粘贴板
if executable('clipboard-provider')
let g:clipboard = {
\ 'name': 'myClipboard',
\ 'copy': {
\ '+': 'clipboard-provider copy',
\ '*': 'env COPY_PROVIDERS=tmux clipboard-provider copy',
\ },
\ 'paste': {
\ '+': 'clipboard-provider paste',
\ '*': 'env COPY_PROVIDERS=tmux clipboard-provider paste',
\ },
\ }
endif
"随机选一个颜色风格
function RandomColorScheme()
let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n")
exe 'so ' . mycolors[localtime() % len(mycolors)]
unlet mycolors
endfunction
"call RandomColorScheme()
:command NewColor call RandomColorScheme()
" 文件类型设置 "{{{
" ---------------------------------------------------------------------
" JSX 语法高亮
" set filetypes as typescriptreact
autocmd BufNewFile,BufRead *.tsx,*.jsx,*.js set filetype=typescriptreact
maps.vim
"-------------------------------------------------------------------------------
" window
"-------------------------------------------------------------------------------
" Split window
nmap ss :split<Return><C-w>w
nmap sv :vsplit<Return><C-w>w
" Move window
"nmap <Space> <C-w>w
"map s<left> <C-w>h
"map s<up> <C-w>k
"map s<down> <C-w>j
"map s<right> <C-w>l
map sh <C-w>h
map sk <C-w>k
map sj <C-w>j
map sl <C-w>l
" Resize window
" 在mac/linux中使用Alt键,在webssh
" 中alt没用,就使用Ctrl,WEBSSH主要的WINDOWS中使用
nmap <M-left> <C-w><
nmap <C-left> <C-w><
nmap s<left> <C-w><
nmap <M-right> <C-w>>
nmap <C-right> <C-w>>
nmap s<right> <C-w>>
nmap <M-up> <C-w>+
nmap <C-up> <C-w>+
nmap s<up> <C-w>+
nmap <M-down> <C-w>-
nmap <C-down> <C-w>-
nmap s<down> <C-w>-
" 插入模式移动光标
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-d> <Delete>
" hh在我用的单词里出现的频率极低,其实感觉home用的没有end多,统一风格都用大写的吧
"inoremap HH <Home>
" 单词中包含ll的太多了,所以用大写LL
"inoremap LL <End>
" jk <Esc>
inoremap jk <Esc>
" 插入模式鼠标滚轮抵消,不然会出现滚动鼠标录入了一堆5j5k
inoremap 5k <Esc>
inoremap 5j <Esc>
inoremap 9<CR> <Esc>a
" 快速跳转行首与行尾
nnoremap L $
nnoremap H ^
" 向下5行
noremap <C-j> 5j
" 向上5行
noremap <C-k> 5k
" 保 存
noremap <C-s> :w<CR>
noremap s :w<CR>
" Coc智能处理,使用IDEA Alt+Enter 同样按键
"noremap <M-Enter> :CocAction<CR>
inoremap <C-s> <ESC> :w<CR>
" 代码格式化
noremap <leader>f :Format<CR>
noremap <leader>r :luafile ~/.wp/lua/run.lua<CR>
" 强制退出
map Q :q<CR>
"map qq :q<CR>
" 重新加载设置
map R :source $MYVIMRC<CR>
"自动关闭标签
inoremap <buffer> <C-v> <esc>yiwi<lt><esc>ea></><esc>hpF>i
set iskeyword+=<,>
iab <h1> <lt>h1> <lt>/h1><esc>5ha
" 全选
nmap <C-a> gg<S-v>G
" 加/减数字1
nnoremap + <C-a>
nnoremap - <C-x>
"-------------------------------------------------------------------------------
" Buffers
"-------------------------------------------------------------------------------
" Open current directory
" 插入模式移动光标
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-d> <Delete>
" hh在我用的单词里出现的频率极低,其实感觉home用的没有end多,统一风格都用大写的吧
"inoremap HH <Home>
" 单词中包含ll的太多了,所以用大写LL
"inoremap LL <End>
" jk <Esc>
inoremap jk <Esc>
" 插入模式鼠标滚轮抵消,不然会出现滚动鼠标录入了一堆5j5k
inoremap 5k <Esc>
inoremap 5j <Esc>
inoremap 9<CR> <Esc>a
" 快速跳转行首与行尾
nnoremap L $
nnoremap H ^
" 向下5行
noremap <C-j> 5j
" 向上5行
noremap <C-k> 5k
" 保存
noremap <C-s> :w<CR>
" Coc智能处理,使用IDEA Alt+Enter 同样按键
noremap <M-Enter> :CocAction<CR>
inoremap <C-s> <ESC> :w<CR>
" 代码格式化
"noremap <leader>f :Format<CR>
" 强制退出
map Q :q<CR>
" 重新加载设置
map R :source $MYVIMRC<CR>
"自动关闭标签
inoremap <buffer> <C-v> <esc>yiwi<lt><esc>ea></><esc>hpF>i
set iskeyword+=<,>
iab <h1> <lt>h1> <lt>/h1><esc>5ha
" 全选
nmap <C-a> gg<S-v>G
" 加/减数字1
nnoremap + <C-a>
nnoremap - <C-x>
"-------------------------------------------------------------------------------
" Buffers
"-------------------------------------------------------------------------------
" Open current directory
"nmap te :tabedit
"nmap <S-Tab> :tabprev<Return>
nmap <S-Tab> :bprev<Return>
"nmap <Tab> :tabnext<Return>
nmap <Tab> :bnext<Return>
" 窗口管理器
" invoke with '-'
nmap - <Plug>(choosewin)
"nmap sw <Plug>(choosewin)
"nmap <leader>w <Plug>(choosewin)
lua/plugins.lua
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://codechina.csdn.net/mirrors/wbthomason/packer.nvim.git', install_path})
vim.cmd 'packadd packer.nvim'
end
vim.cmd [[packadd packer.nvim]]
return require('packer').startup({
function()
use 'wbthomason/packer.nvim'
end,
config = {
max_jobs = 16,
git = {
default_url_format = 'https://hub.fastgit.org/%s'
},
display = {
open_fn = function()
return require('packer.util').float({ border = 'single' })
end
}
}
})
|