which-key.vim 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. " map leader to which_key
  2. " call which_key#register('<Space>', "g:which_key_map")
  3. nnoremap <silent> <leader> :silent WhichKey ' '<CR>
  4. vnoremap <silent> <leader> :silent WhichKeyVisual ' '<CR>
  5. let g:which_key_map = {}
  6. let g:which_key_sep = '→'
  7. " set timeoutlen=100
  8. " Not a fan of floating windows for this
  9. let g:which_key_use_floating_win = 0
  10. " Change the colors if you want
  11. highlight default link WhichKey Operator
  12. highlight default link WhichKeySeperator DiffAdded
  13. highlight default link WhichKeyGroup Identifier
  14. highlight default link WhichKeyDesc Function
  15. " Hide status line
  16. autocmd! FileType which_key
  17. autocmd FileType which_key set laststatus=0 noshowmode noruler
  18. \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
  19. " f is for find
  20. let g:which_key_map.f = {
  21. \ 'name' : '+find' ,
  22. \ '/' : [':History/' , 'history'],
  23. \ ';' : [':Commands' , 'commands'],
  24. \ 'a' : [':Ag' , 'text Ag'],
  25. \ 'b' : [':BLines' , 'current buffer'],
  26. \ 'B' : [':Buffers' , 'open buffers'],
  27. \ 'c' : [':Commits' , 'commits'],
  28. \ 'C' : [':BCommits' , 'buffer commits'],
  29. \ 'f' : [':Files' , 'files'],
  30. \ 'g' : [':GFiles' , 'git files'],
  31. \ 'G' : [':GFiles?' , 'modified git files'],
  32. \ 'h' : [':History' , 'file history'],
  33. \ 'H' : [':History:' , 'command history'],
  34. \ 'l' : [':Lines' , 'lines'] ,
  35. \ 'm' : [':Marks' , 'marks'] ,
  36. \ 'M' : [':Maps' , 'normal maps'] ,
  37. \ 'p' : [':Helptags' , 'help tags'] ,
  38. \ 'r' : [':Rg' , 'text Rg'],
  39. \ 's' : [':Snippets' , 'snippets'],
  40. \ 'S' : [':Colors' , 'color schemes'],
  41. \ 't' : [':Tags' , 'project tags'],
  42. \ 'T' : [':BTags' , 'buffer tags'],
  43. \ 'w' : [':Windows' , 'search windows'],
  44. \ 'y' : [':Filetypes' , 'file types'],
  45. \ 'z' : [':FZF' , 'FZF'],
  46. \ }
  47. let g:fzf_buffers_jump = 1
  48. " l is for language server protocol
  49. let g:which_key_map.l = {
  50. \ 'name' : '+lsp' ,
  51. \ '.' : [':CocConfig' , 'config'],
  52. \ ';' : ['<Plug>(coc-refactor)' , 'refactor'],
  53. \ 'a' : ['<Plug>(coc-codeaction)' , 'line action'],
  54. \ 'A' : ['<Plug>(coc-codeaction-selected)' , 'selected action'],
  55. \ 'b' : [':CocNext' , 'next action'],
  56. \ 'B' : [':CocPrev' , 'prev action'],
  57. \ 'c' : [':CocList commands' , 'commands'],
  58. \ 'd' : ['<Plug>(coc-definition)' , 'definition'],
  59. \ 'D' : ['<Plug>(coc-declaration)' , 'declaration'],
  60. \ 'e' : [':CocList extensions' , 'extensions'],
  61. \ 'f' : ['<Plug>(coc-format-selected)' , 'format selected'],
  62. \ 'F' : ['<Plug>(coc-format)' , 'format'],
  63. \ 'h' : ['<Plug>(coc-float-hide)' , 'hide'],
  64. \ 'i' : ['<Plug>(coc-implementation)' , 'implementation'],
  65. \ 'I' : [':CocList diagnostics' , 'diagnostics'],
  66. \ 'j' : ['<Plug>(coc-float-jump)' , 'float jump'],
  67. \ 'l' : ['<Plug>(coc-codelens-action)' , 'code lens'],
  68. \ 'n' : ['<Plug>(coc-diagnostic-next)' , 'next diagnostic'],
  69. \ 'N' : ['<Plug>(coc-diagnostic-next-error)' , 'next error'],
  70. \ 'o' : ['<Plug>(coc-openlink)' , 'open link'],
  71. \ 'O' : [':CocList outline' , 'outline'],
  72. \ 'p' : ['<Plug>(coc-diagnostic-prev)' , 'prev diagnostic'],
  73. \ 'P' : ['<Plug>(coc-diagnostic-prev-error)' , 'prev error'],
  74. \ 'q' : ['<Plug>(coc-fix-current)' , 'quickfix'],
  75. \ 'r' : ['<Plug>(coc-rename)' , 'rename'],
  76. \ 'R' : ['<Plug>(coc-references)' , 'references'],
  77. \ 's' : [':CocList -I symbols' , 'references'],
  78. \ 't' : ['<Plug>(coc-type-definition)' , 'type definition'],
  79. \ 'u' : [':CocListResume' , 'resume list'],
  80. \ 'U' : [':CocUpdate' , 'update CoC'],
  81. \ 'z' : [':CocDisable' , 'disable CoC'],
  82. \ 'Z' : [':CocEnable' , 'enable CoC'],
  83. \ }
  84. " t is for toggle
  85. let g:which_key_map.t = {
  86. \ 'name' : '+toggle' ,
  87. \ 'e' : [':CocCommand explorer' , 'explorer'],
  88. \ 'n' : [':set nonumber!' , 'line-numbers'],
  89. \ 'r' : [':set norelativenumber!' , 'rel-line-numbers'],
  90. \ 's' : [':let @/ = ""' , 'remove-search-highlight'],
  91. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  92. \ 't' : [':FloatermToggle' , 'terminal'],
  93. \ }
  94. call which_key#register('<Space>', "g:which_key_map")