which-key.vim 15 KB

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