which-key.vim 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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['/'] = [ ':call Comment()' , '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'] = [ ':Farr' , 'find and replace' ]
  29. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  30. let g:which_key_map['p'] = [ ':Files' , 'search files' ]
  31. let g:which_key_map['q'] = [ 'q' , 'quit' ]
  32. let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ]
  33. let g:which_key_map['S'] = [ ':SSave' , 'save session' ]
  34. let g:which_key_map['u'] = [ ':UndotreeToggle' , 'undo tree']
  35. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  36. let g:which_key_map['W'] = [ 'w' , 'write' ]
  37. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  38. " Group mappings
  39. " a is for actions
  40. let g:which_key_map.a = {
  41. \ 'name' : '+actions' ,
  42. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  43. \ 'e' : [':CocCommand explorer' , 'explorer'],
  44. \ 'l' : [':Bracey' , 'start live server'],
  45. \ 'L' : [':BraceyStop' , 'stop live server'],
  46. \ 'n' : [':set nonumber!' , 'line-numbers'],
  47. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  48. \ 's' : [':let @/ = ""' , 'remove search highlight'],
  49. \ 't' : [':FloatermToggle' , 'terminal'],
  50. \ 'v' : [':Codi' , 'virtual repl on'],
  51. \ 'V' : [':Codi!' , 'virtual repl off'],
  52. \ }
  53. " b is for buffer
  54. let g:which_key_map.b = {
  55. \ 'name' : '+buffer' ,
  56. \ '1' : ['b1' , 'buffer 1'] ,
  57. \ '2' : ['b2' , 'buffer 2'] ,
  58. \ 'd' : ['bd' , 'delete-buffer'] ,
  59. \ 'f' : ['bfirst' , 'first-buffer'] ,
  60. \ 'h' : ['Startify' , 'home-buffer'] ,
  61. \ 'l' : ['blast' , 'last-buffer'] ,
  62. \ 'n' : ['bnext' , 'next-buffer'] ,
  63. \ 'p' : ['bprevious' , 'previous-buffer'] ,
  64. \ '?' : ['Buffers' , 'fzf-buffer'] ,
  65. \ }
  66. " s is for search
  67. let g:which_key_map.s = {
  68. \ 'name' : '+search' ,
  69. \ '/' : [':History/' , 'history'],
  70. \ ';' : [':Commands' , 'commands'],
  71. \ 'a' : [':Ag' , 'text Ag'],
  72. \ 'b' : [':BLines' , 'current buffer'],
  73. \ 'B' : [':Buffers' , 'open buffers'],
  74. \ 'c' : [':Commits' , 'commits'],
  75. \ 'C' : [':BCommits' , 'buffer commits'],
  76. \ 'f' : [':Files' , 'files'],
  77. \ 'g' : [':GFiles' , 'git files'],
  78. \ 'G' : [':GFiles?' , 'modified git files'],
  79. \ 'h' : [':History' , 'file history'],
  80. \ 'H' : [':History:' , 'command history'],
  81. \ 'l' : [':Lines' , 'lines'] ,
  82. \ 'm' : [':Marks' , 'marks'] ,
  83. \ 'M' : [':Maps' , 'normal maps'] ,
  84. \ 'p' : [':Helptags' , 'help tags'] ,
  85. \ 'P' : [':Tags' , 'project tags'],
  86. \ 's' : [':CocList snippets' , 'snippets'],
  87. \ 'S' : [':Colors' , 'color schemes'],
  88. \ 't' : [':Rg' , 'text Rg'],
  89. \ 'T' : [':BTags' , 'buffer tags'],
  90. \ 'w' : [':Windows' , 'search windows'],
  91. \ 'y' : [':Filetypes' , 'file types'],
  92. \ 'z' : [':FZF' , 'FZF'],
  93. \ }
  94. " \ 's' : [':Snippets' , 'snippets'],
  95. " g is for git
  96. let g:which_key_map.g = {
  97. \ 'name' : '+git' ,
  98. \ 'a' : [':Git add .' , 'add all'],
  99. \ 'A' : [':Git add %' , 'add current'],
  100. \ 'b' : [':Git blame' , 'blame'],
  101. \ 'B' : [':GBrowse' , 'browse'],
  102. \ 'c' : [':Git commit' , 'commit'],
  103. \ 'd' : [':Git diff' , 'diff'],
  104. \ 'D' : [':Gdiffsplit' , 'diff split'],
  105. \ 'g' : [':GGrep' , 'git grep'],
  106. \ 'G' : [':Gstatus' , 'status'],
  107. \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  108. \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  109. \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  110. \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  111. \ 'l' : [':Git log' , 'log'],
  112. \ 'p' : [':Git push' , 'push'],
  113. \ 'P' : [':Git pull' , 'pull'],
  114. \ 'r' : [':GRemove' , 'remove'],
  115. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  116. \ 'S' : [':!git status' , 'status'],
  117. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  118. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  119. \ 'v' : [':GV' , 'view commits'],
  120. \ 'V' : [':GV!' , 'view buffer commits'],
  121. \ }
  122. " l is for language server protocol
  123. let g:which_key_map.l = {
  124. \ 'name' : '+lsp' ,
  125. \ '.' : [':CocConfig' , 'config'],
  126. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  127. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  128. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  129. \ 'b' : [':CocNext' , 'next action'],
  130. \ 'B' : [':CocPrev' , 'prev action'],
  131. \ 'c' : [':CocList commands' , 'commands'],
  132. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  133. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  134. \ 'e' : [':CocList extensions' , 'extensions'],
  135. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  136. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  137. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  138. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  139. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  140. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  141. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  142. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  143. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  144. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  145. \ 'O' : [':CocList outline' , 'outline'],
  146. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  147. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  148. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  149. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  150. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  151. \ 's' : [':CocList -I symbols' , 'references'],
  152. \ 'S' : [':CocList snippets' , 'snippets'],
  153. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  154. \ 'u' : [':CocListResume' , 'resume list'],
  155. \ 'U' : [':CocUpdate' , 'update CoC'],
  156. \ 'v' : [':Vista!!' , 'tag viewer'],
  157. \ 'z' : [':CocDisable' , 'disable CoC'],
  158. \ 'Z' : [':CocEnable' , 'enable CoC'],
  159. \ }
  160. " t is for terminal
  161. let g:which_key_map.t = {
  162. \ 'name' : '+terminal' ,
  163. \ ';' : [':FloatermNew --wintype=popup --height=6' , 'terminal'],
  164. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  165. \ 'g' : [':FloatermNew lazygit' , 'git'],
  166. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  167. \ 'n' : [':FloatermNew node' , 'node'],
  168. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  169. \ 'p' : [':FloatermNew python' , 'python'],
  170. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  171. \ 't' : [':FloatermToggle' , 'toggle'],
  172. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  173. \ 's' : [':FloatermNew ncdu' , 'ncdu'],
  174. \ }
  175. " T is for terminal
  176. let g:which_key_map.T = {
  177. \ 'name' : '+tabline' ,
  178. \ 'b' : [':XTabListBuffers' , 'list buffers'],
  179. \ 'd' : [':XTabCloseBuffer' , 'close buffer'],
  180. \ 'D' : [':XTabDeleteTab' , 'close tab'],
  181. \ 'h' : [':XTabHideBuffer' , 'hide buffer'],
  182. \ 'i' : [':XTabInfo' , 'info'],
  183. \ 'l' : [':XTabLock' , 'lock tab'],
  184. \ 'm' : [':XTabMode' , 'toggle mode'],
  185. \ 'n' : [':tabNext' , 'next tab'],
  186. \ 'N' : [':XTabMoveBufferNext' , 'buffer->'],
  187. \ 't' : [':tabnew' , 'new tab'],
  188. \ 'p' : [':tabprevious' , 'prev tab'],
  189. \ 'P' : [':XTabMoveBufferPrev' , '<-buffer'],
  190. \ 'x' : [':XTabPinBuffer' , 'pin buffer'],
  191. \ }
  192. " w is for wiki
  193. let g:which_key_map.w = {
  194. \ 'name' : '+wiki' ,
  195. \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  196. \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  197. \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  198. \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  199. \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  200. \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  201. \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  202. \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  203. \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  204. \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  205. \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  206. \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  207. \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  208. \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  209. \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  210. \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  211. \ }
  212. " Global
  213. " <Plug>VimwikiIndex
  214. " <Plug>VimwikiTabIndex
  215. " <Plug>VimwikiUISelect
  216. " <Plug>VimwikiDiaryIndex
  217. " <Plug>VimwikiMakeDiaryNote
  218. " <Plug>VimwikiTabMakeDiaryNote
  219. " <Plug>VimwikiMakeYesterdayDiaryNote
  220. " <Plug>VimwikiMakeTomorrowDiaryNote
  221. "
  222. " " Local
  223. " <Plug>Vimwiki2HTML
  224. " <Plug>Vimwiki2HTMLBrowse
  225. " <Plug>VimwikiDiaryGenerateLinks
  226. " <Plug>VimwikiFollowLink
  227. " <Plug>VimwikiSplitLink
  228. " <Plug>VimwikiVSplitLink
  229. " <Plug>VimwikiTabnewLink
  230. " <Plug>VimwikiGoBackLink
  231. " <Plug>VimwikiNextLink
  232. " <Plug>VimwikiPrevLink
  233. " <Plug>VimwikiGoto
  234. " <Plug>VimwikiDeleteLink
  235. " <Plug>VimwikiRenameLink
  236. " <Plug>VimwikiAddHeaderLevel
  237. " Register which key map
  238. call which_key#register('<Space>', "g:which_key_map")