which-key.vim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. " Leader Key Maps
  2. let @s = 'veS"'
  3. " Timeout
  4. let g:which_key_timeout = 100
  5. let g:which_key_display_names = {'<CR>': '↵', '<TAB>': '⇆'}
  6. " Map leader to which_key
  7. nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
  8. vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
  9. " Create map to add keys to
  10. let g:which_key_map = {}
  11. " Define a separator
  12. let g:which_key_sep = '→'
  13. " set timeoutlen=100
  14. " Not a fan of floating windows for this
  15. let g:which_key_use_floating_win = 0
  16. let g:which_key_max_size = 0
  17. " let g:which_key_position = 'botright'
  18. " let g:which_key_position = 'topleft'
  19. " let g:which_key_vertical = 1
  20. " Change the colors if you want
  21. " Hide status line
  22. autocmd! FileType which_key
  23. autocmd FileType which_key set laststatus=0 noshowmode noruler
  24. \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
  25. " Single mappings
  26. let g:which_key_map['/'] = [ ':call Comment()' , 'comment' ]
  27. let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'comment' ]
  28. let g:which_key_map['.'] = [ ':e $MYVIMRC' , 'open init' ]
  29. let g:which_key_map[';'] = [ ':Commands' , 'commands' ]
  30. let g:which_key_map['='] = [ '<C-W>=' , 'balance windows' ]
  31. let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ]
  32. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  33. let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ]
  34. let g:which_key_map['o'] = [ ':RnvimrToggle' , 'open' ]
  35. let g:which_key_map['p'] = [ ':Files' , 'search files' ]
  36. " TODO fix this
  37. " let g:which_key_map['q'] = [ ':q' , 'quit' ]
  38. let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ]
  39. let g:which_key_map['u'] = [ ':UndotreeToggle' , 'undo tree']
  40. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  41. let g:which_key_map['W'] = [ ':call WindowSwap#EasyWindowSwap()' , 'move window' ]
  42. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  43. " Group mappings
  44. " a is for actions
  45. let g:which_key_map.a = {
  46. \ 'name' : '+actions' ,
  47. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  48. \ 'e' : [':CocCommand explorer' , 'explorer'],
  49. \ 'h' : [':let @/ = ""' , 'remove search highlight'],
  50. \ 'l' : [':Bracey' , 'start live server'],
  51. \ 'L' : [':BraceyStop' , 'stop live server'],
  52. \ 'm' : [':MarkdownPreview' , 'markdown preview'],
  53. \ 'M' : [':MarkdownPreviewStop' , 'markdown preview stop'],
  54. \ 'n' : [':set nonumber!' , 'line-numbers'],
  55. \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'],
  56. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  57. \ 't' : [':FloatermToggle' , 'terminal'],
  58. \ 'v' : [':Codi' , 'virtual repl on'],
  59. \ 'V' : [':Codi!' , 'virtual repl off'],
  60. \ 'w' : [':StripWhitespace' , 'strip whitespace'],
  61. \ }
  62. " b is for buffer
  63. let g:which_key_map.b = {
  64. \ 'name' : '+buffer' ,
  65. \ '>' : [':BufferMoveNext' , 'move next'],
  66. \ '<' : [':BufferMovePrevious' , 'move prev'],
  67. \ '1' : [':BufferGoto 1' , 'buffer 1'],
  68. \ '2' : [':BufferGoto 2' , 'buffer 2'],
  69. \ '3' : [':BufferGoto 3' , 'buffer 3'],
  70. \ '4' : [':BufferGoto 4' , 'buffer 4'],
  71. \ '5' : [':BufferGoto 5' , 'buffer 5'],
  72. \ '6' : [':BufferGoto 6' , 'buffer 6'],
  73. \ '7' : [':BufferGoto 7' , 'buffer 7'],
  74. \ '8' : [':BufferGoto 8' , 'buffer 8'],
  75. \ '9' : [':BufferGoto 9' , 'buffer 9'],
  76. \ '0' : [':BufferGoto 0' , 'buffer 0'],
  77. \ 'b' : [':BufferPick' , 'pick buffer'],
  78. \ 'd' : [':Bdelete' , 'delete-buffer'],
  79. \ 'D' : [':BufferOrderByDirectory', 'order by directory'],
  80. \ 'f' : ['bfirst' , 'first-buffer'],
  81. \ 'l' : ['blast' , 'last buffer'],
  82. \ 'L' : [':BufferOrderByLanguage' , 'order by language'],
  83. \ 'n' : ['bnext' , 'next-buffer'],
  84. \ 'p' : ['bprevious' , 'previous-buffer'],
  85. \ '?' : ['Buffers' , 'fzf-buffer'],
  86. \ }
  87. " d is for debug
  88. let g:which_key_map.d = {
  89. \ 'name' : '+debug' ,
  90. \ 'b' : ['<Plug>VimspectorToggleBreakpoint' , 'breakpoint'],
  91. \ 'B' : ['<Plug>VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'],
  92. \ 'c' : ['<Plug>VimspectorRunToCursor' , 'run to cursor'],
  93. \ 'd' : ['<Plug>VimspectorContinue' , 'continue'],
  94. \ 'f' : ['<Plug>VimspectorAddFunctionBreakpoint' , 'function breakpoint'],
  95. \ 'm' : [':MaximizerToggle' , 'maximize window'],
  96. \ 'o' : ['<Plug>VimspectorStepOver' , 'step over'],
  97. \ 'O' : ['<Plug>VimspectorStepOut' , 'step out'],
  98. \ 'i' : ['<Plug>VimspectorStepInto' , 'step into'],
  99. \ 'p' : ['<Plug>VimspectorPause' , 'pause'],
  100. \ 'r' : ['<Plug>VimspectorRestart' , 'restart'],
  101. \ 's' : ['<Plug>VimspectorStop' , 'stop'],
  102. \ }
  103. " f is for find and replace
  104. " \ 'f' : [':Farr' , 'file'],
  105. let g:which_key_map.f = {
  106. \ 'name' : '+find & replace' ,
  107. \ 'f' : [':Farr --source=vimgrep' , 'file'],
  108. \ 'p' : [':Farr --source=rgnvim' , 'project'],
  109. \ }
  110. " k is for task
  111. let g:which_key_map.k = {
  112. \ 'name' : '+task' ,
  113. \ 'c' : [':AsyncTask file-compile' , 'compile file'],
  114. \ 'b' : [':AsyncTask project-build' , 'build project'],
  115. \ 'e' : [':AsyncTaskEdit' , 'edit local tasks'],
  116. \ 'f' : [':AsyncTaskFzf' , 'find task'],
  117. \ 'g' : [':AsyncTaskEdit!' , 'edit global tasks'],
  118. \ 'h' : [':AsyncTaskList!' , 'list hidden tasks'],
  119. \ 'l' : [':CocList tasks' , 'list tasks'],
  120. \ 'm' : [':AsyncTaskMacro' , 'macro help'],
  121. \ 'o' : [':copen' , 'open task view'],
  122. \ 'r' : [':AsyncTask file-run' , 'run file'],
  123. \ 'p' : [':AsyncTask project-run' , 'run project'],
  124. \ 'x' : [':cclose' , 'close task view'],
  125. \ }
  126. " \ 'l' : [':AsyncTaskList' , 'list tasks'],
  127. " m is for mark
  128. let g:which_key_map.m = {
  129. \ 'name' : '+mark' ,
  130. \ 'c' : [':CocCommand bookmark.clearForCurrentFile', 'clear file'],
  131. \ 'C' : [':CocCommand bookmark.clearForAllFiles', 'clear project'],
  132. \ 'j' : [':CocCommand bookmark.next', 'next bookmark'],
  133. \ 'k' : [':CocCommand bookmark.prev', 'prev bookmark'],
  134. \ 't' : [':CocCommand bookmark.toggle', 'toggle bookmark'],
  135. \ }
  136. " CoC throws an error
  137. " \ 'a' : [':CocCommand bookmark.annotate', 'annotate bookmark'],
  138. " s is for search powered by telescope
  139. let g:which_key_map.s = {
  140. \ 'name' : '+search' ,
  141. \ '.' : [':Telescope filetypes' , 'filetypes'],
  142. \ ';' : [':Telescope commands' , 'commands'],
  143. \ 'a' : [':Telescope lsp_code_actions' , 'code_actions'],
  144. \ 'A' : [':Telescope builtin' , 'all'],
  145. \ 'b' : [':Telescope buffers' , 'buffers'],
  146. \ 'B' : [':Telescope git_branches' , 'git_branches'],
  147. \ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'],
  148. \ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'],
  149. \ 'c' : [':Telescope git_bcommits' , 'git_bcommits'],
  150. \ 'C' : [':Telescope git_bcommits' , 'git_bcommits'],
  151. \ 'f' : [':Telescope find_files' , 'files'],
  152. \ 'F' : [':Telescope git_files' , 'git_files'],
  153. \ 'g' : [':Telescope tags' , 'tags'],
  154. \ 'G' : [':Telescope current_buffer_tags' , 'buffer_tags'],
  155. \ 'h' : [':Telescope command_history' , 'history'],
  156. \ 'H' : [':Telescope help_tags' , 'help_tags'],
  157. \ 'k' : [':Telescope keymaps' , 'keymaps'],
  158. \ 'l' : [':Telescope loclist' , 'loclist'],
  159. \ 'm' : [':Telescope marks' , 'marks'],
  160. \ 'o' : [':Telescope vim_options' , 'vim_options'],
  161. \ 'O' : [':Telescope oldfiles' , 'oldfiles'],
  162. \ 'M' : [':Telescope man_pages' , 'man_pages'],
  163. \ 'p' : [':Telescope fd' , 'fd'],
  164. \ 'P' : [':Telescope spell_suggest' , 'spell_suggest'],
  165. \ 's' : [':Telescope git_status' , 'git_status'],
  166. \ 'S' : [':Telescope grep_string' , 'grep_string'],
  167. \ 't' : [':Telescope live_grep' , 'text'],
  168. \ 'y' : [':Telescope symbols' , 'symbols'],
  169. \ 'Y' : [':Telescope lsp_workspace_symbols' , 'lsp_workspace_symbols'],
  170. \ 'r' : [':Telescope registers' , 'registers'],
  171. \ 'R' : [':Telescope reloader' , 'reloader'],
  172. \ 'w' : [':Telescope file_browser' , 'buf_fuz_find'],
  173. \ 'u' : [':Telescope colorscheme' , 'colorschemes'],
  174. \ 'z' : [':Telescope current_buffer_fuzzy_find' , 'buf_fuz_find'],
  175. \ }
  176. let g:which_key_map.S = {
  177. \ 'name' : '+Session' ,
  178. \ 'c' : [':SClose' , 'Close Session'] ,
  179. \ 'd' : [':SDelete' , 'Delete Session'] ,
  180. \ 'l' : [':SLoad' , 'Load Session'] ,
  181. \ 's' : [':Startify' , 'Start Page'] ,
  182. \ 'S' : [':SSave' , 'Save Session'] ,
  183. \ }
  184. " g is for git
  185. let g:which_key_map.g = {
  186. \ 'name' : '+git' ,
  187. \ 'a' : [':Git add .' , 'add all'],
  188. \ 'A' : [':CocCommand fzf-preview.GitStatus' , 'actions'],
  189. \ 'b' : [':Git blame' , 'blame'],
  190. \ 'B' : [':GBrowse' , 'browse'],
  191. \ 'c' : [':Git commit' , 'commit'],
  192. \ 'd' : [':Git diff' , 'diff'],
  193. \ 'D' : [':Gdiffsplit' , 'diff split'],
  194. \ 'g' : [':GGrep' , 'git grep'],
  195. \ 'G' : [':Gstatus' , 'status'],
  196. \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  197. \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  198. \ 'i' : [':Gist -b' , 'post gist'],
  199. \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  200. \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  201. \ 'l' : [':Git log' , 'log'],
  202. \ 'm' : ['<Plug>(git-messenger)' , 'message'],
  203. \ 'p' : [':Git push' , 'push'],
  204. \ 'P' : [':Git pull' , 'pull'],
  205. \ 'r' : [':GRemove' , 'remove'],
  206. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  207. \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'],
  208. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  209. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  210. \ 'v' : [':GV' , 'view commits'],
  211. \ 'V' : [':GV!' , 'view buffer commits'],
  212. \ }
  213. " \ 'A' : [':Git add %' , 'add current'],
  214. " \ 'S' : [':!git status' , 'status'],
  215. "
  216. "
  217. "
  218. let g:which_key_map.G = {
  219. \ 'name' : '+gist' ,
  220. \ 'a' : [':Gist -a' , 'post gist anon'],
  221. \ 'b' : [':Gist -b' , 'post gist browser'],
  222. \ 'd' : [':Gist -d' , 'delete gist'],
  223. \ 'e' : [':Gist -e' , 'edit gist'],
  224. \ 'l' : [':Gist -l' , 'list public gists'],
  225. \ 's' : [':Gist -ls' , 'list starred gists'],
  226. \ 'm' : [':Gist -m' , 'post gist all buffers'],
  227. \ 'p' : [':Gist -P' , 'post public gist '],
  228. \ 'P' : [':Gist -p' , 'post private gist '],
  229. \ }
  230. " l is for language server protocol
  231. let g:which_key_map.l = {
  232. \ 'name' : '+lsp' ,
  233. \ 'a' : [':Lspsaga code_action' , 'code action'],
  234. \ 'A' : [':Lspsaga range_code_action' , 'selected action'],
  235. \ 'd' : [':LspDefinition' , 'definition'],
  236. \ 'D' : [':LspDeclaration' , 'workspace_diagnostics'],
  237. \ 'f' : [':LspFormatting' , 'format'],
  238. \ 'h' : [':Lspsaga hover_doc' , 'hover_doc'],
  239. \ 'H' : [':Lspsaga signature_help' , 'signature_help'],
  240. \ 'K' : [':LspHover' , 'hover'],
  241. \ 'i' : [':LspImplementation' , 'lsp_info'],
  242. \ 'I' : [':LspInfo' , 'lsp_info'],
  243. \ 'l' : [':Lspsaga lsp_finder' , 'lsp_finder'],
  244. \ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'],
  245. \ 'n' : [':Lspsaga diagnostic_jump_next' , 'next_diagnostic'],
  246. \ 'o' : [':Vista!!' , 'outline'],
  247. \ 'p' : [':Lspsaga diagnostic_jump_prev' , 'prev diagnostic'],
  248. \ 'q' : [':Lspsaga code_action' , 'quickfix'],
  249. \ 'r' : [':LspReferences' , 'references'],
  250. \ 'R' : [':LspRename' , 'rename'],
  251. \ 'T' : [':LspTypeDefinition' , 'type defintion'],
  252. \ 'x' : [':cclose' , 'close quickfix'],
  253. \ 'y' : [':LspDocumentSymbol' , 'document symbols'],
  254. \ 'Y' : [':LspWorkspaceSymbol' , 'workspace symbols'],
  255. \ }
  256. " t is for terminal
  257. let g:which_key_map.t = {
  258. \ 'name' : '+terminal' ,
  259. \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'],
  260. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  261. \ 'g' : [':FloatermNew lazygit' , 'git'],
  262. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  263. \ 'n' : [':FloatermNew node' , 'node'],
  264. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  265. \ 'p' : [':FloatermNew python' , 'python'],
  266. \ 'm' : [':FloatermNew lazynpm' , 'npm'],
  267. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  268. \ 't' : [':FloatermToggle' , 'toggle'],
  269. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  270. \ 'u' : [':FloatermNew ncdu' , 'ncdu'],
  271. \ }
  272. " w is for wiki
  273. " let g:which_key_map.w = {
  274. " \ 'name' : '+wiki' ,
  275. " \ 'w' : ['<Plug>VimwikiIndex' , 'ncdu'],
  276. " \ 'n' : ['<plug>(wiki-open)' , 'ncdu'],
  277. " \ 'j' : ['<plug>(wiki-journal)' , 'ncdu'],
  278. " \ 'R' : ['<plug>(wiki-reload)' , 'ncdu'],
  279. " \ 'c' : ['<plug>(wiki-code-run)' , 'ncdu'],
  280. " \ 'b' : ['<plug>(wiki-graph-find-backlinks)' , 'ncdu'],
  281. " \ 'g' : ['<plug>(wiki-graph-in)' , 'ncdu'],
  282. " \ 'G' : ['<plug>(wiki-graph-out)' , 'ncdu'],
  283. " \ 'l' : ['<plug>(wiki-link-toggle)' , 'ncdu'],
  284. " \ 'd' : ['<plug>(wiki-page-delete)' , 'ncdu'],
  285. " \ 'r' : ['<plug>(wiki-page-rename)' , 'ncdu'],
  286. " \ 't' : ['<plug>(wiki-page-toc)' , 'ncdu'],
  287. " \ 'T' : ['<plug>(wiki-page-toc-local)' , 'ncdu'],
  288. " \ 'e' : ['<plug>(wiki-export)' , 'ncdu'],
  289. " \ 'u' : ['<plug>(wiki-list-uniq)' , 'ncdu'],
  290. " \ 'U' : ['<plug>(wiki-list-uniq-local)' , 'ncdu'],
  291. " \ }
  292. " Global
  293. " <Plug>VimwikiIndex
  294. " <Plug>VimwikiTabIndex
  295. " <Plug>VimwikiUISelect
  296. " <Plug>VimwikiDiaryIndex
  297. " <Plug>VimwikiMakeDiaryNote
  298. " <Plug>VimwikiTabMakeDiaryNote
  299. " <Plug>VimwikiMakeYesterdayDiaryNote
  300. " <Plug>VimwikiMakeTomorrowDiaryNote
  301. "
  302. " " Local
  303. " <Plug>Vimwiki2HTML
  304. " <Plug>Vimwiki2HTMLBrowse
  305. " <Plug>VimwikiDiaryGenerateLinks
  306. " <Plug>VimwikiFollowLink
  307. " <Plug>VimwikiSplitLink
  308. " <Plug>VimwikiVSplitLink
  309. " <Plug>VimwikiTabnewLink
  310. " <Plug>VimwikiGoBackLink
  311. " <Plug>VimwikiNextLink
  312. " <Plug>VimwikiPrevLink
  313. " <Plug>VimwikiGoto
  314. " <Plug>VimwikiDeleteLink
  315. " <Plug>VimwikiRenameLink
  316. " <Plug>VimwikiAddHeaderLevel
  317. " Register which key map
  318. call which_key#register('<Space>', "g:which_key_map")