which-key.vim 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. " Map leader to which_key
  2. nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
  3. vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
  4. " Create map to add keys to
  5. let g:which_key_map = {}
  6. " Define a separator
  7. let g:which_key_sep = '→'
  8. " set timeoutlen=100
  9. " Not a fan of floating windows for this
  10. let g:which_key_use_floating_win = 0
  11. " Change the colors if you want
  12. highlight default link WhichKey Operator
  13. highlight default link WhichKeySeperator DiffAdded
  14. highlight default link WhichKeyGroup Identifier
  15. highlight default link WhichKeyDesc Function
  16. " Hide status line
  17. autocmd! FileType which_key
  18. autocmd FileType which_key set laststatus=0 noshowmode noruler
  19. \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
  20. " Single mappings
  21. let g:which_key_map['/'] = [ ':Commentary' , 'comment' ]
  22. let g:which_key_map['.'] = [ ':e $MYVIMRC' , 'open init' ]
  23. let g:which_key_map[';'] = [ ':Commands' , 'commands' ]
  24. let g:which_key_map['='] = [ '<C-W>=' , 'balance windows' ]
  25. let g:which_key_map[','] = [ 'Startify' , 'start screen' ]
  26. let g:which_key_map['d'] = [ ':bd' , 'delete buffer']
  27. let g:which_key_map['e'] = [ ':CocCommand explorer' , 'explorer' ]
  28. let g:which_key_map['f'] = [ ':Files' , 'search files' ]
  29. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  30. let g:which_key_map['q'] = [ 'q' , 'quit' ]
  31. let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ]
  32. let g:which_key_map['S'] = [ ':SSave' , 'save session' ]
  33. let g:which_key_map['T'] = [ ':Rg' , 'search text' ]
  34. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  35. let g:which_key_map['W'] = [ 'w' , 'write' ]
  36. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  37. " Group mappings
  38. " a is for actions
  39. let g:which_key_map.a = {
  40. \ 'name' : '+actions' ,
  41. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  42. \ 'e' : [':CocCommand explorer' , 'explorer'],
  43. \ 'n' : [':set nonumber!' , 'line-numbers'],
  44. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  45. \ 's' : [':let @/ = ""' , 'remove search highlight'],
  46. \ 't' : [':FloatermToggle' , 'terminal'],
  47. \ 'v' : [':Vista!!' , 'tag viewer'],
  48. \ }
  49. " b is for buffer
  50. let g:which_key_map.b = {
  51. \ 'name' : '+buffer' ,
  52. \ '1' : ['b1' , 'buffer 1'] ,
  53. \ '2' : ['b2' , 'buffer 2'] ,
  54. \ 'd' : ['bd' , 'delete-buffer'] ,
  55. \ 'f' : ['bfirst' , 'first-buffer'] ,
  56. \ 'h' : ['Startify' , 'home-buffer'] ,
  57. \ 'l' : ['blast' , 'last-buffer'] ,
  58. \ 'n' : ['bnext' , 'next-buffer'] ,
  59. \ 'p' : ['bprevious' , 'previous-buffer'] ,
  60. \ '?' : ['Buffers' , 'fzf-buffer'] ,
  61. \ }
  62. " s is for search
  63. let g:which_key_map.s = {
  64. \ 'name' : '+search' ,
  65. \ '/' : [':History/' , 'history'],
  66. \ ';' : [':Commands' , 'commands'],
  67. \ 'a' : [':Ag' , 'text Ag'],
  68. \ 'b' : [':BLines' , 'current buffer'],
  69. \ 'B' : [':Buffers' , 'open buffers'],
  70. \ 'c' : [':Commits' , 'commits'],
  71. \ 'C' : [':BCommits' , 'buffer commits'],
  72. \ 'f' : [':Files' , 'files'],
  73. \ 'g' : [':GFiles' , 'git files'],
  74. \ 'G' : [':GFiles?' , 'modified git files'],
  75. \ 'h' : [':History' , 'file history'],
  76. \ 'H' : [':History:' , 'command history'],
  77. \ 'l' : [':Lines' , 'lines'] ,
  78. \ 'm' : [':Marks' , 'marks'] ,
  79. \ 'M' : [':Maps' , 'normal maps'] ,
  80. \ 'p' : [':Helptags' , 'help tags'] ,
  81. \ 'P' : [':Tags' , 'project tags'],
  82. \ 's' : [':CocList snippets' , 'snippets'],
  83. \ 'S' : [':Colors' , 'color schemes'],
  84. \ 't' : [':Rg' , 'text Rg'],
  85. \ 'T' : [':BTags' , 'buffer tags'],
  86. \ 'w' : [':Windows' , 'search windows'],
  87. \ 'y' : [':Filetypes' , 'file types'],
  88. \ 'z' : [':FZF' , 'FZF'],
  89. \ }
  90. " \ 's' : [':Snippets' , 'snippets'],
  91. " g is for git
  92. let g:which_key_map.g = {
  93. \ 'name' : '+git' ,
  94. \ 'a' : [':Git add .' , 'add all'],
  95. \ 'A' : [':Git add %' , 'add current'],
  96. \ 'b' : [':Git blame' , 'blame'],
  97. \ 'B' : [':GBrowse' , 'browse'],
  98. \ 'c' : [':Git commit' , 'commit'],
  99. \ 'd' : [':Git diff' , 'diff'],
  100. \ 'D' : [':Gdiffsplit' , 'diff split'],
  101. \ 'g' : [':GGrep' , 'git grep'],
  102. \ 'G' : [':Gstatus' , 'status'],
  103. \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  104. \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  105. \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  106. \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  107. \ 'l' : [':Git log' , 'log'],
  108. \ 'p' : [':Git push' , 'push'],
  109. \ 'P' : [':Git pull' , 'pull'],
  110. \ 'r' : [':GRemove' , 'remove'],
  111. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  112. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  113. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  114. \ 'v' : [':GV' , 'view commits'],
  115. \ 'V' : [':GV!' , 'view buffer commits'],
  116. \ }
  117. " l is for language server protocol
  118. let g:which_key_map.l = {
  119. \ 'name' : '+lsp' ,
  120. \ '.' : [':CocConfig' , 'config'],
  121. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  122. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  123. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  124. \ 'b' : [':CocNext' , 'next action'],
  125. \ 'B' : [':CocPrev' , 'prev action'],
  126. \ 'c' : [':CocList commands' , 'commands'],
  127. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  128. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  129. \ 'e' : [':CocList extensions' , 'extensions'],
  130. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  131. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  132. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  133. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  134. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  135. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  136. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  137. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  138. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  139. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  140. \ 'O' : [':CocList outline' , 'outline'],
  141. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  142. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  143. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  144. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  145. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  146. \ 's' : [':CocList -I symbols' , 'references'],
  147. \ 'S' : [':CocList snippets' , 'snippets'],
  148. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  149. \ 'u' : [':CocListResume' , 'resume list'],
  150. \ 'U' : [':CocUpdate' , 'update CoC'],
  151. \ 'v' : [':Vista!!' , 'tag viewer'],
  152. \ 'z' : [':CocDisable' , 'disable CoC'],
  153. \ 'Z' : [':CocEnable' , 'enable CoC'],
  154. \ }
  155. " t is for terminal
  156. let g:which_key_map.t = {
  157. \ 'name' : '+terminal' ,
  158. \ ';' : [':FloatermNew --wintype=popup --height=6' , 'terminal'],
  159. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  160. \ 'g' : [':FloatermNew lazygit' , 'git'],
  161. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  162. \ 'n' : [':FloatermNew node' , 'node'],
  163. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  164. \ 'p' : [':FloatermNew python' , 'python'],
  165. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  166. \ 't' : [':FloatermToggle' , 'toggle'],
  167. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  168. \ 's' : [':FloatermNew ncdu' , 'ncdu'],
  169. \ }
  170. " w is for wiki
  171. let g:which_key_map.w = {
  172. \ 'name' : '+wiki' ,
  173. \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  174. \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  175. \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  176. \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  177. \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  178. \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  179. \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  180. \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  181. \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  182. \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  183. \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  184. \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  185. \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  186. \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  187. \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  188. \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  189. \ }
  190. " Global
  191. " <Plug>VimwikiIndex
  192. " <Plug>VimwikiTabIndex
  193. " <Plug>VimwikiUISelect
  194. " <Plug>VimwikiDiaryIndex
  195. " <Plug>VimwikiMakeDiaryNote
  196. " <Plug>VimwikiTabMakeDiaryNote
  197. " <Plug>VimwikiMakeYesterdayDiaryNote
  198. " <Plug>VimwikiMakeTomorrowDiaryNote
  199. "
  200. " " Local
  201. " <Plug>Vimwiki2HTML
  202. " <Plug>Vimwiki2HTMLBrowse
  203. " <Plug>VimwikiDiaryGenerateLinks
  204. " <Plug>VimwikiFollowLink
  205. " <Plug>VimwikiSplitLink
  206. " <Plug>VimwikiVSplitLink
  207. " <Plug>VimwikiTabnewLink
  208. " <Plug>VimwikiGoBackLink
  209. " <Plug>VimwikiNextLink
  210. " <Plug>VimwikiPrevLink
  211. " <Plug>VimwikiGoto
  212. " <Plug>VimwikiDeleteLink
  213. " <Plug>VimwikiRenameLink
  214. " <Plug>VimwikiAddHeaderLevel
  215. " Register which key map
  216. call which_key#register('<Space>', "g:which_key_map")