-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.ideavimrc
351 lines (302 loc) · 13 KB
/
.ideavimrc
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
"" Source your .vimrc
"source ~/.vimrc
let mapleader = " "
" plugins
set which-key
set NERDTree
set commentary
set argtextobj
set highlightedyank
set ReplaceWithRegister
set easymotion
set surround
set multiple-cursors
set exchange
set ideajoin
set quickscope
set textobj-entire
" removing mappings
nunmap gr
nunmap grr
"""""""""""""""""""""""" SETTINGS """""""""""""""""""""""""""""
" System clipboard fi
set clipboard^=unnamedplus,unnamed
" Turning off error bells
set noerrorbells
set visualbell
" for which-key to display popup
set notimeout
let g:WhichKey_ShowVimActions = "false"
" settings for quick-scope
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" settings for highlightedyank
let g:highlightedyank_highlight_duration = "1000"
let g:highlightedyank_highlight_color = "rgba(160, 160, 160, 155)"
" settings for argtextobject
let g:argtextobj_pairs="(:),{:},<:>,[:]"
" Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set iskeyword+=-
set tabstop = 4
set softtabstop = 4
set scrolloff=8
set nu rnu
" Do incremental searching.
set incsearch
set ignorecase
set smartcase
" Don't use Ex mode, use Q for formatting.
map Q gq
"""""""""""""""""""""""" BETTER INDENTS """""""""""""""""""""""""""""
vmap < <gv
vmap > >gv
"""""""""""""""""""""""" MOVEMENTS """""""""""""""""""""""""""""
map <A-j> <Action>(MoveStatementDown)
map <A-k> <Action>(MoveStatementUp)
map <S-L> <Action>(NextTab)
map <S-H> <Action>(PreviousTab)
nmap <C-i> <Action>(Forward)
nmap <C-o> <Action>(Back)
nmap <C-h> :NERDTreeFocus<CR>
"""""""""""""""""""""""" LEADER FILE/FIND MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_find_files_menu = "<leader>f Find/Files"
map <leader>ff <Action>(GotoFile)
let g:WhichKeyDesc_find_files = "<leader>ff find files"
map <leader>fc <Action>(GotoClass)
let g:WhichKeyDesc_find_class = "<leader>fc find class"
map <leader>fb <Action>(RecentFiles)
let g:WhichKeyDesc_find_buffers = "<leader>fb find buffers"
map K <Action>(QuickJavaDoc)
map <leader>f? <Action>(GotoAction)
let g:WhichKeyDesc_find_actions = "<leader>f? find actions"
map <leader>fs <Action>(NewScratchFile)
let g:WhichKeyDesc_file_scratch = "<leader>fs new scratch file"
"""""""""""""""""""""""" LEADER MAPPINGS """""""""""""""""""""""""""""
map <leader>a <Action>(ShowIntentionActions)
let g:WhichKeyDesc_actions = "<leader>a Show actions"
let g:WhichKeyDesc_quit = "<leader>q Quit+"
let g:WhichKeyDesc_quit_ide = "<leader>qq Quit All"
map <leader>qq <Action>(Exit)
lActionseActionst g:WhichKeyDesc_quit_project = "<leader>qp Quit Project"
map <leader>qp <Action>(CloseProject)
map <leader>e :NERDTreeToggle<CR>
let g:WhichKeyDesc_explorer = "<leader>e Open explorer"
map <leader>o :NERDTreeFind<CR>
let g:WhichKeyDesc_focus_in_explorer = "<leader>o Focus in explorer"
map <leader>/ <Action>(CommentByLineComment)
let g:WhichKeyDesc_comment_line = "<leader>/ Comment line"
"""""""""""""""""""""""" LEADER SEARCH MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_search = "<leader>s Search"
map <leader>ss <Action>(FileStructurePopup)
let g:WhichKeyDesc_search_symbol = "<leader>ss search symbol"
map <leader>sg <Action>(FindInPath)
let g:WhichKeyDesc_search_grep = "<leader>sg search grep"
map <leader>sw mpviw:<Action>(FindInPath)<CR>`p
let g:WhichKeyDesc_search_word = "<leader>sw search word"
map <leader>sr <Action>(Replace)
let g:WhichKeyDesc_search_replace = "<leader>sr search and replace"
map <leader>sR <Action>(ReplaceInPath)
let g:WhichKeyDesc_search_replace_in_workspace = "<leader>sR search and replace in workspace"
"""""""""""""""""""""""" WINDOW MAPPINGS """""""""""""""""""""""""""""
nmap <C-/> <Action>(ActivateTerminalToolWindow)
nmap <C-w>q <Action>(CloseContent)
"""""""""""""""""""""""" BUFFER MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_buffers = "<leader>b Buffer"
nmap <leader>bd <Action>(CloseContent)
let g:WhichKeyDesc_buffer_delete = "<leader>bd delete buffer"
nmap <leader>bo <Action>(CloseAllEditorsButActive)
let g:WhichKeyDesc_buffer_delete_others = "<leader>bo delete other buffers"
"""""""""""""""""""""""" PROJECT MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_project = "<leader>p Project"
let g:WhichKeyDesc_recent_projects_list = "<leader>pl recent projects"
map <leader>pl <Action>(ManageRecentProjects)
let g:WhichKeyDesc_project_execute_maven = "<leader>pe execute maven goal"
map <leader>pe <Action>(Maven.ExecuteGoal)
let g:WhichKeyDesc_project_analyze_dependencies = "<leader>pd analyze maven dependencies"
map <leader>pd <Action>(Maven.ProjectViewDependencyAnalyzer)
let g:WhichKeyDesc_project_run_config = "<leader>pr run configurations"
map <leader>pr <Action>(ChooseRunConfiguration)
let g:WhichKeyDesc_project_structure = "<leader>ps project settings"
map <leader>ps <Action>(ShowProjectStructureSettings)
let g:WhichKeyDesc_project_tree = "<leader>pt project dependency tree"
map <leader>pt <Action>(ShowUmlDiagramPopup)
let g:WhichKeyDesc_project_ideavim = "<leader>pi reload ideavimrc"
map <leader>pi <Action>(IdeaVim.ReloadVimRc.reload)
let g:WhichKeyDesc_project_maven_dependencies = "<leader>pm reload maven dependencies"
map <leader>pm <Action>(ExternalSystem.ProjectRefreshAction)
"""""""""""""""""""""""" CODE MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_code = "<leader>c Code"
map <leader>cf <Action>(ReformatCode)
map <leader>co <Action>(OptimizeImports)
map <leader>cg <Action>(Generate)
map <leader>cm <Action>(OverrideMethods)
map <leader>ch <Action>(TypeHierarchy)
"""""""""""""""""""""""" DEBUG MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_debug = "<leader>d Debug"
map <leader>db <Action>(ToggleLineBreakpoint)
let g:WhichKeyDesc_toggle_breakpoint_leader = "<leader>db toggle breakpoint"
map <leader>dc <Action>(Resume)
let g:WhichKeyDesc_resume_debug = "<leader>dc resume execution"
map <leader>ds <Action>(Debug)
let g:WhichKeyDesc_start_debug = "<leader>ds start debug"
map <M-d>b <Action>(ToggleLineBreakpoint)
let g:WhichKeyDesc_toggle_breakpoint = "<M-d>b toggle breakpoint"
map <M-d>o <Action>(StepOver)
let g:WhichKeyDesc_step_over = "<M-d>o step over"
map <M-d>i <Action>(StepInto)
let g:WhichKeyDesc_step_into = "<M-d>i step into"
map <M-d>u <Action>(StepOut)
let g:WhichKeyDesc_step_out = "<M-d>u step out"
map <M-d>e <Action>(EvaluateExpression)
let g:WhichKeyDesc_evaluate_expression = "<M-d>e evaluate expression"
map <M-d>c <Action>(Resume)
let g:WhichKeyDesc_resume = "<M-d>c resume execution"
"""""""""""""""""""""""" TEST MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_test = "<leader>t Test"
map <leader>tr <Action>(RunClass)
let g:WhichKeyDesc_run_current_test = "<leader>tr run closest test"
map <leader>tl <Action>(Run)
let g:WhichKeyDesc_run_last_test = "<leader>tl run last test"
map <leader>tf <Action>(RerunFailedTests)
let g:WhichKeyDesc_rerun_failed_test = "<leader>tf rerun failed tests"
map <leader>td <Action>(DebugClass)
let g:WhichKeyDesc_debug_current_test = "<leader>td debug current test"
map <leader>tv <Action>(ShowRecentTests)
let g:WhichKeyDesc_view_recent_tests = "<leader>tv view recent tests"
map <leader>ts <Action>(Stop)
let g:WhichKeyDesc_stop = "<leader>ts stop"
"""""""""""""""""""""""" REFACTOR MAPPINGS """""""""""""""""""""""""""""
map <leader>rr <Action>(RenameElement)
let g:WhichKeyDesc_refactor = "<leader>r Refactor"
let g:WhichKeyDesc_refactor_rename = "<leader>rr rename"
map <leader>rm <Action>(ExtractMethod)
let g:WhichKeyDesc_refactor_method = "<leader>rm extract method"
map <leader>rv <Action>(IntroduceVariable)
let g:WhichKeyDesc_refactor_variable = "<leader>rv extract variable"
map <leader>rc <Action>(IntroduceConstant)
let g:WhichKeyDesc_refactor_constant = "<leader>rc extract constant"
map <leader>rd <Action>(SafeDelete)
let g:WhichKeyDesc_refactor_safe_delete = "<leader>rd safe delete"
map <leader>rf <Action>(IntroduceField)
let g:WhichKeyDesc_refactor_field = "<leader>rf extract field"
map <leader>rp <Action>(IntroduceParameter)
let g:WhichKeyDesc_refactor_parameter = "<leader>rp extract parameter"
map <leader>ri <Action>(Inline)
let g:WhichKeyDesc_refactor_inline = "<leader>ri inline"
map <leader>ro <Action>(IntroduceParameterObject)
let g:WhichKeyDesc_refactor_param_object = "<leader>ro extract parameter object"
map <leader>rq <Action>(Refactorings.QuickListPopupAction)
let g:WhichKeyDesc_refactor_quick_popup = "<leader>rq show refactor popup"
map <leader>rs <Action>(SurroundWith)
let g:WhichKeyDesc_surround_with = "<leader>rs surround with"
map <leader>ru <Action>(Unwrap)
let g:WhichKeyDesc_unwrap = "<leader>ru unwrap"
map <leader>rt <Action>(Move)
let g:WhichKeyDesc_transport_object = "<leader>rt transport"
"""""""""""""""""""""""" DIAGNOSTICS MAPPINGS """""""""""""""""""""""""""""
map <leader>xt <Action>(RenameElement)
let g:WhichKeyDesc_diagnostics = "<leader>x diagnostics"
let g:WhichKeyDesc_diagnostics = "<leader>xt todo"
nmap <leader>xt <Action>(ActivateTODOToolWindow)
"""""""""""""""""""""""" GIT MAPPINGS """""""""""""""""""""""""""""
let g:WhichKeyDesc_git = "<leader>g Git"
map <leader>gu <Action>(Vcs.UpdateProject)
map <leader>gp <Action>(Vcs.Push)
map <leader>gh <Action>(Vcs.ShowTabbedFileHistory)
map <leader>gg <Action>(CheckinProject)
map <leader>gf <Action>(Git.Fetch)
map <leader>gn <Action>(Git.CreateNewBranch)
map <leader>gl <Action>(Git.Branches)
map <leader>gm <Action>(Git.Merge)
map <leader>gb <Action>(Git.Rebase)
map <leader>g= <Action>(Git.CompareWithBranch)
map <leader>gr <Action>(ChangesView.Revert)
map <leader>gq <Action>(Vcs.QuickListPopupAction)
"""""""""""""""""""""""" GOTO MAPPINGS """""""""""""""""""""""""""""
nmap gd <Action>(GotoDeclaration)
nmap gr <Action>(GotoDeclaration)
nmap gy <Action>(GotoTypeDeclaration)
nmap gi <Action>(GotoImplementation)
nmap gt <Action>(GotoTest)
nmap gs <Action>(ParameterInfo)
nmap gl <Action>(ShowErrorDescription)
nmap g; <Action>(JumpToLastChange)
nmap g, <Action>(JumpToNextChange)
"""""""""""""""""""""""" UNIMPARIED MAPPINGS """""""""""""""""""""""""""""
nmap ]f <Action>(MethodDown)
map [f <Action>(MethodUp)
map ]d <Action>(GotoNextError)
map [d <Action>(GotoPreviousError)
map ]g <Action>(VcsShowNextChangeMarker)
map [g <Action>(VcsShowPrevChangeMarker)
nnoremap ]<space> mpo<Esc>`p
nnoremap [<space> mpO<Esc>`p
"""""""""""""""""""""""" MULTIPLE CURSOR MAPPINGS """""""""""""""""""""""""""""
" Remap multiple-cursors shortcuts to match terryma/vim-multiple-cursors
nmap <C-n> <Plug>NextOccurrence
xmap <C-n> <Plug>NextOccurrence
" Note that the default <A-n> and g<A-n> shortcuts don't work on Mac due to dead keys.
" <A-n> is used to enter accented text e.g. ñ
nmap <S-A-C-n> <Plug>AllWholeOccurrences
xmap <S-A-C-n> <Plug>AllWholeOccurrences
" intellij nie ma takiej akcji!
"map <c-s-N> <Action>(SelectPreviousOccurrence)
nmap <M-n> <Action>(EditorCloneCaretBelow)
nmap <M-S-N> <Action>(EditorCloneCaretAbove)
"""""""""""""""""""""""" EASY MOTION MAPPINGS """""""""""""""""""""""""""""
"map s <Plug>(easymotion-s)
"""""""""""""""""""""""" ReplaceWithRegister """""""""""""""""""""""""""""
nmap cr <Plug>ReplaceWithRegisterOperator
nmap crr <Plug>ReplaceWithRegisterLine
xmap cr <Plug>ReplaceWithRegisterVisual
"""""""""""""""""""""""" SURROUND MAP """""""""""""""""""""""""""""
nmap ma <Plug>YSurround
nmap md <Plug>DSurround
nmap mr <Plug>CSurround
""""""""""""""""""""""" EASY MOTION MAP """""""""""""""""""""""""""""
nmap s <Plug>(easymotion-s)
"""""""""""""""""""""""" INSERT MODE MAPPINGS """""""""""""""""""""""""""""
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
"""""""""""""""""""""""" FOLDS MAPPINGS """""""""""""""""""""""""""""
nmap zc <Action>(CollapseRegion)
nmap zo <Action>(ExpandRegion)
nmap zM <Action>(CollapseAllRegions)
nmap zR <Action>(ExpandAllRegions)
"""""""""""""""""""""""" YANK MAPPINGS """""""""""""""""""""""""""""
nmap <leader>y :%y+<cr>
let g:WhichKeyDesc_yank_buffer = "<leader>y Yank entire buffer to clipboard"
"""""""""""""""""""""""" VIRTUAL ASSISTANT MAPPINGS """""""""""""""""""""""""""""
nmap <leader>vc <Action>(ActivateGitHubCopilotChatToolWindow)
"""""""""""""""""""""""" CUSTOM FUNCTIONS MAPPINGS """""""""""""""""""""""""""""
" Stolen from https://github.com/citizenmatt/dotfiles/blob/master/ideavimrc
function! Invert(calledFromVisual)
let antonyms = ['true', 'false', 'after', 'before', 'start', 'end', 'left', 'right', 'first', 'last',
\'True', 'False', 'After', 'Before', 'Start', 'End', 'Left', 'Right', 'First', 'Last',
\'private', 'public']
if a:calledFromVisual
normal gv"wy
else
normal "wyiw
endif
let wordUnderCaret = @w
let eraseWord = a:calledFromVisual ? 'gvc' : 'ciw'
let count = 0
while (count < len(antonyms))
if (antonyms[count] ==# wordUnderCaret)
let antonym = (count % 2 ==? 0) ? antonyms[count + 1] : antonyms[count - 1]
execute 'normal ' .. eraseWord .. antonym
break
endif
let count += 1
endwhile
endfunction
nnoremap ! :call Invert(0)<CR>
vnoremap ! :<C-u>call Invert(1)<CR>
" Find more examples here: https://jb.gg/share-ideavimrc