which-key.vim 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. " Leader Key Maps
  2. let @s = 'veS"'
  3. " Timeout
  4. let g:which_key_timeout = 100
  5. let g:which_key_display_names = {'<CR>': '↵', '<TAB>': '⇆'}
  6. " Map leader to which_key
  7. nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
  8. vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
  9. " Create map to add keys to
  10. let g:which_key_map = {}
  11. " Define a separator
  12. let g:which_key_sep = '→'
  13. " set timeoutlen=100
  14. " Coc Search & refactor
  15. nnoremap <leader>? :CocSearch <C-R>=expand("<cword>")<CR><CR>
  16. let g:which_key_map['?'] = 'search word'
  17. " Not a fan of floating windows for this
  18. let g:which_key_use_floating_win = 0
  19. let g:which_key_max_size = 0
  20. " let g:which_key_position = 'botright'
  21. " let g:which_key_position = 'topleft'
  22. " let g:which_key_vertical = 1
  23. " Change the colors if you want
  24. " Hide status line
  25. autocmd! FileType which_key
  26. autocmd FileType which_key set laststatus=0 noshowmode noruler
  27. \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
  28. " Single mappings
  29. let g:which_key_map['/'] = [ ':call Comment()' , 'comment' ]
  30. let g:which_key_map['.'] = [ ':e $MYVIMRC' , 'open init' ]
  31. let g:which_key_map[';'] = [ ':Commands' , 'commands' ]
  32. let g:which_key_map['='] = [ '<C-W>=' , 'balance windows' ]
  33. let g:which_key_map['e'] = [ ':CocCommand explorer --toggle --sources=file+' , 'explorer' ]
  34. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  35. let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ]
  36. let g:which_key_map['o'] = [ ':RnvimrToggle' , 'open' ]
  37. let g:which_key_map['p'] = [ ':Files' , 'search files' ]
  38. let g:which_key_map['q'] = [ '<Plug>(coc-fix-current)' , 'quickfix' ]
  39. let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ]
  40. let g:which_key_map['u'] = [ ':UndotreeToggle' , 'undo tree']
  41. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  42. let g:which_key_map['W'] = [ ':call WindowSwap#EasyWindowSwap()' , 'move window' ]
  43. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  44. " Group mappings
  45. " a is for actions
  46. let g:which_key_map.a = {
  47. \ 'name' : '+actions' ,
  48. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  49. \ 'e' : [':CocCommand explorer' , 'explorer'],
  50. \ 'h' : [':let @/ = ""' , 'remove search highlight'],
  51. \ 'l' : [':Bracey' , 'start live server'],
  52. \ 'L' : [':BraceyStop' , 'stop live server'],
  53. \ 'm' : [':MarkdownPreview' , 'markdown preview'],
  54. \ 'M' : [':MarkdownPreviewStop' , 'markdown preview stop'],
  55. \ 'n' : [':set nonumber!' , 'line-numbers'],
  56. \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'],
  57. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  58. \ 't' : [':FloatermToggle' , 'terminal'],
  59. \ 'v' : [':Codi' , 'virtual repl on'],
  60. \ 'V' : [':Codi!' , 'virtual repl off'],
  61. \ 'w' : [':StripWhitespace' , 'strip whitespace'],
  62. \ }
  63. " b is for buffer
  64. let g:which_key_map.b = {
  65. \ 'name' : '+buffer' ,
  66. \ '>' : [':BufferMoveNext' , 'move next'],
  67. \ '<' : [':BufferMovePrevious' , 'move prev'],
  68. \ '1' : [':BufferGoto 1' , 'buffer 1'],
  69. \ '2' : [':BufferGoto 2' , 'buffer 2'],
  70. \ '3' : [':BufferGoto 3' , 'buffer 3'],
  71. \ '4' : [':BufferGoto 4' , 'buffer 4'],
  72. \ '5' : [':BufferGoto 5' , 'buffer 5'],
  73. \ '6' : [':BufferGoto 6' , 'buffer 6'],
  74. \ '7' : [':BufferGoto 7' , 'buffer 7'],
  75. \ '8' : [':BufferGoto 8' , 'buffer 8'],
  76. \ '9' : [':BufferGoto 9' , 'buffer 9'],
  77. \ '0' : [':BufferGoto 0' , 'buffer 0'],
  78. \ 'b' : [':BufferPick' , 'pick buffer'],
  79. \ 'd' : [':Bdelete' , 'delete-buffer'],
  80. \ 'D' : [':BufferOrderByDirectory', 'order by directory'],
  81. \ 'f' : ['bfirst' , 'first-buffer'],
  82. \ 'l' : ['blast' , 'last buffer'],
  83. \ 'L' : [':BufferOrderByLanguage' , 'order by language'],
  84. \ 'n' : ['bnext' , 'next-buffer'],
  85. \ 'p' : ['bprevious' , 'previous-buffer'],
  86. \ '?' : ['Buffers' , 'fzf-buffer'],
  87. \ }
  88. " d is for debug
  89. let g:which_key_map.d = {
  90. \ 'name' : '+debug' ,
  91. \ 'b' : ['<Plug>VimspectorToggleBreakpoint' , 'breakpoint'],
  92. \ 'B' : ['<Plug>VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'],
  93. \ 'c' : ['<Plug>VimspectorRunToCursor' , 'run to cursor'],
  94. \ 'd' : ['<Plug>VimspectorContinue' , 'continue'],
  95. \ 'f' : ['<Plug>VimspectorAddFunctionBreakpoint' , 'function breakpoint'],
  96. \ 'm' : [':MaximizerToggle' , 'maximize window'],
  97. \ 'o' : ['<Plug>VimspectorStepOver' , 'step over'],
  98. \ 'O' : ['<Plug>VimspectorStepOut' , 'step out'],
  99. \ 'i' : ['<Plug>VimspectorStepInto' , 'step into'],
  100. \ 'p' : ['<Plug>VimspectorPause' , 'pause'],
  101. \ 'r' : ['<Plug>VimspectorRestart' , 'restart'],
  102. \ 's' : ['<Plug>VimspectorStop' , 'stop'],
  103. \ }
  104. " f is for find and replace
  105. let g:which_key_map.f = {
  106. \ 'name' : '+find & replace' ,
  107. \ 'f' : [':Farr --source=vimgrep' , 'file'],
  108. \ 'p' : [':Farr --source=rgnvim' , 'project'],
  109. \ }
  110. " k is for task
  111. let g:which_key_map.k = {
  112. \ 'name' : '+task' ,
  113. \ 'c' : [':AsyncTask file-compile' , 'compile file'],
  114. \ 'b' : [':AsyncTask project-build' , 'build project'],
  115. \ 'e' : [':AsyncTaskEdit' , 'edit local tasks'],
  116. \ 'f' : [':AsyncTaskFzf' , 'find task'],
  117. \ 'g' : [':AsyncTaskEdit!' , 'edit global tasks'],
  118. \ 'h' : [':AsyncTaskList!' , 'list hidden tasks'],
  119. \ 'l' : [':CocList tasks' , 'list tasks'],
  120. \ 'm' : [':AsyncTaskMacro' , 'macro help'],
  121. \ 'o' : [':copen' , 'open task view'],
  122. \ 'r' : [':AsyncTask file-run' , 'run file'],
  123. \ 'p' : [':AsyncTask project-run' , 'run project'],
  124. \ 'x' : [':cclose' , 'close task view'],
  125. \ }
  126. " \ 'l' : [':AsyncTaskList' , 'list tasks'],
  127. " m is for mark
  128. let g:which_key_map.m = {
  129. \ 'name' : '+mark' ,
  130. \ 'c' : [':CocCommand bookmark.clearForCurrentFile', 'clear file'],
  131. \ 'C' : [':CocCommand bookmark.clearForAllFiles', 'clear project'],
  132. \ 'j' : [':CocCommand bookmark.next', 'next bookmark'],
  133. \ 'k' : [':CocCommand bookmark.prev', 'prev bookmark'],
  134. \ 't' : [':CocCommand bookmark.toggle', 'toggle bookmark'],
  135. \ }
  136. " CoC throws an error
  137. " \ 'a' : [':CocCommand bookmark.annotate', 'annotate bookmark'],
  138. " " s is for search
  139. " let g:which_key_map.s = {
  140. " \ 'name' : '+search' ,
  141. " \ '/' : [':History/' , 'history'],
  142. " \ ';' : [':Commands' , 'commands'],
  143. " \ 'a' : [':Ag' , 'text Ag'],
  144. " \ 'b' : [':BLines' , 'current buffer'],
  145. " \ 'B' : [':Buffers' , 'open buffers'],
  146. " \ 'c' : [':Commits' , 'commits'],
  147. " \ 'C' : [':BCommits' , 'buffer commits'],
  148. " \ 'f' : [':Files' , 'files'],
  149. " \ 'g' : [':GFiles' , 'git files'],
  150. " \ 'G' : [':GFiles?' , 'modified git files'],
  151. " \ 'h' : [':History' , 'file history'],
  152. " \ 'H' : [':History:' , 'command history'],
  153. " \ 'l' : [':Lines' , 'lines'] ,
  154. " \ 'm' : [':Marks' , 'marks'] ,
  155. " \ 'M' : [':Maps' , 'normal maps'] ,
  156. " \ 'p' : [':Helptags' , 'help tags'] ,
  157. " \ 'P' : [':Tags' , 'project tags'],
  158. " \ 's' : [':CocList snippets' , 'snippets'],
  159. " \ 'S' : [':Colors' , 'color schemes'],
  160. " \ 't' : [':Rg' , 'text Rg'],
  161. " \ 'T' : [':BTags' , 'buffer tags'],
  162. " \ 'w' : [':Windows' , 'search windows'],
  163. " \ 'y' : [':Filetypes' , 'file types'],
  164. " \ 'z' : [':FZF' , 'FZF'],
  165. " \ }
  166. " \ 's' : [':Snippets' , 'snippets'],
  167. " TODO fix FZF preview or just move to Telescope
  168. " s is for search
  169. let g:which_key_map.s = {
  170. \ 'name' : '+search' ,
  171. \ '/' : [':History/' , 'history'],
  172. \ ';' : [':FzfPreviewCommandPalette' , 'commands'],
  173. \ 'a' : [':Ag' , 'text Ag'],
  174. \ 'b' : [':CocCommand fzf-preview.BufferLines' , 'current buffer'],
  175. \ 'B' : [':CocCommand fzf-preview.Buffers' , 'open buffers'],
  176. \ 'c' : [':Commits' , 'commits'],
  177. \ 'C' : [':BCommits' , 'buffer commits'],
  178. \ 'd' : [':CocCommand fzf-preview.DirectoryFiles' , 'directories'],
  179. \ 'f' : [':CocCommand fzf-preview.ProjectFiles' , 'files'],
  180. \ 'g' : [':CocCommand fzf-preview.GitFiles' , 'git files'],
  181. \ 'G' : [':GFiles?' , 'modified git files'],
  182. \ 'h' : [':History' , 'file history'],
  183. \ 'H' : [':History:' , 'command history'],
  184. \ 'l' : [':Lines' , 'lines'] ,
  185. \ 'm' : [':CocCommand fzf-preview.Marks', 'list marks'],
  186. \ 'M' : [':Maps' , 'normal maps'] ,
  187. \ 'p' : [':Helptags' , 'help tags'] ,
  188. \ 'P' : [':Tags' , 'project tags'],
  189. \ 'q' : [':CocCommand fzf-preview.QuickFix' , 'quickfix list'],
  190. \ 's' : [':CocList snippets' , 'snippets'],
  191. \ 'S' : [':Colors' , 'color schemes'],
  192. \ 't' : [':Rg' , 'text Rg'],
  193. \ 'T' : [':BTags' , 'buffer tags'],
  194. \ 'w' : [':Windows' , 'search windows'],
  195. \ 'y' : [':Filetypes' , 'file types'],
  196. \ 'z' : [':FZF' , 'FZF'],
  197. \ }
  198. "
  199. " :CocCommand fzf-preview.AllBuffers
  200. " :CocCommand fzf-preview.Changes
  201. " :CocCommand fzf-preview.Yankround
  202. " :CocCommand fzf-preview.CocReferences
  203. " :CocCommand fzf-preview.CocDiagnostics
  204. " :CocCommand fzf-preview.CocCurrentDiagnostics
  205. " :CocCommand fzf-preview.CocTypeDefinitions
  206. " \ 'l' : [':CocCommand fzf-preview.Bookmarks', 'list bookmarks'],
  207. " $FZF_PREVIEW_PREVIEW_BAT_THEME = 'ansi-dark'
  208. "
  209. let g:which_key_map.S = {
  210. \ 'name' : '+Session' ,
  211. \ 'c' : [':SClose' , 'Close Session'] ,
  212. \ 'd' : [':SDelete' , 'Delete Session'] ,
  213. \ 'l' : [':SLoad' , 'Load Session'] ,
  214. \ 's' : [':Startify' , 'Start Page'] ,
  215. \ 'S' : [':SSave' , 'Save Session'] ,
  216. \ }
  217. " g is for git
  218. let g:which_key_map.g = {
  219. \ 'name' : '+git' ,
  220. \ 'a' : [':Git add .' , 'add all'],
  221. \ 'A' : [':CocCommand fzf-preview.GitStatus' , 'actions'],
  222. \ 'b' : [':Git blame' , 'blame'],
  223. \ 'B' : [':GBrowse' , 'browse'],
  224. \ 'c' : [':Git commit' , 'commit'],
  225. \ 'd' : [':Git diff' , 'diff'],
  226. \ 'D' : [':Gdiffsplit' , 'diff split'],
  227. \ 'g' : [':GGrep' , 'git grep'],
  228. \ 'G' : [':Gstatus' , 'status'],
  229. \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  230. \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  231. \ 'i' : [':Gist -b' , 'post gist'],
  232. \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  233. \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  234. \ 'l' : [':Git log' , 'log'],
  235. \ 'm' : ['<Plug>(git-messenger)' , 'message'],
  236. \ 'p' : [':Git push' , 'push'],
  237. \ 'P' : [':Git pull' , 'pull'],
  238. \ 'r' : [':GRemove' , 'remove'],
  239. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  240. \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'],
  241. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  242. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  243. \ 'v' : [':GV' , 'view commits'],
  244. \ 'V' : [':GV!' , 'view buffer commits'],
  245. \ }
  246. " \ 'A' : [':Git add %' , 'add current'],
  247. " \ 'S' : [':!git status' , 'status'],
  248. "
  249. "
  250. "
  251. let g:which_key_map.G = {
  252. \ 'name' : '+gist' ,
  253. \ 'a' : [':Gist -a' , 'post gist anon'],
  254. \ 'b' : [':Gist -b' , 'post gist browser'],
  255. \ 'd' : [':Gist -d' , 'delete gist'],
  256. \ 'e' : [':Gist -e' , 'edit gist'],
  257. \ 'l' : [':Gist -l' , 'list public gists'],
  258. \ 's' : [':Gist -ls' , 'list starred gists'],
  259. \ 'm' : [':Gist -m' , 'post gist all buffers'],
  260. \ 'p' : [':Gist -P' , 'post public gist '],
  261. \ 'P' : [':Gist -p' , 'post private gist '],
  262. \ }
  263. " l is for language server protocol
  264. let g:which_key_map.l = {
  265. \ 'name' : '+lsp' ,
  266. \ '.' : [':CocConfig' , 'config'],
  267. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  268. \ 'a' : ['<Plug>(coc-codeaction)' , 'code action'],
  269. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  270. \ 'b' : [':CocNext' , 'next action'],
  271. \ 'B' : [':CocPrev' , 'prev action'],
  272. \ 'c' : [':CocList commands' , 'commands'],
  273. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  274. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  275. \ 'e' : [':CocList extensions' , 'extensions'],
  276. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  277. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  278. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  279. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  280. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  281. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  282. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  283. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  284. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  285. \ 'o' : [':Vista!!' , 'outline'],
  286. \ 'O' : [':CocList outline' , 'search outline'],
  287. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  288. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  289. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  290. \ 'r' : ['<Plug>(coc-references)' , 'references'],
  291. \ 'R' : ['<Plug>(coc-rename)' , 'rename'],
  292. \ 's' : [':CocList -I symbols' , 'references'],
  293. \ 'S' : [':CocList snippets' , 'snippets'],
  294. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  295. \ 'u' : [':CocListResume' , 'resume list'],
  296. \ 'U' : [':CocUpdate' , 'update CoC'],
  297. \ 'z' : [':CocDisable' , 'disable CoC'],
  298. \ 'Z' : [':CocEnable' , 'enable CoC'],
  299. \ }
  300. " \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  301. " t is for terminal
  302. let g:which_key_map.t = {
  303. \ 'name' : '+terminal' ,
  304. \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'],
  305. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  306. \ 'g' : [':FloatermNew lazygit' , 'git'],
  307. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  308. \ 'n' : [':FloatermNew node' , 'node'],
  309. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  310. \ 'p' : [':FloatermNew python' , 'python'],
  311. \ 'm' : [':FloatermNew lazynpm' , 'npm'],
  312. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  313. \ 't' : [':FloatermToggle' , 'toggle'],
  314. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  315. \ 's' : [':FloatermNew ncdu' , 'ncdu'],
  316. \ }
  317. " w is for wiki
  318. " let g:which_key_map.w = {
  319. " \ 'name' : '+wiki' ,
  320. " \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  321. " \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  322. " \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  323. " \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  324. " \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  325. " \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  326. " \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  327. " \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  328. " \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  329. " \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  330. " \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  331. " \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  332. " \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  333. " \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  334. " \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  335. " \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  336. " \ }
  337. " Global
  338. " <Plug>VimwikiIndex
  339. " <Plug>VimwikiTabIndex
  340. " <Plug>VimwikiUISelect
  341. " <Plug>VimwikiDiaryIndex
  342. " <Plug>VimwikiMakeDiaryNote
  343. " <Plug>VimwikiTabMakeDiaryNote
  344. " <Plug>VimwikiMakeYesterdayDiaryNote
  345. " <Plug>VimwikiMakeTomorrowDiaryNote
  346. "
  347. " " Local
  348. " <Plug>Vimwiki2HTML
  349. " <Plug>Vimwiki2HTMLBrowse
  350. " <Plug>VimwikiDiaryGenerateLinks
  351. " <Plug>VimwikiFollowLink
  352. " <Plug>VimwikiSplitLink
  353. " <Plug>VimwikiVSplitLink
  354. " <Plug>VimwikiTabnewLink
  355. " <Plug>VimwikiGoBackLink
  356. " <Plug>VimwikiNextLink
  357. " <Plug>VimwikiPrevLink
  358. " <Plug>VimwikiGoto
  359. " <Plug>VimwikiDeleteLink
  360. " <Plug>VimwikiRenameLink
  361. " <Plug>VimwikiAddHeaderLevel
  362. " Register which key map
  363. call which_key#register('<Space>', "g:which_key_map")