which-key.vim 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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['c'] = [ ':Codi!!' , 'virtual repl']
  27. let g:which_key_map['d'] = [ ':bd' , 'delete buffer']
  28. let g:which_key_map['e'] = [ ':CocCommand explorer' , 'explorer' ]
  29. let g:which_key_map['f'] = [ ':Files' , 'search files' ]
  30. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  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['T'] = [ ':Rg' , 'search text' ]
  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' : [':Vista!!' , 'tag viewer'],
  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. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  114. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  115. \ 'v' : [':GV' , 'view commits'],
  116. \ 'V' : [':GV!' , 'view buffer commits'],
  117. \ }
  118. " l is for language server protocol
  119. let g:which_key_map.l = {
  120. \ 'name' : '+lsp' ,
  121. \ '.' : [':CocConfig' , 'config'],
  122. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  123. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  124. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  125. \ 'b' : [':CocNext' , 'next action'],
  126. \ 'B' : [':CocPrev' , 'prev action'],
  127. \ 'c' : [':CocList commands' , 'commands'],
  128. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  129. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  130. \ 'e' : [':CocList extensions' , 'extensions'],
  131. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  132. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  133. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  134. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  135. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  136. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  137. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  138. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  139. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  140. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  141. \ 'O' : [':CocList outline' , 'outline'],
  142. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  143. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  144. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  145. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  146. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  147. \ 's' : [':CocList -I symbols' , 'references'],
  148. \ 'S' : [':CocList snippets' , 'snippets'],
  149. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  150. \ 'u' : [':CocListResume' , 'resume list'],
  151. \ 'U' : [':CocUpdate' , 'update CoC'],
  152. \ 'v' : [':Vista!!' , 'tag viewer'],
  153. \ 'z' : [':CocDisable' , 'disable CoC'],
  154. \ 'Z' : [':CocEnable' , 'enable CoC'],
  155. \ }
  156. " t is for terminal
  157. let g:which_key_map.t = {
  158. \ 'name' : '+terminal' ,
  159. \ ';' : [':FloatermNew --wintype=popup --height=6' , 'terminal'],
  160. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  161. \ 'g' : [':FloatermNew lazygit' , 'git'],
  162. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  163. \ 'n' : [':FloatermNew node' , 'node'],
  164. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  165. \ 'p' : [':FloatermNew python' , 'python'],
  166. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  167. \ 't' : [':FloatermToggle' , 'toggle'],
  168. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  169. \ 's' : [':FloatermNew ncdu' , 'ncdu'],
  170. \ }
  171. " w is for wiki
  172. let g:which_key_map.w = {
  173. \ 'name' : '+wiki' ,
  174. \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  175. \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  176. \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  177. \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  178. \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  179. \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  180. \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  181. \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  182. \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  183. \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  184. \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  185. \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  186. \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  187. \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  188. \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  189. \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  190. \ }
  191. " Global
  192. " <Plug>VimwikiIndex
  193. " <Plug>VimwikiTabIndex
  194. " <Plug>VimwikiUISelect
  195. " <Plug>VimwikiDiaryIndex
  196. " <Plug>VimwikiMakeDiaryNote
  197. " <Plug>VimwikiTabMakeDiaryNote
  198. " <Plug>VimwikiMakeYesterdayDiaryNote
  199. " <Plug>VimwikiMakeTomorrowDiaryNote
  200. "
  201. " " Local
  202. " <Plug>Vimwiki2HTML
  203. " <Plug>Vimwiki2HTMLBrowse
  204. " <Plug>VimwikiDiaryGenerateLinks
  205. " <Plug>VimwikiFollowLink
  206. " <Plug>VimwikiSplitLink
  207. " <Plug>VimwikiVSplitLink
  208. " <Plug>VimwikiTabnewLink
  209. " <Plug>VimwikiGoBackLink
  210. " <Plug>VimwikiNextLink
  211. " <Plug>VimwikiPrevLink
  212. " <Plug>VimwikiGoto
  213. " <Plug>VimwikiDeleteLink
  214. " <Plug>VimwikiRenameLink
  215. " <Plug>VimwikiAddHeaderLevel
  216. " Register which key map
  217. call which_key#register('<Space>', "g:which_key_map")