source $VIMRUNTIME/defaults.vim set nocompatible set encoding=utf-8 set helplang=cn syntaxon setnumber set relativenumber set cursorline " 显示光标所在行 set wrap " 自动换行 set showcmd " 显示输入信息 set wildmenu " 显示补全提示 set hlsearch " 高亮搜索结果 "打开vim运行nohlsearch,取消高亮 exec "nohlsearch" set incsearch " 一边输入一边高亮 set ignorecase " 忽略大小写 set smartcase " 智能大小写 set scrolloff=5" 光标行上下移动范围各缩小5行 "寻找下一搜索结果,并将其置于屏幕中心 noremap = nzz "寻找上一搜索结果,并将其置于屏幕中心 noremap - Nzz " === " === Normal Mode " === noremap Q :q<CR> noremap<C-q> :qa<CR> noremap S :w<CR> noremap s <nop> map R :source $MYVIMRC<CR> noremap<silent> J 5j noremap<silent> K 5k " Ctrl + U or E will move up/down the view port without moving the cursor noremap<C-K>5<C-y> noremap<C-J>5<C-e> nnoremap Y y$ " 全选 map<C-a> ggVG " Resize splits with arrow keys noremap<up> :res +5<CR> noremap<down> :res -5<CR> noremap<left> :verticalresize-5<CR> noremap<right> :verticalresize+5<CR> " Copy to system clipboard vnoremap Y "+y " Place the two screens up and down noremap su <C-w>t<C-w>K " Place the two screens side by side noremapsv<C-w>t<C-w>H " split the screens to up (horizontal), down (horizontal), left (vertical), right (vertical) noremap sk :set nosplitbelow<CR>:split<CR>:set splitbelow<CR> noremap sj :set splitbelow<CR>:split<CR> noremapsh :set nosplitright<CR>:vsplit<CR>:set splitright<CR> noremapsl :set splitright<CR>:vsplit<CR> "新建标签页 maptn :tabe<CR> "前一标签页 mapth :-tabnext<CR> "后一标签页 maptl :+tabnext<CR> " 将当前标签和前一标签交换位置 noremap tmh :-tabmove<CR> " 将当前标签和后一标签交换位置 noremap tml :+tabmove<CR> " === " === Insert Model " === inoremap<C-a><ESC>A " === " === Command Mode " === cnoremap<C-a><Home> cnoremap<C-e><End> cnoremap<C-p><Up> cnoremap<C-n><Down> " === " === Leader Mapping " === let mapleader= " " map<LEADER>rc :e $MYVIMRC<CR> map<LEADER>sd :w !sudo tee %<CR> map<LEADER><CR> :nohlsearch<CR> map<LEADER>k<C-w>k map<LEADER>j<C-w>j map<LEADER>h <C-w>h map<LEADER>l<C-w>l
"================== vim-one config ===================== colorscheme one set background=dark letg:airline_theme='one' set termguicolors "================== vim-which-key config ===================== nnoremap<silent><leader> :WhichKey '<Space>'<CR> set timeoutlen=300 "================== coc.nvim config ===================== " https://raw.githubusercontent.com/neoclide/coc.nvim/master/doc/coc-example-config.vim
" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count " utf-8 byte sequence set encoding=utf-8 " Some servers have issues with backup files, see #649 set nobackup set nowritebackup
" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable " delays and poor user experience set updatetime=300
" Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate " NOTE: There's always complete item selected by default, you may want to enable " no select by `"suggest.noselect": true` in your configuration file " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by " other plugin before putting this into your config inoremap<silent><expr><TAB> \ coc#pum#visible() ? coc#pum#next(1) : \ CheckBackspace() ? "\<Tab>" : \ coc#refresh() inoremap<expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format " <C-g>u breaks current undo, please make your own choice inoremap<silent><expr><CR> coc#pum#visible() ? coc#pum#confirm() \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use <c-space> to trigger completion ifhas('nvim') inoremap<silent><expr><c-space> coc#refresh() else inoremap<silent><expr> <c-@> coc#refresh() endif
" Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list nmap<silent><nowait> [g <Plug>(coc-diagnostic-prev) nmap<silent><nowait> ]g <Plug>(coc-diagnostic-next)
" Applying code actions to the selected code block " Example: `<leader>aap` for current paragraph xmap<leader>a<Plug>(coc-codeaction-selected) nmap<leader>a<Plug>(coc-codeaction-selected)
" Remap keys for applying code actions at the cursor position nmap<leader>ac <Plug>(coc-codeaction-cursor) " Remap keys for apply code actions affect whole buffer nmap<leader>as<Plug>(coc-codeaction-source) " Apply the most preferred quickfix action to fix diagnostic on the current line nmap<leader>qf <Plug>(coc-fix-current)
" Run the Code Lens action on the current line nmap<leader>cl<Plug>(coc-codelens-action)
" Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server xmapif<Plug>(coc-funcobj-i) omapif<Plug>(coc-funcobj-i) xmap af <Plug>(coc-funcobj-a) omap af <Plug>(coc-funcobj-a) xmap ic <Plug>(coc-classobj-i) omap ic <Plug>(coc-classobj-i) xmap ac <Plug>(coc-classobj-a) omap ac <Plug>(coc-classobj-a)
" Use CTRL-S for selections ranges " Requires 'textDocument/selectionRange' support of language server nmap<silent><C-s><Plug>(coc-range-select) xmap<silent><C-s><Plug>(coc-range-select)
" Add `:Format` command to format current buffer command! -nargs=0 Format :call CocActionAsync('format')
" Add `:Fold` command to fold current buffer command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList " Show all diagnostics nnoremap<silent><nowait><space>a :<C-u>CocList diagnostics<cr> " Manage extensions nnoremap<silent><nowait><space>e :<C-u>CocList extensions<cr> " Show commands nnoremap<silent><nowait><space>c :<C-u>CocList commands<cr> " Find symbol of current document nnoremap<silent><nowait><space>o :<C-u>CocList outline<cr> " Search workspace symbols nnoremap<silent><nowait><space>s :<C-u>CocList -I symbols<cr> " Do default action for next item "nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> " Do default action for previous item "nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> " Resume latest coc list nnoremap<silent><nowait><space>p :<C-u>CocListResume<CR>
"================== coc-snippets config ===================== " Use <C-l> for trigger snippet expand. imap<C-l><Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet. vmap<C-j><Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim letg:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim letg:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.) imap<C-j><Plug>(coc-snippets-expand-jump)
" Use <leader>x for convert visual selected code to snippet xmap<leader>x<Plug>(coc-convert-snippet)