which-key.vim 13 KB

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