init.vim 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. " " delete without yanking
  18. " nnoremap <leader>d "_d
  19. " vnoremap <leader>d "_d
  20. "
  21. " " replace currently selected text with default register
  22. " " without yanking it
  23. " vnoremap <leader>p "_dP
  24. " vnoremap <leader>p "_dP
  25. map <leader>p <Plug>(miniyank-startput)
  26. map <leader>P <Plug>(miniyank-startPut)
  27. " Single mappings
  28. let g:which_key_map['/'] = 'which_key_ignore'
  29. let g:which_key_map['p'] = 'which_key_ignore'
  30. let g:which_key_map['P'] = 'which_key_ignore'
  31. let g:which_key_map['n'] = 'which_key_ignore'
  32. let g:which_key_map['N'] = 'which_key_ignore'
  33. let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'find current file' ]
  34. let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ]
  35. let g:which_key_map['f'] = [ ':Telescope find_files' , 'find files' ]
  36. let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
  37. let g:which_key_map['m'] = [ ':MarkdownPreviewToggle' , 'markdown preview']
  38. let g:which_key_map['h'] = [ ':let @/ = ""' , 'no highlight' ]
  39. let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ]
  40. " let g:which_key_map['p'] = [ '"0p' , 'paste' ]
  41. " TODO create entire treesitter section
  42. let g:which_key_map['T'] = [ ':TSHighlightCapturesUnderCursor' , 'treesitter highlight' ]
  43. let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
  44. " Add Zen mode, play nice with status line
  45. let g:which_key_map['z'] = [ 'Goyo' , 'zen' ]
  46. " Group mappings
  47. " a is for actions
  48. let g:which_key_map.a = {
  49. \ 'name' : '+actions' ,
  50. \ 'c' : [':ColorizerToggle' , 'colorizer'],
  51. \ 'h' : [':let @/ = ""' , 'remove search highlight'],
  52. \ 'l' : [':Bracey' , 'start live server'],
  53. \ 'L' : [':BraceyStop' , 'stop live server'],
  54. \ 'n' : [':set nonumber!' , 'line-numbers'],
  55. \ 's' : [':s/\%V\(.*\)\%V/"\1"/' , 'surround'],
  56. \ 'r' : [':set norelativenumber!' , 'relative line nums'],
  57. \ 'v' : [':Codi' , 'virtual repl on'],
  58. \ 'V' : [':Codi!' , 'virtual repl off'],
  59. \ }
  60. " b is for buffer
  61. let g:which_key_map.b = {
  62. \ 'name' : '+buffer' ,
  63. \ '>' : [':BufferMoveNext' , 'move next'],
  64. \ '<' : [':BufferMovePrevious' , 'move prev'],
  65. \ 'b' : [':BufferPick' , 'pick buffer'],
  66. \ 'd' : [':Bdelete' , 'delete-buffer'],
  67. \ 'n' : ['bnext' , 'next-buffer'],
  68. \ 'p' : ['bprevious' , 'previous-buffer'],
  69. \ '?' : ['Buffers' , 'fzf-buffer'],
  70. \ }
  71. " F is for fold
  72. let g:which_key_map.F = {
  73. \ 'name': '+fold',
  74. \ 'O' : [':set foldlevel=20', 'open all'],
  75. \ 'C' : [':set foldlevel=0', 'close all'],
  76. \ 'c' : [':foldclose', 'close'],
  77. \ 'o' : [':foldopen', 'open'],
  78. \ '1' : [':set foldlevel=1', 'level1'],
  79. \ '2' : [':set foldlevel=2', 'level2'],
  80. \ '3' : [':set foldlevel=3', 'level3'],
  81. \ '4' : [':set foldlevel=4', 'level4'],
  82. \ '5' : [':set foldlevel=5', 'level5'],
  83. \ '6' : [':set foldlevel=6', 'level6']
  84. \ }
  85. " s is for search powered by telescope
  86. let g:which_key_map.s = {
  87. \ 'name' : '+search' ,
  88. \ '.' : [':Telescope filetypes' , 'filetypes'],
  89. \ 'B' : [':Telescope git_branches' , 'git branches'],
  90. \ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'],
  91. \ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'],
  92. \ 'f' : [':Telescope find_files' , 'files'],
  93. \ 'h' : [':Telescope command_history' , 'history'],
  94. \ 'i' : [':Telescope media_files' , 'media files'],
  95. \ 'm' : [':Telescope marks' , 'marks'],
  96. \ 'M' : [':Telescope man_pages' , 'man_pages'],
  97. \ 'o' : [':Telescope vim_options' , 'vim_options'],
  98. \ 't' : [':Telescope live_grep' , 'text'],
  99. \ 'r' : [':Telescope registers' , 'registers'],
  100. \ 'w' : [':Telescope file_browser' , 'buf_fuz_find'],
  101. \ 'u' : [':Telescope colorscheme' , 'colorschemes'],
  102. \ }
  103. " \ 'A' : [':Telescope builtin' , 'all'],
  104. " \ 's' : [':Telescope git_status' , 'git_status'],
  105. " \ 'b' : [':Telescope buffers' , 'buffers'],
  106. " \ ';' : [':Telescope commands' , 'commands'],
  107. " \ 'a' : [':Telescope lsp_code_actions' , 'code_actions'],
  108. " \ 'c' : [':Telescope git_commits' , 'git_commits'],
  109. " \ 'C' : [':Telescope git_bcommits' , 'git_bcommits'],
  110. " \ 'g' : [':Telescope tags' , 'tags'],
  111. " \ 'F' : [':Telescope git_files' , 'git_files'],
  112. " \ 'G' : [':Telescope current_buffer_tags' , 'buffer_tags'],
  113. " \ 'k' : [':Telescope keymaps' , 'keymaps'],
  114. " \ 'H' : [':Telescope help_tags' , 'help_tags'],
  115. " \ 'l' : [':Telescope loclist' , 'loclist'],
  116. " \ 'O' : [':Telescope oldfiles' , 'oldfiles'],
  117. " \ 'p' : [':Telescope fd' , 'fd'],
  118. " \ 'S' : [':Telescope grep_string' , 'grep_string'],
  119. " \ 'y' : [':Telescope symbols' , 'symbols'],
  120. " \ 'Y' : [':Telescope lsp_workspace_symbols' , 'lsp_workspace_symbols'],
  121. " \ 'R' : [':Telescope reloader' , 'reloader'],
  122. " \ 'z' : [':Telescope current_buffer_fuzzy_find' , 'buf_fuz_find'],
  123. " \ 'P' : [':Telescope spell_suggest' , 'spell_suggest'],
  124. let g:which_key_map.S = {
  125. \ 'name' : '+Session' ,
  126. \ 'c' : [':SClose' , 'Close Session'] ,
  127. \ 'd' : [':SDelete' , 'Delete Session'] ,
  128. \ 'l' : [':SLoad' , 'Load Session'] ,
  129. \ 's' : [':Startify' , 'Start Page'] ,
  130. \ 'S' : [':SSave' , 'Save Session'] ,
  131. \ }
  132. " g is for git
  133. let g:which_key_map.g = {
  134. \ 'name' : '+git' ,
  135. \ 'b' : [':GitBlameToggle' , 'blame'],
  136. \ 'B' : [':GBrowse' , 'browse'],
  137. \ 'd' : [':Git diff' , 'diff'],
  138. \ 'j' : [':NextHunk' , 'next hunk'],
  139. \ 'k' : [':PrevHunk' , 'prev hunk'],
  140. \ 'l' : [':Git log' , 'log'],
  141. \ 'n' : [':Neogit' , 'neogit'],
  142. \ 'p' : [':PreviewHunk' , 'preview hunk'],
  143. \ 'r' : [':ResetHunk' , 'reset hunk'],
  144. \ 'R' : [':ResetBuffer' , 'reset buffer'],
  145. \ 's' : [':StageHunk' , 'stage hunk'],
  146. \ 'S' : [':Gstatus' , 'status'],
  147. \ 'u' : [':UndoStageHunk' , 'undo stage hunk'],
  148. \ }
  149. " G is for gist
  150. let g:which_key_map.G = {
  151. \ 'name' : '+gist' ,
  152. \ 'b' : [':Gist -b' , 'post gist browser'],
  153. \ 'd' : [':Gist -d' , 'delete gist'],
  154. \ 'e' : [':Gist -e' , 'edit gist'],
  155. \ 'l' : [':Gist -l' , 'list public gists'],
  156. \ 's' : [':Gist -ls' , 'list starred gists'],
  157. \ 'm' : [':Gist -m' , 'post gist all buffers'],
  158. \ 'p' : [':Gist -P' , 'post public gist '],
  159. \ 'P' : [':Gist -p' , 'post private gist '],
  160. \ }
  161. " \ 'a' : [':Gist -a' , 'post gist anon'],
  162. " l is for language server protocol
  163. let g:which_key_map.l = {
  164. \ 'name' : '+lsp' ,
  165. \ 'a' : [':Lspsaga code_action' , 'code action'],
  166. \ 'A' : [':Lspsaga range_code_action' , 'selected action'],
  167. \ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'],
  168. \ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'],
  169. \ 'f' : [':LspFormatting' , 'format'],
  170. \ 'I' : [':LspInfo' , 'lsp info'],
  171. \ 'v' : [':LspVirtualTextToggle' , 'lsp toggle virtual text'],
  172. \ 'l' : [':Lspsaga lsp_finder' , 'lsp finder'],
  173. \ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'],
  174. \ 'o' : [':Vista!!' , 'outline'],
  175. \ 'p' : [':Lspsaga preview_definition' , 'preview definition'],
  176. \ 'q' : [':Telescope quickfix' , 'quickfix'],
  177. \ 'r' : [':Lspsaga rename' , 'rename'],
  178. \ 'T' : [':LspTypeDefinition' , 'type defintion'],
  179. \ 'x' : [':cclose' , 'close quickfix'],
  180. \ 's' : [':Telescope lsp_document_symbols' , 'document symbols'],
  181. \ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'],
  182. \ }
  183. " \ 'H' : [':Lspsaga signature_help' , 'signature_help'],
  184. " t is for terminal
  185. let g:which_key_map.t = {
  186. \ 'name' : '+terminal' ,
  187. \ ';' : [':FloatermNew --wintype=normal --height=6' , 'terminal'],
  188. \ 'f' : [':FloatermNew fzf' , 'fzf'],
  189. \ 'g' : [':FloatermNew lazygit' , 'git'],
  190. \ 'd' : [':FloatermNew lazydocker' , 'docker'],
  191. \ 'n' : [':FloatermNew node' , 'node'],
  192. \ 'N' : [':FloatermNew nnn' , 'nnn'],
  193. \ 'p' : [':FloatermNew python' , 'python'],
  194. \ 'm' : [':FloatermNew lazynpm' , 'npm'],
  195. \ 't' : [':FloatermToggle' , 'toggle'],
  196. \ 'y' : [':FloatermNew ytop' , 'ytop'],
  197. \ 'u' : [':FloatermNew ncdu' , 'ncdu'],
  198. \ }
  199. " \ 'r' : [':FloatermNew ranger' , 'ranger'],
  200. let g:which_key_map.R = {
  201. \ 'name' : '+Find_Replace' ,
  202. \ 'f' : [':Farr --source=vimgrep' , 'file'],
  203. \ 'p' : [':Farr --source=rgnvim' , 'project'],
  204. \ }
  205. call which_key#register('<Space>', "g:which_key_map")