1
1
" vim: set sw = 2 ts = 2 sts = 2 et tw = 78 foldmarker = {{{,}}} foldlevel = 0 foldmethod = marker nospell :
2
2
3
- so ~/.config/nvim/bindings/whichkey.vim
4
3
" Vim {{{
5
4
" Disable EX mode
6
5
nnoremap Q <nop>
@@ -44,22 +43,19 @@ so ~/.config/nvim/bindings/whichkey.vim
44
43
" Write the file with sudo
45
44
cmap w!! w !sudo tee % > /dev/null
46
45
" NVim Terminal emulator mappings {{{
47
- if has (' nvim' )
48
- fun ! Fterm_maps ()
49
- if &ft = ~ ' fzf'
50
- return
51
- endif
52
- tnoremap <buffer> <Esc> <C-\><C-n>
53
- tnoremap <buffer> <C-h> <C-\><C-n><C-w> h
54
- tnoremap <buffer> <C-j> <C-\><C-n><C-w> j
55
- tnoremap <buffer> <C-k> <C-\><C-n><C-w> k
56
- tnoremap <buffer> <C-l> <C-\><C-n><C-w> l
57
- endf
58
- augroup term_maps
59
- " this one is which you're most likely to use?
60
- autocmd BufEnter * call Fterm_maps ()
61
- augroup end
62
- endif
46
+ fun ! Fterm_maps ()
47
+ if &ft = ~ ' fzf'
48
+ return
49
+ endif
50
+ tnoremap <buffer> <Esc> <C-\><C-n>
51
+ tnoremap <buffer> <C-h> <C-\><C-n><C-w> h
52
+ tnoremap <buffer> <C-j> <C-\><C-n><C-w> j
53
+ tnoremap <buffer> <C-k> <C-\><C-n><C-w> k
54
+ tnoremap <buffer> <C-l> <C-\><C-n><C-w> l
55
+ endf
56
+ augroup term_maps
57
+ autocmd BufEnter * call Fterm_maps ()
58
+ augroup end
63
59
" }}}
64
60
" Fast buffer switching {{{
65
61
map <S-H> :bp<CR>
@@ -71,176 +67,26 @@ so ~/.config/nvim/bindings/whichkey.vim
71
67
nnoremap <C-L> <C-W> l
72
68
nnoremap <C-H> <C-W> h
73
69
" }}}
74
- " Toggle loclist
75
- nmap <silent> <leader> bql :call ToggleList("Location List", 'l')<CR>
76
- " Toggle qfix
77
- nmap <silent> <leader> bqq :call ToggleList("Quickfix List", 'c')<CR>
78
70
" Adjust splits evenly
79
71
map <Leader> = <C-w> =
80
72
" Toggle Linebreaks and wraps
81
- nnoremap <silent> <Leader> bvl :set wrap!<CR> \| :set linebreak!<CR>
73
+ nnoremap <silent> <Leader> :set wrap!<CR> \| :set linebreak!<CR>
82
74
" Clear search term (and it hilight :) )
83
75
nmap <silent> <Leader> / :let @/=""<CR>
84
- " Fast access to vim settings
85
- nnoremap <silent> <leader> fevc :vsplit ~/.config/nvim/init.vim<CR>
86
- nnoremap <silent> <leader> fevb :vsplit ~/.config/nvim/bindings.vim<CR>
87
- nnoremap <silent> <leader> fevp :vsplit ~/.config/nvim/plugins/plug.nvim<CR>
88
76
" Add modeline to file
89
- nnoremap <silent> <Leader> fm :call AppendModeline()<CR>
77
+ nnoremap <silent> <Leader> am :call AppendModeline()<CR>
90
78
" Fast splits
91
- nnoremap <silent> <leader> bsv :vsplit<CR>
92
- nnoremap <silent> <leader> bsh :split<CR>
79
+ nnoremap <silent> <leader> sv :vsplit<CR>
80
+ nnoremap <silent> <leader> sh :split<CR>
93
81
" }}}
94
- " Plugins {{{
95
- " Which Key {{{
96
- nnoremap <silent> <leader> :WhichKey '<Space> '<CR>
97
- nnoremap <silent> <localleader> :WhichKey '\'<CR>
98
- " }}}
99
- " Buffers {{{
100
- " NERDTree {{{
101
- nnoremap <silent> <Leader> be :NERDTreeFocus<CR>
102
- " }}}
103
- " Tagbar {{{
104
- nnoremap <silent> <Leader> bT :TagbarOpen fjc<CR>
105
- " }}}
106
- " BBye {{{
107
- nnoremap <silent> <leader> bd :Bdelete<CR>
108
- " }}}
109
- " FZF {{{
110
- nmap <leader> <tab> <Plug> (fzf-maps-n)
111
- imap <leader> <tab> <Plug> (fzf-maps-i)
112
- xmap <leader> <tab> <Plug> (fzf-maps-x)
113
- nnoremap <Leader> bf :GFiles<CR>
114
- nnoremap <Leader> bF :Files<CR>
115
- nnoremap <Leader> bb :Buffers<CR>
116
- " fast buffers access
117
- nnoremap <Leader> <Space> :Buffers<CR>
118
- nnoremap <Leader> bb :Buffers<CR>
119
- nnoremap <Leader> bg :Rg
120
- nnoremap <Leader> bl :BLines<CR>
121
- nnoremap <Leader> bL :Lines<CR>
122
- nnoremap <Leader> bt :BTags<CR>
123
- nnoremap <Leader> bc :Commands<CR>
124
- nnoremap <Leader> bp :Commits<CR>
125
- " }}}
126
- " Sessionman {{{
127
- " Open session
128
- nmap <leader> psl :SessionList<CR>
129
- " Save session
130
- nmap <leader> pss :SessionSave<CR>
131
- " }}}
132
- " Accordion {{{
133
- " Start accordion with 3 splits by default
134
- nmap <silent> <leader> bas :AccordionAll 3<CR>
135
- " Stop layout management
136
- nmap <silent> <leader> bac :AccordionStop<CR>
137
- " -1 split visible
138
- nmap <silent> <leader> bai :AccordionZoomIn<CR>
139
- " +1 split visible
140
- nmap <silent> <leader> bao :AccordionZoomOut<CR>
141
- " }}}
142
- " Undotree {{{
143
- nnoremap <silent> <leader> bu :UndotreeToggle<CR> :UndotreeFocus<CR>
144
- " }}}
145
- " }}}
146
- " Git {{{
147
- " Fugutive {{{
148
- " Stage file
149
- nmap <silent> <Leader> gw :GWrite<CR>
150
- " Git status
151
- nmap <silent> <Leader> gs :G<CR>
152
- " }}}
153
- " GV {{{
154
- nnoremap <silent> <leader> gl :GV<CR>
155
- " }}}
156
- " }}}
157
- " Code {{{
158
- " NERDCommenter {{{
159
- " Map toggle comment
160
- map <silent> <Leader> c<space> <Plug> NERDCommenterToggle
161
- " }}}
162
- " }}}
163
- " CoC {{{
164
- " General {{{
165
- " Extensions could be used for CoC to have more powerful features
166
- " Here is the list:
167
- " https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions << Explanation
168
- " https://www.npmjs.com/search?q=keywords%3Acoc.nvim << Actual list
169
82
170
- " use <tab> for trigger completion and navigate to next complete item
171
- function ! s: check_back_space () abort
172
- let col = col (' .' ) - 1
173
- return ! col || getline (' .' )[col - 1 ] = ~# ' \s'
174
- endfunction
175
-
176
- " Next by Tab
177
- inoremap <silent> <expr> <TAB>
178
- \ pumvisible() ? "\<C-n> " :
179
- \ <SID> check_back_space() ? "\<TAB> " :
180
- \ coc#rpc#request('doKeymap', ['snippets-expand', "\<TAB> "])
181
-
182
- " Previous by Tab
183
- inoremap <silent> <expr><S-Tab>
184
- \ pumvisible() ? "\<C-p> " :
185
- \ <SID> check_back_space() ? "\<S-Tab> " :
186
- \ coc#rpc#request('doKeymap', ['snippets-expand', "\<S-Tab> "])
187
-
188
- " use <c-space>for trigger completion
189
- imap <silent> <expr> <c-space> coc#refresh()
190
-
191
- " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
192
- " position. Coc only does snippet and additional edit on confirm.
193
- if has (' patch8.1.1068' )
194
- " Use `complete_info` if your (Neo)Vim version supports it.
195
- inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y> " : "\<C-g> u\<CR> "
196
- else
197
- inoremap <expr> <cr> pumvisible() ? "\<C-y> " : "\<C-g> u\<CR> "
198
- endif
199
-
200
- " Use <C-j> to select text for visual text of snippet.
201
- vmap <C-j> <Plug> (coc-snippets-select)
202
-
203
- " Show doc
204
- function ! s: show_doc ()
205
- if (index ([' vim' ,' help' ], &filetype ) >= 0 )
206
- execute ' h ' .expand (' <cword>' )
207
- else
208
- call CocAction (' doHover' )
209
- endif
210
- endfunction
211
-
212
- fun ! s: jump_definition ()
213
- if (index ([' vim' , ' help' ], &filetype ) >= 0 )
214
- execute ' tag ' .expand (' <cword>' )
215
- else
216
- call CocAction (' jumpDefinition' , v: false )
217
- endif
218
- endf
219
-
220
- " Now jump usage
221
- nnoremap <silent> K :call <SID> show_doc()<CR>
222
-
223
- " GoTos
224
- nnoremap <silent> <C-]> :call <SID> jump_definition()<CR>
225
- nnoremap <silent> <leader> ld :call CocAction('jumpDeclaration', v:false)<CR>
226
- nnoremap <silent> <leader> li :call CocAction('jumpImplementation', v:false)<CR>
227
- nnoremap <silent> <leader> lr :call CocAction('jumpReferences', v:false)<CR>
228
-
229
- " Use `[g` and `]g` to navigate diagnostics
230
- nmap <silent> [e <Plug> (coc-diagnostic-prev)
231
- nmap <silent> ]e <Plug> (coc-diagnostic-next)
232
- " and qf to fix em (or try at least
233
- nmap <silent> <leader> lqf <Plug> (coc-fix-current)
234
- " Add `:OR` command for organize imports of the current buffer.
235
- command ! -nargs =0 OR :call CocAction (' runCommand' , ' editor.action.organizeImport' )
236
-
237
- " Other helpful stuff
238
- nnoremap <silent> <leader> gC :call CocAction('codeAction')<CR>
239
- nnoremap <silent> <leader> gR :call CocAction('rename')<CR>
240
- nnoremap <silent> <leader> gq :call CocAction('quickfixes')<CR>
241
- nnoremap <silent> <leader> ,. :call CocActionAsync('format')<CR>
242
- nnoremap <silent> <leader> gL :CocList<CR>
83
+ " NvimTree {{{
84
+ nnoremap <silent> <leader> be :NvimTreeToggle<CR>
85
+ " }}}
243
86
244
- " }}}
245
- " }}}
87
+ " Easy Align {{{
88
+ " Start interactive EasyAlign in visual mode (e.g. vipga)
89
+ xmap ga <Plug> (EasyAlign)
90
+ " Start interactive EasyAlign for a motion/text object (e.g. gaip)
91
+ nmap ga <Plug> (EasyAlign)
246
92
" }}}
0 commit comments