which-key.vim 14 KB

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