init.vim 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. " Leader Key Maps
  2. " Timeout
  3. let g:which_key_timeout = 100
  4. let g:which_key_display_names = {'<CR>': '↵', '<TAB>': '⇆'}
  5. " Map leader to which_key
  6. nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
  7. vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
  8. let g:which_key_map = {}
  9. let g:which_key_sep = '→'
  10. " Not a fan of floating windows for this
  11. let g:which_key_use_floating_win = 0
  12. let g:which_key_max_size = 0
  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. " Single mappings
  18. " let g:which_key_map['/'] = [ ':call Comment()' , 'comment' ]
  19. " let g:which_key_map['/'] = { 'name' : 'comment' }
  20. let g:which_key_map['/'] = 'which_key_ignore'
  21. let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'find current file' ]
  22. let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ]
  23. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  24. let g:which_key_map['n'] = [ ':let @/ = ""' , 'no highlight' ]
  25. let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ]
  26. let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ]
  27. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  28. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  29. " Group mappings
  30. " a is for actions
  31. let g:which_key_map.a = {
  32. \ 'name' : '+actions' ,
  33. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  34. \ 'e' : [':CocCommand explorer' , 'explorer'],
  35. \ 'h' : [':let @/ = ""' , 'remove search highlight'],
  36. \ 'l' : [':Bracey' , 'start live server'],
  37. \ 'L' : [':BraceyStop' , 'stop live server'],
  38. \ 'm' : [':MarkdownPreview' , 'markdown preview'],
  39. \ 'M' : [':MarkdownPreviewStop' , 'markdown preview stop'],
  40. \ 'n' : [':set nonumber!' , 'line-numbers'],
  41. \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'],
  42. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  43. \ 't' : [':FloatermToggle' , 'terminal'],
  44. \ 'v' : [':Codi' , 'virtual repl on'],
  45. \ 'V' : [':Codi!' , 'virtual repl off'],
  46. \ 'w' : [':StripWhitespace' , 'strip whitespace'],
  47. \ }
  48. " b is for buffer
  49. " let g:which_key_map.b = {
  50. " \ 'name' : '+buffer' ,
  51. " \ '>' : [':BufferMoveNext' , 'move next'],
  52. " \ '<' : [':BufferMovePrevious' , 'move prev'],
  53. " \ 'b' : [':BufferPick' , 'pick buffer'],
  54. " \ 'd' : [':Bdelete' , 'delete-buffer'],
  55. " \ 'n' : ['bnext' , 'next-buffer'],
  56. " \ 'p' : ['bprevious' , 'previous-buffer'],
  57. " \ '?' : ['Buffers' , 'fzf-buffer'],
  58. " \ }
  59. " d is for debug
  60. " let g:which_key_map.d = {
  61. " \ 'name' : '+debug' ,
  62. " \ 'b' : ['<Plug>VimspectorToggleBreakpoint' , 'breakpoint'],
  63. " \ 'B' : ['<Plug>VimspectorToggleConditionalBreakpoint' , 'conditional breakpoint'],
  64. " \ 'c' : ['<Plug>VimspectorRunToCursor' , 'run to cursor'],
  65. " \ 'd' : ['<Plug>VimspectorContinue' , 'continue'],
  66. " \ 'f' : ['<Plug>VimspectorAddFunctionBreakpoint' , 'function breakpoint'],
  67. " \ 'm' : [':MaximizerToggle' , 'maximize window'],
  68. " \ 'o' : ['<Plug>VimspectorStepOver' , 'step over'],
  69. " \ 'O' : ['<Plug>VimspectorStepOut' , 'step out'],
  70. " \ 'i' : ['<Plug>VimspectorStepInto' , 'step into'],
  71. " \ 'p' : ['<Plug>VimspectorPause' , 'pause'],
  72. " \ 'r' : ['<Plug>VimspectorRestart' , 'restart'],
  73. " \ 's' : ['<Plug>VimspectorStop' , 'stop'],
  74. " \ }
  75. " F is for fold
  76. let g:which_key_map.F = {
  77. \ 'name': '+fold',
  78. \ 'O' : [':set foldlevel=20', 'open all'],
  79. \ 'C' : [':set foldlevel=0', 'close all'],
  80. \ 'c' : [':foldclose', 'close'],
  81. \ 'o' : [':foldopen', 'open'],
  82. \ '1' : [':set foldlevel=1', 'level1'],
  83. \ '2' : [':set foldlevel=2', 'level2'],
  84. \ '3' : [':set foldlevel=3', 'level3'],
  85. \ '4' : [':set foldlevel=4', 'level4'],
  86. \ '5' : [':set foldlevel=5', 'level5'],
  87. \ '6' : [':set foldlevel=6', 'level6']
  88. \ }
  89. " s is for search powered by telescope
  90. let g:which_key_map.s = {
  91. \ 'name' : '+search' ,
  92. \ '.' : [':Telescope filetypes' , 'filetypes'],
  93. \ ';' : [':Telescope commands' , 'commands'],
  94. \ 'a' : [':Telescope lsp_code_actions' , 'code_actions'],
  95. \ 'A' : [':Telescope builtin' , 'all'],
  96. \ 'b' : [':Telescope buffers' , 'buffers'],
  97. \ 'B' : [':Telescope git_branches' , 'git branches'],
  98. \ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'],
  99. \ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'],
  100. \ 'c' : [':Telescope git_commits' , 'git_commits'],
  101. \ 'C' : [':Telescope git_bcommits' , 'git_bcommits'],
  102. \ 'f' : [':Telescope find_files' , 'files'],
  103. \ 'F' : [':Telescope git_files' , 'git_files'],
  104. \ 'g' : [':Telescope tags' , 'tags'],
  105. \ 'G' : [':Telescope current_buffer_tags' , 'buffer_tags'],
  106. \ 'h' : [':Telescope command_history' , 'history'],
  107. \ 'H' : [':Telescope help_tags' , 'help_tags'],
  108. \ 'i' : [':Telescope media_files' , 'media files'],
  109. \ 'k' : [':Telescope keymaps' , 'keymaps'],
  110. \ 'l' : [':Telescope loclist' , 'loclist'],
  111. \ 'm' : [':Telescope marks' , 'marks'],
  112. \ 'M' : [':Telescope man_pages' , 'man_pages'],
  113. \ 'o' : [':Telescope vim_options' , 'vim_options'],
  114. \ 'O' : [':Telescope oldfiles' , 'oldfiles'],
  115. \ 'p' : [':Telescope fd' , 'fd'],
  116. \ 'P' : [':Telescope spell_suggest' , 'spell_suggest'],
  117. \ 's' : [':Telescope git_status' , 'git_status'],
  118. \ 'S' : [':Telescope grep_string' , 'grep_string'],
  119. \ 't' : [':Telescope live_grep' , 'text'],
  120. \ 'y' : [':Telescope symbols' , 'symbols'],
  121. \ 'Y' : [':Telescope lsp_workspace_symbols' , 'lsp_workspace_symbols'],
  122. \ 'r' : [':Telescope registers' , 'registers'],
  123. \ 'R' : [':Telescope reloader' , 'reloader'],
  124. \ 'w' : [':Telescope file_browser' , 'buf_fuz_find'],
  125. \ 'u' : [':Telescope colorscheme' , 'colorschemes'],
  126. \ 'z' : [':Telescope current_buffer_fuzzy_find' , 'buf_fuz_find'],
  127. \ }
  128. let g:which_key_map.S = {
  129. \ 'name' : '+Session' ,
  130. \ 'c' : [':SClose' , 'Close Session'] ,
  131. \ 'd' : [':SDelete' , 'Delete Session'] ,
  132. \ 'l' : [':SLoad' , 'Load Session'] ,
  133. \ 's' : [':Startify' , 'Start Page'] ,
  134. \ 'S' : [':SSave' , 'Save Session'] ,
  135. \ }
  136. " g is for git
  137. " let g:which_key_map.g = {
  138. " \ 'name' : '+git' ,
  139. " \ 'a' : [':Git add .' , 'add all'],
  140. " \ 'A' : [':CocCommand fzf-preview.GitStatus' , 'actions'],
  141. " \ 'b' : [':Git blame' , 'blame'],
  142. " \ 'B' : [':GBrowse' , 'browse'],
  143. " \ 'c' : [':Git commit' , 'commit'],
  144. " \ 'd' : [':Git diff' , 'diff'],
  145. " \ 'D' : [':Gdiffsplit' , 'diff split'],
  146. " \ 'g' : [':GGrep' , 'git grep'],
  147. " \ 'G' : [':Gstatus' , 'status'],
  148. " \ 'h' : [':GitGutterLineHighlightsToggle' , 'highlight hunks'],
  149. " \ 'H' : ['<Plug>(GitGutterPreviewHunk)' , 'preview hunk'],
  150. " \ 'i' : [':Gist -b' , 'post gist'],
  151. " \ 'j' : ['<Plug>(GitGutterNextHunk)' , 'next hunk'],
  152. " \ 'k' : ['<Plug>(GitGutterPrevHunk)' , 'prev hunk'],
  153. " \ 'l' : [':Git log' , 'log'],
  154. " \ 'm' : ['<Plug>(git-messenger)' , 'message'],
  155. " \ 'p' : [':Git push' , 'push'],
  156. " \ 'P' : [':Git pull' , 'pull'],
  157. " \ 'r' : [':GRemove' , 'remove'],
  158. " \ 's' : ['<Plug>(GitGutterStageHunk)' , 'stage hunk'],
  159. " \ 'S' : [':CocCommand fzf-preview.GitStatus' , 'status'],
  160. " \ 't' : [':GitGutterSignsToggle' , 'toggle signs'],
  161. " \ 'u' : ['<Plug>(GitGutterUndoHunk)' , 'undo hunk'],
  162. " \ 'v' : [':GV' , 'view commits'],
  163. " \ 'V' : [':GV!' , 'view buffer commits'],
  164. " \ }
  165. " \ 'A' : [':Git add %' , 'add current'],
  166. " \ 'S' : [':!git status' , 'status'],
  167. " let g:which_key_map.G = {
  168. " \ 'name' : '+gist' ,
  169. " \ 'a' : [':Gist -a' , 'post gist anon'],
  170. " \ 'b' : [':Gist -b' , 'post gist browser'],
  171. " \ 'd' : [':Gist -d' , 'delete gist'],
  172. " \ 'e' : [':Gist -e' , 'edit gist'],
  173. " \ 'l' : [':Gist -l' , 'list public gists'],
  174. " \ 's' : [':Gist -ls' , 'list starred gists'],
  175. " \ 'm' : [':Gist -m' , 'post gist all buffers'],
  176. " \ 'p' : [':Gist -P' , 'post public gist '],
  177. " \ 'P' : [':Gist -p' , 'post private gist '],
  178. " \ }
  179. " l is for language server protocol
  180. let g:which_key_map.l = {
  181. \ 'name' : '+lsp' ,
  182. \ 'a' : [':Lspsaga code_action' , 'quickfix'],
  183. \ 'A' : [':Lspsaga range_code_action' , 'selected action'],
  184. \ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'],
  185. \ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'],
  186. \ 'f' : [':LspFormatting' , 'format'],
  187. \ 'H' : [':Lspsaga signature_help' , 'signature_help'],
  188. \ 'I' : [':LspInfo' , 'lsp_info'],
  189. \ 'l' : [':Lspsaga lsp_finder' , 'lsp_finder'],
  190. \ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'],
  191. \ 'o' : [':Vista!!' , 'outline'],
  192. \ 'p' : [':Lspsaga preview_definition' , 'preview definition'],
  193. \ 'q' : [':Telescope quickfix' , 'quickfix'],
  194. \ 'r' : [':LspRename' , 'rename'],
  195. \ 'T' : [':LspTypeDefinition' , 'type defintion'],
  196. \ 'x' : [':cclose' , 'close quickfix'],
  197. \ 's' : [':Telescope lsp_document_symbols' , 'document symbols'],
  198. \ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'],
  199. \ }
  200. " t is for terminal
  201. let g:which_key_map.t = {
  202. \ 'name' : '+terminal' ,
  203. \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'],
  204. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  205. \ 'g' : [':FloatermNew lazygit' , 'git'],
  206. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  207. \ 'n' : [':FloatermNew node' , 'node'],
  208. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  209. \ 'p' : [':FloatermNew python' , 'python'],
  210. \ 'm' : [':FloatermNew lazynpm' , 'npm'],
  211. \ 'r' : [':FloatermNew ranger' , 'ranger'],
  212. \ 't' : [':FloatermToggle' , 'toggle'],
  213. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  214. \ 'u' : [':FloatermNew ncdu' , 'ncdu'],
  215. \ }
  216. call which_key#register('<Space>', "g:which_key_map")