Repository navigation
Expand file tree
/
Copy pathkeymaps.vim
More file actions
89 lines (66 loc) · 2.6 KB
/
Copy pathkeymaps.vim
File metadata and controls
89 lines (66 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
" TODO: bind fzf(files, grep), git(gdiff, bcommits, commits, log)
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Basic
nnoremap <silent> ,, :nohlsearch<cr>
nnoremap <C-h> <cmd>History<cr>
" Find Files
nnoremap <C-f>f <cmd>Files<cr>
nnoremap <C-f>r <cmd>Rg<cr>
" Git
nnoremap <C-g>c <cmd>BCommits<cr>
nnoremap <C-g>ac <cmd>Commits<cr>
nnoremap <C-g>d <cmd>Gdiffsplit<cr>
" Tab with selection
vnoremap > >gv
vnoremap < <gv
nnoremap <C-d> Y<Esc>p
nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Commentaries
vnoremap / <Plug>Commentary
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy :vsp<Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Eslint fix problems
nmap <silent> <M-f> :CocCommand eslint.executeAutofix<CR>
" Git commands
nmap <silent> <M-g> :GitGutterLineHighlightsToggle<CR>
nmap <silent> <M-d> :GitGutterDiffOrig<CR>
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <silent><M-r> <Plug>(coc-rename)
" Remap keys for applying codeAction to the current buffer.
nmap <silent><M-a> <Plug>(coc-codeaction)
" 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')
" Show commands.
nnoremap <silent><nowait> <M-c> :<C-u>CocList commands<cr>
nnoremap <silent><nowait> <M-o> :OR<CR>
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()