init.vim 11 KB

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