which-key.vim 12 KB

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