which-key.vim 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. let g:which_key_map = {}
  2. let g:which_key_sep = '→'
  3. " set timeoutlen=100
  4. nnoremap <silent> <leader> :silent WhichKey '<Space>'<CR>
  5. vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
  6. " Not a fan of floating windows for this
  7. let g:which_key_use_floating_win = 0
  8. " Change the colors if you want
  9. highlight default link WhichKey Operator
  10. highlight default link WhichKeySeperator DiffAdded
  11. highlight default link WhichKeyGroup Identifier
  12. highlight default link WhichKeyDesc Function
  13. " Hide status line
  14. autocmd! FileType which_key
  15. autocmd FileType which_key set laststatus=0 noshowmode noruler
  16. \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
  17. " change to nerd commenter
  18. let g:which_key_map['/'] = [ '<Plug>NERDCommenterToggle' , 'commenter' ]
  19. let g:which_key_map['.'] = [ ':CocConfig' , 'CoC config' ]
  20. let g:which_key_map[';'] = [ ':Commands' , 'commands' ]
  21. let g:which_key_map['d'] = [ ':bd' , 'delete buffer']
  22. let g:which_key_map['e'] = [ ':CocCommand explorer' , 'explorer' ]
  23. let g:which_key_map['f'] = [ ':Files' , 'files' ]
  24. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  25. let g:which_key_map['q'] = [ 'q' , 'quit' ]
  26. let g:which_key_map['r'] = [ ':Ranger' , 'ranger' ]
  27. let g:which_key_map['S'] = [ ':Startify' , 'start screen' ]
  28. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  29. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  30. " f is for find
  31. let g:which_key_map.f = {
  32. \ 'name' : '+find' ,
  33. \ '/' : [':History/' , 'history'],
  34. \ ';' : [':Commands' , 'commands'],
  35. \ 'a' : [':Ag' , 'text Ag'],
  36. \ 'b' : [':BLines' , 'current buffer'],
  37. \ 'B' : [':Buffers' , 'open buffers'],
  38. \ 'c' : [':Commits' , 'commits'],
  39. \ 'C' : [':BCommits' , 'buffer commits'],
  40. \ 'f' : [':Files' , 'files'],
  41. \ 'g' : [':GFiles' , 'git files'],
  42. \ 'G' : [':GFiles?' , 'modified git files'],
  43. \ 'h' : [':History' , 'file history'],
  44. \ 'H' : [':History:' , 'command history'],
  45. \ 'l' : [':Lines' , 'lines'] ,
  46. \ 'm' : [':Marks' , 'marks'] ,
  47. \ 'M' : [':Maps' , 'normal maps'] ,
  48. \ 'p' : [':Helptags' , 'help tags'] ,
  49. \ 'r' : [':Rg' , 'text Rg'],
  50. \ 's' : [':Snippets' , 'snippets'],
  51. \ 'S' : [':Colors' , 'color schemes'],
  52. \ 't' : [':Tags' , 'project tags'],
  53. \ 'T' : [':BTags' , 'buffer tags'],
  54. \ 'w' : [':Windows' , 'search windows'],
  55. \ 'y' : [':Filetypes' , 'file types'],
  56. \ 'z' : [':FZF' , 'FZF'],
  57. \ }
  58. " g is for git
  59. let g:which_key_map.g = {
  60. \ 'name' : '+git' ,
  61. \ 'a' : [':Git add .' , 'add all'],
  62. \ 'A' : [':Git add %' , 'add current'],
  63. \ 'b' : [':Git blame' , 'blame'],
  64. \ 'B' : [':GBrowse' , 'browse'],
  65. \ 'c' : [':Git commit -m "autocommit"' , 'commit'],
  66. \ 'd' : [':Git diff' , 'diff'],
  67. \ 'D' : [':Gdiffsplit' , 'diff split'],
  68. \ 'g' : [':GGrep' , 'git grep'],
  69. \ 'G' : [':Gstatus' , 'status'],
  70. \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  71. \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  72. \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  73. \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  74. \ 'l' : [':Git log' , 'log'],
  75. \ 'p' : [':Git push' , 'push'],
  76. \ 'P' : [':Git pull' , 'pull'],
  77. \ 'r' : [':GRemove' , 'remove'],
  78. \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  79. \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  80. \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  81. \ 'v' : [':GV' , 'view commits'],
  82. \ 'V' : [':GV!' , 'view buffer commits'],
  83. \ }
  84. " l is for language server protocol
  85. let g:which_key_map.l = {
  86. \ 'name' : '+lsp' ,
  87. \ '.' : [':CocConfig' , 'config'],
  88. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  89. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  90. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  91. \ 'b' : [':CocNext' , 'next action'],
  92. \ 'B' : [':CocPrev' , 'prev action'],
  93. \ 'c' : [':CocList commands' , 'commands'],
  94. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  95. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  96. \ 'e' : [':CocList extensions' , 'extensions'],
  97. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  98. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  99. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  100. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  101. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  102. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  103. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  104. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  105. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  106. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  107. \ 'O' : [':CocList outline' , 'outline'],
  108. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  109. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  110. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  111. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  112. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  113. \ 's' : [':CocList -I symbols' , 'references'],
  114. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  115. \ 'u' : [':CocListResume' , 'resume list'],
  116. \ 'U' : [':CocUpdate' , 'update CoC'],
  117. \ 'v' : [':Vista!!' , 'tag viewer'],
  118. \ 'z' : [':CocDisable' , 'disable CoC'],
  119. \ 'Z' : [':CocEnable' , 'enable CoC'],
  120. \ }
  121. " t is for toggle
  122. let g:which_key_map.t = {
  123. \ 'name' : '+toggle' ,
  124. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  125. \ 'e' : [':CocCommand explorer' , 'explorer'],
  126. \ 'n' : [':set nonumber!' , 'line-numbers'],
  127. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  128. \ 's' : [':let @/ = ""' , 'remove search highlight'],
  129. \ 't' : [':FloatermToggle' , 'terminal'],
  130. \ 'v' : [':Vista!!' , 'tag viewer'],
  131. \ }
  132. call which_key#register('<Space>', "g:which_key_map")