which-key.vim 7.0 KB

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