which-key.vim 15 KB

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