which-key.vim 15 KB

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