which-key.vim 15 KB

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