-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmappings.vim
238 lines (191 loc) · 9.41 KB
/
mappings.vim
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
" MAPPINGS --------------------------------------------
let mapleader = "\<Space>"
call which_key#register('<Space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
let g:which_key_map = {}
" TODO: nnoremap <silent> coh :call gruvbox#hls_toggle()<CR>
" b => buffers ----------
let g:which_key_map.b = { 'name': '+buffers' }
let g:which_key_map.b.a = [':Bdelete all', 'close all']
nmap ; :Buffers<CR>
let g:which_key_map.b.b = [':Buffers', 'buffers'] " list buffers
let g:which_key_map.b.d = [':BD', 'close'] " delete a buffer but keep its window
let g:which_key_map.b.o = [':Bdelete hidden', 'close others'] " close all buffers except buffer in current window
let g:which_key_map.b.w = [':bd', 'close window and buffer']
" goes to the previous/next buffer
nmap <S-h> :BB<CR>
nmap <S-l> :BF<CR>
let g:which_key_map.b.p = [':BB', 'previous']
let g:which_key_map.b.n = [':BF', 'next']
" c => code ----------
let g:which_key_map.c = { 'name': '+code' }
let g:which_key_map.c.d = [':GoToTag', 'tag definition']
let g:which_key_map.c.f = ['<Plug>(coc-definition)', 'coc definition']
let g:which_key_map.c.r = ['<Plug>(coc-references)', 'references']
let g:which_key_map.c.n = ['<Plug>(coc-rename)', 'rename']
let g:which_key_map.c.c = ['<plug>NERDCommenterToggle', 'comment'] " toggle comment
let g:which_key_map.c[' '] = ['RemoveTrailingSpaces', 'remove trailing spaces']
let g:which_key_map.c.p = ['RemoveDebuggers', 'remove debuggers'] " remove byebug, debugger, etc
let g:which_key_map.c.s = ['Snippets', 'snippets']
let g:which_key_map.c.t = ['Filetypes', 'change file type']
" CoC gotos mappings
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" f => file ----------
let g:which_key_map.f = { 'name': '+file' }
let g:which_key_map.f.f = ['CopyFullPath', 'copy full path']
let g:which_key_map.f.n = ['CopyFileName', 'copy file name']
let g:which_key_map.f.r = ['CopyRelativePath', 'copy relative path']
let g:which_key_map.f.m = ['Marks', 'marks']
" g => git ----------
let g:which_key_map.g = { 'name': '+git' }
let g:which_key_map.g.o = [':CocCommand git.browserOpen', 'open on github']
let g:which_key_map.g.s = [':GFiles?', 'status']
let g:which_key_map.g.l = [':GitMessenger', 'line log']
" j => jump ----------
let g:which_key_map.j = { 'name': '+jump' }
let g:which_key_map.j.l = ['<Plug>(easymotion-lineforward)', 'forward']
let g:which_key_map.j.j = ['<Plug>(easymotion-j)', 'down']
let g:which_key_map.j.k = ['<Plug>(easymotion-k)', 'up']
let g:which_key_map.j.h = ['<Plug>(easymotion-linebackward)', 'backward']
let g:which_key_map.j.f = ['<Plug>(easymotion-w)', 'forward/down']
let g:which_key_map.j.b = ['<Plug>(easymotion-b)', 'backward/up']
map f <Plug>(easymotion-lineforward)
map F <Plug>(easymotion-linebackward)
" p => project ----------
map <C-p> :Files<CR>
let g:which_key_map.p = { 'name': '+project' }
let g:which_key_map.p.b = ['TagbarToggle', 'tagbar'] " locate file on nerdtree
let g:which_key_map.p.f = ['Files', 'files'] " fuzzy find files
let g:which_key_map.p.g = ['Tags', 'tags'] " fuzzy find tags
let g:which_key_map.p.t = ['NERDTreeToggle', 'tree'] " toggle nerdtree
let g:which_key_map.p.l = ['NERDTreeFind', 'locate on tree'] " locate file on nerdtree
" s => search----------
let g:which_key_map.s = { 'name': '+search' }
map s :Rg<CR>
let g:which_key_map.s.s = ['Rg', 'search'] " ALT-A + enter to copy everything to quickfix
let g:which_key_map.s.h = ['TurnOffSearchHighlight', 'turn off highlight']
let g:which_key_map.s.H = [':Helptags', 'help tags']
let g:which_key_map.s.l = ['Lines', 'lines in buffers']
nmap <C-f> :Filetypes<CR>
let g:which_key_map.s.f = ['Filetypes', 'filetypes'] " fuzzy search for file types and manually set it
map r :History<CR>
let g:which_key_map.s.r = ['History', 'recent files'] " open window to find recent files
let g:which_key_map.s.w = ['Windows', 'windows']
" S => sessions----------
let g:which_key_map.S = { 'name': '+sessions' }
let g:which_key_map.S.s = [':call g:SaveSession()', 'save']
let g:which_key_map.S.l = ['Sessions', 'list'] " <Ctrl-X> deletes session under the cursor
let g:which_key_map.S.q = ['SQuit', 'quit tracking sessions']
" TAB => tabs ----------
nmap <Tab> :tabnext<CR>
nmap <S-Tab> :tabprevious<CR>
let g:which_key_map['<Tab>'] = { 'name': '+tabs' }
let g:which_key_map['<Tab>'].n = ['tabnew', 'new']
let g:which_key_map['<Tab>'].l = ['tabnext', 'next'] " next tab (hjkL)
let g:which_key_map['<Tab>'].h = ['tabprevious', 'previous'] " previous tab (Hjkl)
let g:which_key_map['<Tab>'].c = ['tabclose', 'close']
let g:which_key_map['<Tab>'].r = [':call g:tabulous#renameTab()', 'rename']
" t => tests ----------
let g:which_key_map.t = { 'name': '+tests' }
let g:which_key_map.t.t = ['TestNearest', 'nearest']
let g:which_key_map.t.f = ['TestFile', 'file']
let g:which_key_map.t.l = ['TestLast', 'last']
let g:which_key_map.t.g = ['TestVisit', 'visit']
let g:which_key_map.t.m = { 'name': 'which_key_ignore' }
" T => toggles ----------
let g:which_key_map.T = { 'name': '+toggles' }
let g:which_key_map.T.a = ['ALEToggle', 'ALE'] " toggle linting
let g:which_key_map.T.c = [':Colors', 'colorschemes']
let g:which_key_map.T.n = [':ToggleLineNumbers', 'numbers']
let g:which_key_map.T.l = [':ToggleLineNumbers', 'line numbers'] " because I sometimes forgot that that map is SPC T n
let g:which_key_map.T.r = [':ToggleRelativeLineNumbers', 'relative numbers']
let g:which_key_map.T.m = [':messages', 'messages']
let g:which_key_map.T.i = [':IndentLinesToggle', 'indent lines']
" v => vimlociraptor ----------
let g:which_key_map.v = { 'name': '+vimlociraptor' }
let g:which_key_map.v.m = ['OpenMappingsVim', 'mappings.vim']
let g:which_key_map.v.p = ['OpenPluginsVim', 'plugins.vim']
let g:which_key_map.v.c = ['OpenCommandsVim', 'commands.vim']
let g:which_key_map.v.f = ['OpenConfigsVim', 'configs.vim']
let g:which_key_map.v.s = ['OpenStatusLineVim', 'statusline.vim']
let g:which_key_map.v.r = ['ReloadVimConfig', 'reload']
let g:which_key_map.v.i = ['PlugInstall', 'install']
let g:which_key_map.v.u = ['PlugUpdate', 'update']
let g:which_key_map.v.k = ['PlugClean', 'clean']
let g:which_key_map.v.h = ['<Plug>HiLinkTrace', 'show highlight link trace']
let g:which_key_map.v.o = [':call coc#refresh()', 'refresh coc']
" w => windows ----------
let g:which_key_map.w = { 'name': '+windows' }
let g:which_key_map.w.c = ['q', 'close']
let g:which_key_map.w.o = ['only', 'close others']
let g:which_key_map.w.r = ['InteractiveWindow', 'resize interactively']
let g:which_key_map.w['-'] = ['split', 'split horizontally']
let g:which_key_map.w['/'] = ['vsplit', 'split vertically']
nmap <C-\> :vsplit<CR>
let g:which_key_map.w.s = [':EasyWindowSwap', 'swap'] " need to run it on both windows
let g:which_key_map.w.z = ['<Plug>(zoom-toggle)', 'zoom']
" ignore
let g:which_key_map.b.u = { 'name': 'which_key_ignore' }
let g:which_key_map.b.f = 'which_key_ignore'
let g:which_key_map.C = { 'name': 'which_key_ignore' }
let g:which_key_map.h = { 'name': 'which_key_ignore' }
let g:which_key_map['!'] = { 'name': 'which_key_ignore' }
" ----------------------------------------------
" language specific mappings ----------
" (not using ftplugin because I want all my mappings to live in one file)
"
" l => ruby ----------
function! s:MapRuby()
let g:which_key_map.l = { 'name': '+ruby' }
let g:which_key_map.l.a = ['A', 'alternate']
let g:which_key_map.l.u = [':ALEFindReferences -relative', 'usages']
let g:which_key_map.l.r = ['R', 'related']
let g:which_key_map.l.e = ['<Plug>(ale_next_wrap)', 'errors']
let g:which_key_map.l.f = ['ALEFix', 'format']
endfunction
autocmd! FileType ruby,eruby call s:MapRuby()
" l => elixir ----------
function! s:MapElixir()
let g:which_key_map.l = { 'name': '+elixir' }
let g:which_key_map.l.d = [':call alchemist#exdef()', 'definition']
let g:which_key_map.l.e = [':call alchemist#exdoc()', 'ExDocs']
let g:which_key_map.l.f = [':FormatElixirFile', 'format']
let g:which_key_map.l.i = [':IEx', 'IEx']
let g:which_key_map.l.s = [':call alchemist#jump_tag_stack()', 'stack']
endfunction
autocmd! FileType elixir call s:MapElixir()
" l => javascript ----------
function! s:MapJavaScript()
let g:which_key_map.l = { 'name': '+javascript' }
let g:which_key_map.l.d = [':call ReactGotoDef()', 'definition'] " go to definition
let g:which_key_map.l.f = [':CocCommand prettier.formatFile', 'format']
endfunction
autocmd! FileType javascript,json call s:MapJavaScript()
" ----------------------------------------------
" Copy and cut an entire line to clipboard
vmap <C-c> :w !pbcopy<CR><CR>
vmap <C-x> :!pbcopy<CR>
" Save using Ctrl + s, ¯\_(ツ)_/¯
map <C-s> :w<CR>
map <C-q> :q<CR>
map <C-a> :wqa<CR>
" Disable cursor keys in normal mode, no idea how to use emojis
map <Left> :echo "use h instead (hjkl)"<CR>
map <Right> :echo "use l instead (hjkl)"<CR>
map <Up> :echo "use k instead (hjkl)"<CR>
map <Down> :echo "use j instead (hjkl)"<CR>
" use Alt + hjkl instead of Ctrl + hjkl
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <M-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <M-j> :TmuxNavigateDown<cr>
nnoremap <silent> <M-k> :TmuxNavigateUp<cr>
nnoremap <silent> <M-\> :TmuxNavigatePrevious<cr>
nnoremap <silent> <M-l> :TmuxNavigateRight<cr>
" use Ctrl + hj to move lines
let g:move_key_modifier = 'C'
" move this away since I can't remove it, TODO: remove this plugin?
let g:table_mode_map_prefix = "<leader>C"