which-key.vim 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. \ 'p' : [':Git push' , 'push'],
  145. \ 'P' : [':Git pull' , 'pull'],
  146. \ 'r' : [':GRemove' , 'remove'],
  147. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  148. \ 'S' : [':!git status' , 'status'],
  149. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  150. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  151. \ 'v' : [':GV' , 'view commits'],
  152. \ 'V' : [':GV!' , 'view buffer commits'],
  153. \ }
  154. let g:which_key_map.G = {
  155. \ 'name' : '+gist' ,
  156. \ 'a' : [':Gist -a' , 'post gist anon'],
  157. \ 'b' : [':Gist -b' , 'post gist browser'],
  158. \ 'd' : [':Gist -d' , 'delete gist'],
  159. \ 'e' : [':Gist -e' , 'edit gist'],
  160. \ 'l' : [':Gist -l' , 'list public gists'],
  161. \ 's' : [':Gist -ls' , 'list starred gists'],
  162. \ 'm' : [':Gist -m' , 'post gist all buffers'],
  163. \ 'p' : [':Gist -P' , 'post public gist '],
  164. \ 'P' : [':Gist -p' , 'post private gist '],
  165. \ }
  166. " l is for language server protocol
  167. let g:which_key_map.l = {
  168. \ 'name' : '+lsp' ,
  169. \ '.' : [':CocConfig' , 'config'],
  170. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  171. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  172. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  173. \ 'b' : [':CocNext' , 'next action'],
  174. \ 'B' : [':CocPrev' , 'prev action'],
  175. \ 'c' : [':CocList commands' , 'commands'],
  176. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  177. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  178. \ 'e' : [':CocList extensions' , 'extensions'],
  179. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  180. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  181. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  182. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  183. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  184. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  185. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  186. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  187. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  188. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  189. \ 'O' : [':CocList outline' , 'outline'],
  190. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  191. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  192. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  193. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  194. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  195. \ 's' : [':CocList -I symbols' , 'references'],
  196. \ 'S' : [':CocList snippets' , 'snippets'],
  197. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  198. \ 'u' : [':CocListResume' , 'resume list'],
  199. \ 'U' : [':CocUpdate' , 'update CoC'],
  200. \ 'v' : [':Vista!!' , 'tag viewer'],
  201. \ 'z' : [':CocDisable' , 'disable CoC'],
  202. \ 'Z' : [':CocEnable' , 'enable CoC'],
  203. \ }
  204. " t is for terminal
  205. let g:which_key_map.t = {
  206. \ 'name' : '+terminal' ,
  207. \ ';' : [':FloatermNew --wintype=popup --height=6' , 'terminal'],
  208. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  209. \ 'g' : [':FloatermNew lazygit' , 'git'],
  210. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  211. \ 'n' : [':FloatermNew node' , 'node'],
  212. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  213. \ 'p' : [':FloatermNew python' , 'python'],
  214. \ 'm' : [':FloatermNew lazynpm' , 'npm'],
  215. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  216. \ 't' : [':FloatermToggle' , 'toggle'],
  217. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  218. \ 's' : [':FloatermNew ncdu' , 'ncdu'],
  219. \ }
  220. " T is for terminal
  221. let g:which_key_map.T = {
  222. \ 'name' : '+tabline' ,
  223. \ 'b' : [':XTabListBuffers' , 'list buffers'],
  224. \ 'd' : [':XTabCloseBuffer' , 'close buffer'],
  225. \ 'D' : [':XTabDeleteTab' , 'close tab'],
  226. \ 'h' : [':XTabHideBuffer' , 'hide buffer'],
  227. \ 'i' : [':XTabInfo' , 'info'],
  228. \ 'l' : [':XTabLock' , 'lock tab'],
  229. \ 'm' : [':XTabMode' , 'toggle mode'],
  230. \ 'n' : [':tabNext' , 'next tab'],
  231. \ 'N' : [':XTabMoveBufferNext' , 'buffer->'],
  232. \ 't' : [':tabnew' , 'new tab'],
  233. \ 'p' : [':tabprevious' , 'prev tab'],
  234. \ 'P' : [':XTabMoveBufferPrev' , '<-buffer'],
  235. \ 'x' : [':XTabPinBuffer' , 'pin buffer'],
  236. \ }
  237. " w is for wiki
  238. let g:which_key_map.w = {
  239. \ 'name' : '+wiki' ,
  240. \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  241. \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  242. \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  243. \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  244. \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  245. \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  246. \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  247. \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  248. \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  249. \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  250. \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  251. \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  252. \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  253. \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  254. \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  255. \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  256. \ }
  257. " Global
  258. " <Plug>VimwikiIndex
  259. " <Plug>VimwikiTabIndex
  260. " <Plug>VimwikiUISelect
  261. " <Plug>VimwikiDiaryIndex
  262. " <Plug>VimwikiMakeDiaryNote
  263. " <Plug>VimwikiTabMakeDiaryNote
  264. " <Plug>VimwikiMakeYesterdayDiaryNote
  265. " <Plug>VimwikiMakeTomorrowDiaryNote
  266. "
  267. " " Local
  268. " <Plug>Vimwiki2HTML
  269. " <Plug>Vimwiki2HTMLBrowse
  270. " <Plug>VimwikiDiaryGenerateLinks
  271. " <Plug>VimwikiFollowLink
  272. " <Plug>VimwikiSplitLink
  273. " <Plug>VimwikiVSplitLink
  274. " <Plug>VimwikiTabnewLink
  275. " <Plug>VimwikiGoBackLink
  276. " <Plug>VimwikiNextLink
  277. " <Plug>VimwikiPrevLink
  278. " <Plug>VimwikiGoto
  279. " <Plug>VimwikiDeleteLink
  280. " <Plug>VimwikiRenameLink
  281. " <Plug>VimwikiAddHeaderLevel
  282. " Register which key map
  283. call which_key#register('<Space>', "g:which_key_map")