1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
" Leader Key Maps
" Timeout
let g:which_key_timeout = 100
let g:which_key_display_names = {'<CR>': '↵', '<TAB>': '⇆', " ": 'SPC'}
" Map leader to which_key
nnoremap <silent> <leader> :silent <c-u> :silent WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>
let g:which_key_map = {}
let g:which_key_sep = '→'
" Not a fan of floating windows for this
let g:which_key_use_floating_win = 0
let g:which_key_max_size = 0
" Hide status line
autocmd! FileType which_key
autocmd FileType which_key set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
let g:which_key_map['/'] = 'comment toggle'
let g:which_key_map[';'] = [ ':Dashboard' , 'home screen' ]
let g:which_key_map['?'] = [ ':NvimTreeFindFile' , 'find current file' ]
let g:which_key_map['e'] = [ ':NvimTreeToggle' , 'explorer' ]
let g:which_key_map['f'] = [ ':Telescope find_files' , 'find files' ]
let g:which_key_map['h'] = [ '<C-W>s' , 'split below']
let g:which_key_map['H'] = [ ':let @/ = ""' , 'no highlight' ]
let g:which_key_map['r'] = [ ':RnvimrToggle' , 'ranger' ]
" TODO create entire treesitter section
let g:which_key_map['v'] = [ '<C-W>v' , 'split right']
" TODO play nice with status line
" Group mappings
" b is for buffer
let g:which_key_map.b = {
\ 'name' : '+buffer' ,
\ '>' : [':BufferMoveNext' , 'move next'],
\ '<' : [':BufferMovePrevious' , 'move prev'],
\ 'b' : [':BufferPick' , 'pick buffer'],
\ 'd' : [':BufferClose' , 'delete-buffer'],
\ 'n' : ['bnext' , 'next-buffer'],
\ 'p' : ['bprevious' , 'previous-buffer'],
\ '?' : ['Buffers' , 'fzf-buffer'],
\ }
" d is for debug
let g:which_key_map.d = {
\ 'name' : '+debug' ,
\ 'b' : ['DebugToggleBreakpoint ' , 'toggle breakpoint'],
\ 'c' : ['DebugContinue' , 'continue'],
\ 'i' : ['DebugStepInto' , 'step into'],
\ 'o' : ['DebugStepOver' , 'step over'],
\ 'r' : ['DebugToggleRepl' , 'toggle repl'],
\ 's' : ['DebugStart' , 'start'],
\ }
" F is for fold
let g:which_key_map.F = {
\ 'name': '+fold',
\ 'O' : [':set foldlevel=20' , 'open all'],
\ 'C' : [':set foldlevel=0' , 'close all'],
\ 'c' : [':foldclose' , 'close'],
\ 'o' : [':foldopen' , 'open'],
\ '1' : [':set foldlevel=1' , 'level1'],
\ '2' : [':set foldlevel=2' , 'level2'],
\ '3' : [':set foldlevel=3' , 'level3'],
\ '4' : [':set foldlevel=4' , 'level4'],
\ '5' : [':set foldlevel=5' , 'level5'],
\ '6' : [':set foldlevel=6' , 'level6']
\ }
" s is for search powered by telescope
let g:which_key_map.s = {
\ 'name' : '+search' ,
\ '.' : [':Telescope filetypes' , 'filetypes'],
\ 'B' : [':Telescope git_branches' , 'git branches'],
\ 'd' : [':Telescope lsp_document_diagnostics' , 'document_diagnostics'],
\ 'D' : [':Telescope lsp_workspace_diagnostics' , 'workspace_diagnostics'],
\ 'f' : [':Telescope find_files' , 'files'],
\ 'h' : [':Telescope command_history' , 'history'],
\ 'i' : [':Telescope media_files' , 'media files'],
\ 'm' : [':Telescope marks' , 'marks'],
\ 'M' : [':Telescope man_pages' , 'man_pages'],
\ 'o' : [':Telescope vim_options' , 'vim_options'],
\ 't' : [':Telescope live_grep' , 'text'],
\ 'r' : [':Telescope registers' , 'registers'],
\ 'w' : [':Telescope file_browser' , 'buf_fuz_find'],
\ 'u' : [':Telescope colorscheme' , 'colorschemes'],
\ }
" S is for Session
let g:which_key_map.S = {
\ 'name' : '+Session' ,
\ 's' : [':SessionSave' , 'save session'],
\ 'l' : [':SessionLoad' , 'load Session'],
\ }
" g is for git
let g:which_key_map.g = {
\ 'name' : '+git' ,
\ 'b' : [':GitBlameToggle' , 'blame'],
\ 'B' : [':GBrowse' , 'browse'],
\ 'd' : [':Git diff' , 'diff'],
\ 'j' : [':NextHunk' , 'next hunk'],
\ 'k' : [':PrevHunk' , 'prev hunk'],
\ 'l' : [':Git log' , 'log'],
\ 'p' : [':PreviewHunk' , 'preview hunk'],
\ 'r' : [':ResetHunk' , 'reset hunk'],
\ 'R' : [':ResetBuffer' , 'reset buffer'],
\ 's' : [':StageHunk' , 'stage hunk'],
\ 'S' : [':Gstatus' , 'status'],
\ 'u' : [':UndoStageHunk' , 'undo stage hunk'],
\ }
" l is for language server protocol
let g:which_key_map.l = {
\ 'name' : '+lsp' ,
\ 'a' : [':Lspsaga code_action' , 'code action'],
\ 'A' : [':Lspsaga range_code_action' , 'selected action'],
\ 'd' : [':Telescope lsp_document_diagnostics' , 'document diagnostics'],
\ 'D' : [':Telescope lsp_workspace_diagnostics', 'workspace diagnostics'],
\ 'f' : [':LspFormatting' , 'format'],
\ 'I' : [':LspInfo' , 'lsp info'],
\ 'v' : [':LspVirtualTextToggle' , 'lsp toggle virtual text'],
\ 'l' : [':Lspsaga lsp_finder' , 'lsp finder'],
\ 'L' : [':Lspsaga show_line_diagnostics' , 'line_diagnostics'],
\ 'p' : [':Lspsaga preview_definition' , 'preview definition'],
\ 'q' : [':Telescope quickfix' , 'quickfix'],
\ 'r' : [':Lspsaga rename' , 'rename'],
\ 'T' : [':LspTypeDefinition' , 'type defintion'],
\ 'x' : [':cclose' , 'close quickfix'],
\ 's' : [':Telescope lsp_document_symbols' , 'document symbols'],
\ 'S' : [':Telescope lsp_workspace_symbols' , 'workspace symbols'],
\ }
call which_key#register('<Space>', "g:which_key_map")
|