which-key.vim 15 KB

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