-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspace_whichkey.vim
360 lines (334 loc) · 15.8 KB
/
space_whichkey.vim
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
" Which key config
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
let g:which_key_map = {}
" single mappings
" comment
let g:which_key_map[';'] = ['<plug>NERDCommenterToggle', 'comment']
" search
let g:which_key_map['/'] = [':RG', 'text Rg']
" terminal on buffer's current directory
"let g:which_key_map["'"] = [':FloatermNew! --wintype=split --height=0.1 --postition=bottom --cmd=cd %:p:h' , 'terminal in cwd']
let g:which_key_map["'"] = [':FloatermNew! --height=0.9 --width=0.9 --cmd=cd %:p:h' , 'terminal in cwd']
let g:which_key_map[","] = [':FloatermNew --height=0.9 --width=0.9' , 'terminal in project root']
" navigate to windows using space + window number
nnoremap <space>1 1<C-w>w
nnoremap <space>2 2<C-w>w
nnoremap <space>3 3<C-w>w
nnoremap <space>4 4<C-w>w
nnoremap <space>5 5<C-w>w
nnoremap <space>6 6<C-w>w
nnoremap <space>7 7<C-w>w
nnoremap <space>8 8<C-w>w
nnoremap <space>9 9<C-w>w
let g:which_key_map['1'] = 'which_key_ignore'
let g:which_key_map['2'] = 'which_key_ignore'
let g:which_key_map['3'] = 'which_key_ignore'
let g:which_key_map['4'] = 'which_key_ignore'
let g:which_key_map['5'] = 'which_key_ignore'
let g:which_key_map['6'] = 'which_key_ignore'
let g:which_key_map['7'] = 'which_key_ignore'
let g:which_key_map['8'] = 'which_key_ignore'
let g:which_key_map['9'] = 'which_key_ignore'
" b is for buffer
let g:which_key_map.b = {
\ 'name': '+buffer',
\ 'b': [':Buffers' , 'open buffer'],
\ 'd': [':Bdelete' , 'delete buffer'],
\ 'q': [':%bd' , 'delete all buffers']
\ }
" f is for files
let g:which_key_map.f = {
\ 'name': '+files',
\ 'e': {
\ 'name': '+emacs :P',
\ 'd': [':e ~/Projects/personal/dotfiles/README.md' , 'open DOTFILES README'],
\ 'w': [':WakaTimeToday' , 'show total coding activity for today'],
\ 'k': {
\ 'name': '+kitty',
\ 'c': [':e /Users/mp/vimwiki/TIL/kitty' , 'cheatsheet'],
\ 'k': [':e ~/.config/kitty/kitty.conf' , 'open KITTY config'],
\ 't': [':e ~/.config/kitty/theme.conf' , 'open KITTY theme']
\ },
\ 'r': {
\ 'name': '+ranger',
\ 'r': [':e ~/.config/ranger/rc.conf' , 'open RANGER rc.conf'],
\ 'R': [':e ~/.config/ranger/rifle.conf' , 'open RANGER rifle config']
\ },
\ 'v': {
\ 'name': '+vim',
\ 'c': [':e /Users/mp/vimwiki/TIL/vim/cheatsheet.md', 'cheatsheet'],
\ 'i': [':PlugInstall' , 'install plugs'],
\ 'r': [':source $MYVIMRC' , 'source vimrc'],
\ 'R': [':PlugClean' , 'Remove unused plugs'],
\ 'v': [':e $MYVIMRC' , 'open VIM init file']
\ },
\ 'y': {
\ 'name': '+yabai',
\ 'c': [':e /Users/mp/vimwiki/TIL/macos/yabai.md' , 'cheatsheet'],
\ 's': [':e ~/.config/skhd/skhdrc' , 'skhdrc'],
\ 'y': [':e ~/.config/yabai/yabairc' , 'yabairc'],
\ },
\ 'z': {
\ 'name': '+zsh',
\ 'a': [':e ~/.zsh_config/aliases.zsh' , 'open zsh aliases'],
\ 'e': [':e ~/.zsh_config/env.zsh' , 'open zsh env'],
\ 'f': [':e ~/.zsh_config/functions.zsh' , 'open zsh functions'],
\ 'p': [':e ~/.p10k.zsh' , 'open .p10k.zsh'],
\ 'r': [':!exec zsh' , 'reload zsh (exec zsh)'],
\ 's': [':e ~/.sensitive_env.zsh' , 'open sensitive zsh env'],
\ 'z': [':e ~/.zshrc' , 'open ZSHRC']
\ }
\ }
\ }
" g is for git
let g:which_key_map.g = {
\ 'name': '+git',
\ 'b': [':Git blame' ,'git blame'],
\ 'c': [':Git commit' , 'git commit'],
\ 'd': [':Git diff' , 'git diff'],
\ 'l': [':Git log' , 'git log'],
\ 'r': [':Git rebase -i' , 'git rebase'],
\ 's': [':LazyGit' , 'lazygit'],
\ 'S': [':SignifyEnableAll' , 'Enable signify to all buffers'],
\ 'B': [':GBrowse' , 'open in browser'],
\ 'h': [':Commits' , 'git history'],
\ 'H': [':BCommit!' , 'git history for the file'],
\ 'p': [':Git push' , 'git push'],
\ 'f': [':GFiles' , 'show all git files'],
\ 'm': [':GFiles?' , 'modified git files'],
\ 'C': [':LazyGitConfig' , 'lazygit config']
\ }
" l is for language server
let g:which_key_map.l = {
\ 'name': '+coc',
\ 'a': {
\ 'name': '+action',
\ 'a': ['<Plug>(coc-codeaction)' , 'code action'],
\ 's': ['<Plug>(coc-codeaction-selected)' , 'code action selected'],
\ 'q': ['<Plug>(coc-fix-current)' , 'automatically fix current line'],
\ 'n': [':CocNext' , 'do default action for next item'],
\ 'p': [':CocPrev' , 'do default action for previous item'],
\ },
\ 'c': {
\ 'name': '+coc',
\ 'c': [':CocList commands' , 'show commands'],
\ 's': [':CocList services' , 'show services'],
\ 'l': [':CocListResume' , 'resume latest coc list'],
\ },
\ 'C': [':CocConfig' , 'coc config'],
\ 'd': {
\ 'name': '+diagnostics',
\ 'd': [':CocList diagnostics' , 'show all diagnostics'],
\ 'p': ['<Plug>(coc-diagnostic-next)' , 'previous diagnostic (,]'],
\ 'n': ['<Plug>(coc-diagnostic-prev)' , 'next diagnostic (,[)'],
\ },
\ 'e': [':CocList extensions' , 'manage extensions'],
\ 'E': [':CocCommand eslint.restart', 'Restart eslint'],
\ 'g': {
\ 'name': '+go to',
\ 'd': ['<Plug>(coc-definition)' , 'go to definition (,d)'],
\ 'y': ['<Plug>(coc-type-definition)' , 'type definition (,y)'],
\ 'i': ['<Plug>(coc-implementation)' , 'implementation (,i)'],
\ 'r': ['<Plug>(coc-references)' , 'references (,r)'],
\ },
\ 'l': {
\ 'name': '+languages',
\ 't': [':CocCommand tailwindCSS.showOutput' , 'debug (tailwind)'],
\ 'o': [':CocCommand workspace.showOutput' , 'Show output'],
\ },
\ 'i': ["CocAction('runCommand', 'editor.action.organizeImport')", 'organize imports'],
\ 'O': ['<C-u>CocList outline<cr>' , 'find symbol of current document'],
\ 'p': [':CocCommand prettier.formatFile' , 'format file (:Prettier)'],
\ 'P': [':Format' , 'format file :Format (Use for prisma)'],
\ 'r': ["CocAction('runCommand', 'editor.action.restart')" , 'restart (f2)'],
"\ 'r': ['<Plug>(coc-rename)' , 'rename (f2)'],
\ 'R': [':CocCommand workspace.renameCurrentFile' , 'rename current file'],
\ 's': {
\ 'name': '+snippets',
\ 'l' : [':CocList snippets' , 'snippets'],
\ 'c': ['<Plug>(coc-convert-snippet)' , 'convert selected to snippet'],
\ 'e': [':CocCommand snippets.editSnippets' , 'edit snipets'],
\ 'o': [':CocCommand snippets.openSnippetFiles' , 'open snippet files'],
\ },
\ 'S': [':CocList -I symbols' , 'search workspace symbols'],
\ }
" p is for project
" \ 't': [':NERDTreeToggle', 'open file tree<C-b>'],
let g:which_key_map.p = {
\ 'name': '+project',
\ 'f': [':Files' , 'open file<c-f>'],
\ 'p': [':FzfSwitchProject' , 'switch project'],
\ 'w': [':Windows' , 'search windows'],
\ 't': [':RnvimrToggle' , 'open file tree<c-b>'],
\ 'T': {
\ 'name': '+tab',
\ 'n': [':tabnew %' , 'open current file in a new tab'],
\ 'N': [':- tabnew %' , 'open current file in a prev tab'],
\ 'l': [':tabs' , 'list all tabs'],
\ 'm': [':tabmove +' , 'move tab forward'],
\ 'M': [':tabmove -' , 'move tab backward']
\ },
\ }
let g:which_key_map.P = {
\ 'name': '+Project',
\ 't': {
\ 'name': '+tab',
\ 'n': [':tabnew %' , 'open current file in a new tab'],
\ 'N': [':- tabnew %' , 'open current file in a prev tab'],
\ 'l': [':tabs' , 'list all tabs'],
\ 'm': [':tabmove +' , 'move tab forward'],
\ 'M': [':tabmove -' , 'move tab backward']
\ },
\ }
" s is for search
let g:which_key_map.s = {
\ 'name': '+search',
\ '/' : [':History/' , 'search history'],
\ 'c' : [':Commands' , 'command'],
\ 'a' : [':Ag' , 'text Ag'],
\ 'b' : [':BLines' , 'seach in current buffer'],
\ 'f' : [':Files' , 'files'],
\ 'h' : [':History' , 'file history'],
\ 'H' : [':History:' , 'command history'],
\ 'l' : [':Lines' , 'lines'] ,
\ 'p' : [':Helptags' , 'help tags'] ,
\ 'S' : [':Colors' , 'color schemes'],
\ 't' : [':Rg' , 'text Rg'],
\ 'y' : [':Filetypes' , 'file types'],
\ 'z' : [':FZF' , 'FZF']
\ }
" S is for startify/sessions
let g:which_key_map.S = {
\ 'name': '+Startify',
\ 'h': [':Startify', 'Home screen'],
\ 'l': [':SLoad', 'load a session'],
\ 's': [':SSave', 'save a session'],
\ 'S': [':SSave!', 'save a session (no prompt)'],
\ 'd': [':SDelete', 'delete a session'],
\ 'D': [':SDelete!', 'delete a session (no prompt)'],
\ 'c': [':SClose', 'close a session']
\ }
" t is for toggle
let g:which_key_map.t = {
\ 'name': '+toggle',
\ 'b': [':BlamerToggle' , 'toggle blamer (git lens)'],
\ 'c': [':Codi' , 'turn on codi'],
\ 'C': [':Codi!' , 'turn off codi'],
\ 'g': [':MaximizerToggle' , 'golden-ratio'],
"\ 'g': [':Goyo' , 'goyo'],
"\ 'G': [':Goyo 100%x85' , 'goyo 100%'],
\ 'l': ['ChangeLineNumbering()' , 'line number'],
\ 'p': ['<M-p>' , 'auto-pairs'],
\ 'q': [':QuickScopeToggle' , 'quick scope highlight'],
\ 's': ['ToggleSignify()' , 'toggle signify'],
"\ 't': [':Twilight' , 'twilight']
\ }
" T is for terminal
let g:which_key_map.T = {
\ 'name' : '+terminal' ,
\ ',' : [
\ ':FloatermNew' ,
\ 'open floating terminal on project root'
\ ],
\ "'": [
\ ':FloatermNew! --cmd=cd %:p:h' ,
\ 'open floating terminal on buffer directory'
\ ],
\ ";": [
\ ':FloatermNew --wintype=split --height=0.1 --postition=bottom',
\ 'open split terminal on project root'
\ ],
\ 'f' : [':FloatermNew fzf' , 'fzf'],
\ 'd' : [':FloatermNew --height=0.99 --width=0.99 lazydocker', 'docker'],
\ 'n' : [':FloatermNew node' , 'node'],
\ 't' : [':FloatermToggle' , 'toggle'],
\ 'b' : [':FloatermNew btm' , 'bottom'],
"\ 'S' : [':', , 'text-to-voice selected']
"\ 's' : [':FloatermNew slack-term' , 'slack'],
"\ 's' : [':FloatermNew ncdu' , 'ncdu'],
\ 'i' : [':FloatermNew iex' , 'iex'],
\ 'r' : [':FloatermNew ranger' , 'ranger'],
\ }
" q is for quitting
let g:which_key_map.q = {
\ 'name': '+quit',
\ 'q': [':qa' , 'Close all files'],
\ 'Q': [':qa!' , 'Close all files without saving']
\ }
" w is for window
let g:which_key_map.w = {
\ 'name': '+window',
\ 'c': [':only' , 'close all splits except current one <C-W> o'],
\ 'd': [':q' , 'quit'],
\ 'D': [':q!' , 'quit without saving'],
\ 'h': ['<C-W>H' , 'move active to left <C-W> H'],
\ 'j': ['<C-W>J' , 'move active to bottom <C-W> J'],
\ 'k': ['<C-W>K' , 'move active to top <C-W> K'],
\ 'l': ['<C-W>L' , 'move active to right <C-W> L'],
\ 'r': {
\ 'name': '+resize',
\ 'h': {
\ 'name': '+height',
\ '+': [':resize +1' , 'increase height by 1 line (<ctrl-w> +)'],
\ '-': [':resize -1' , 'decrease height by 1 line (<ctrl-w> +)']
\ },
\ 'w': {
\ 'name': '+width',
\ '+': [':vertical resize +1', 'increase height by 1 line (<ctrl-w> +)'],
\ '-': [':vertical resize -1', 'increase height by 1 line (<ctrl-w> +)']
\ },
\ },
\ 'R': {
\ 'name': '+rotate',
\ '/': ['<C-W>R' , 'rotate splits to right/down'],
\ '-': ['<C-W>r' , 'rotate splits to left/up'],
\ },
\ '/': [':vsplit' , 'split window right'],
\ '-': [':split' , 'split window below'],
\ '=': ['<C-W>=' , 'equalize windows']
\ }
" W is for wiki
let g:which_key_map.W = {
\ 'name': '+vimwiki',
\ 'd': {
\ 'name': '+diary',
\ 'i': ['<Plug>VimwikiDiaryIndex' , 'diary index'],
\ 'm': ['<Plug>VimwikiMakeTomorrowDiaryNote' , 'diary for tomorrow'],
\ 'n': ['<Plug>VimwikiDiaryNextDay' , 'open next day'],
\ 'p': ['<Plug>VimwikiDiaryPrevDay' , 'open prev day'],
\ 't': ['<Plug>VimwikiMakeDiaryNote' , 'diary for today'],
\ 'T': ['<Plug>VimwikiTabMakeDiaryNote' , 'diary for today in new tab'],
\ 'y': ['<Plug>VimwikiMakeYesterdayDiaryNote' , 'diary for yesterday'],
\ },
\ 'D': ['<Plug>VimwikiDeleteFile' , 'delete current wiki file'],
\ 'h': [':help vimwiki' , 'help'],
\ 'l': {
\ 'name': '+links',
\ 'a': [':VimwikiGenerateLinks' , 'insert links to all available wiki files'],
\ 'c': [':VimwikiCheckLinks' , 'check links'],
\ 'd': ['<Plug>VimwikiDiaryGenerateLinks' , 'update diary links'],
\ 't': [':VimwikiTOC' , 'update table of contents'],
\ },
\ 'p': ['<Plug>MarkdownPreviewToggle' , 'markdown preview'],
\ 'r': ['<Plug>VimwikiRenameFile' , 'rename current wiki file'],
\ 'w': ['<Plug>VimwikiIndex' , 'wiki index'],
\ 'W': {
\ 'name': '+wiki',
\ 'i': ['<Plug>VimwikiIndex' , 'wiki index'],
\ 't': ['<Plug>VimwikiTabIndex' , 'wiki in new tab'],
\ },
\ '=': ['<Plug>VimwikiAddHeaderLevel' , 'add header level'],
\ '-': ['<Plug>VimwikiRemoveHeaderLevel' , 'remove header level'],
\ 't': {
\ 'name': '+table',
\ '1': [':VimwikiTable 1' , 'create table with 1 row'],
\ '2': [':VimwikiTable 2' , 'create table with 2 row'],
\ '3': [':VimwikiTable 3' , 'create table with 3 row'],
\ '4': [':VimwikiTable 4' , 'create table with 4 row'],
\ '5': [':VimwikiTable 5' , 'create table with 5 row'],
\ 'l': ['<Plug>VimwikiTableMoveColumnLeft' , 'move current column to left'],
\ 'r': ['<Plug>VimwikiTableMoveColumnRight' , 'move current column to right'],
\ }
\ }
call which_key#register('<Space>', "g:which_key_map")