which-key.vim 12 KB

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