-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.ideavimrc
More file actions
284 lines (248 loc) · 7.84 KB
/
.ideavimrc
File metadata and controls
284 lines (248 loc) · 7.84 KB
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
" See https://github.com/JetBrains/ideavim/wiki
""" Settings {{{
set visualbell
"set noerrorbells
"set t_vb=
set hls
set nu
set rnu
set clipboard=ideaput,unnamed
" set clipboard=ideaput
set incsearch
set showmode
set ideajoin " use IDEA to intelligently join lines
set ideastatusicon=enabled " always show ideavim icon
set ideavimsupport=dialog " use ideavim in dialogs
set idearefactormode=keep " keep mode enabled before starting refactor
"let mapleader="\\"
let mapleader="\\"
" workaround for not being able to set mapleader to <CR>
" https://youtrack.jetbrains.com/issue/VIM-2817/Unable-to-set-enter-backspace-as-leader-key
map <CR> <Leader>
iunmap <CR>
" }}}
""" Basic Bindings"{{{
nnoremap Y y$
"noremap <silent><leader>/ :nohls<CR>
noremap <Leader>/ :call Refresh()<CR>
nmap <Leader>r :call ReloadConfiguration()<CR>
nmap <C-l> :call Refresh()<CR>
"}}}
""" Plugins"{{{
Plug 'easymotion/vim-easymotion'
Plug 'preservim/nerdtree'
Plug 'tpope/vim-surround'
Plug 'kana/vim-textobj-entire' " Adds ae and ie text-objects
nmap <Leader>] :NERDTreeToggle<CR>
let g:NERDTreeMapActivateNode='l'
let g:NERDTreeMapPreview='h'
"}}}
""" IDEA Actions"{{{
" All implemented commands:
" https://github.com/JetBrains/ideavim/blob/master/src/main/java/com/maddyhome/idea/vim/package-info.java
"" Prefixes
" <C-s>: Alter code
" <C-j>: Navigate
nmap <D-k> <action>(RecentLocations)
vmap <M-j> <action>(MoveLineDown)
nmap <M-j> <action>(MoveLineDown)
vmap <M-k> <action>(MoveLineUp)
nmap <M-k> <action>(MoveLineUp)
nmap <C-s>s <action>(InsertLiveTemplate)
vmap <C-s>s <action>(SurroundWithLiveTemplate)
imap <C-s>s <action>(InsertLiveTemplate)
nmap <C-s><C-s> <action>(Refactorings.QuickListPopupAction)
vmap <C-s><C-s> <action>(Refactorings.QuickListPopupAction)
nmap <C-s>r <action>(RenameElement)
vmap <C-s>r <action>(RenameElement)
vmap <C-s>e <action>(ExtractMethod)
nmap <C-s>i <action>(OptimizeImports)
vmap <C-s>i <action>(OptimizeImports)
imap <C-s>i <action>(OptimizeImports)
" Cursor context
nmap <C-j>h <action>(CallHierarchy)
nmap <C-j>u <action>(FindUsages)
nmap <C-j><C-b> <action>(ToggleBookmark)
" File context
nmap <C-j>m <action>(FileStructurePopup)
nmap <C-j>i <action>(ViewImportPopups)
nmap <C-j>n <action>(ShowNavBar)
nmap <C-j><C-r> <action>(GotoRelated)
" No context
nmap <C-j><C-j> <action>(SearchEverywhere)
nmap <C-j>b <action>(ShowBookmarks)
nmap <C-j>/ <action>(FindInPath)
nmap <C-j>H <action>(LocalHistory.ShowHistory)
nmap <C-j>a <action>(GotoAction)
nmap <C-j>l :actionlist<Space>
nmap <C-j>s <action>(GotoSymbol)
nmap <C-j>c <action>(GotoClass)
nmap <C-j>f <action>(GotoFile)
nmap <C-j>g <action>(GotoGit)
nmap <C-j><C-s> <action>(SelectIn)
nmap <C-j>r :call ReloadConfiguration()<CR>
"nmap <C-j>r <action>(RecentFiles)
" nmap vak :call ReloadConfiguration()<CR>
map <C-w><C-w> <action>(JumpToLastWindow)
map <C-w>x <action>(HideActiveWindow)
map <C-w>X <action>(HideAllWindows)
" Navigation
" Reserved: gg gj gl gk gv gq gu gw
nmap ga <action>(ShowIntentionActions)
nmap gb <action>(Back)
nmap gc <action>(JumpToLastChange)
nmap gd <action>(GotoDeclaration)
nmap ge <action>(GotoNextError)
nmap gE <action>(GotoPreviousError)
nmap gf <action>(Forward)
nmap gF :NERDTreeToggle<CR>
"nmap gg <action>(MotionGotoFirstLine)
nmap gh <action>(VcsShowPrevChangeMarker)
nmap g; <action>(VcsShowNextChangeMarker)
nmap gi <action>(GotoImplementation)
nmap gm :action LocalHistory.ShowHistory<CR><Tab><Tab>
"nmap gn <action>()
nmap go <action>(AceAction)
" nmap gp <action>()
nmap gr <action>(ShowRecentTests)
nmap gs <action>(GotoSuperMethod)
nmap gt <action>(GotoTest)
nmap gT <action>(ActivateRunToolWindow)
"nmap gx <action>()
"nmap gy <action>()
nmap gz <action>(OpenProjectWindows)
nmap [[ <action>(MethodUp)
nmap ]] <action>(MethodDown)
" Trial
nmap ,M <action>(MoveEditorToOppositeTabGroup)
nmap <Leader>w <action>(NextProjectWindow)
nmap <Leader>l <action>(JumpToLastWindow)
nmap <Leader>p <action>(ToggleLineBreakpoint)
nmap <Leader>s <action>(ActivateStructureToolWindow)
nmap <Leader>h <action>(ShowErrorDescription)
nmap <Leader>H :call WhyNotBoth()<CR>
nmap <Leader>i <action>(InspectCode)
nmap <Leader>g <action>(Github.Open.In.Browser)
nmap <Leader>c <action>(RecentChangedFiles)
nmap <Leader>d <action>(ToggleRenderedDocPresentation)
nmap <Leader>D <action>(QuickJavaDoc)
"Debug Trial
nmap <C-m><C-m> <action>(JumpToLastWindow)
nmap <C-m>D <action>(ActivateDebugToolWindow)
nmap <C-m>d <action>(Debug)
nmap <C-m>s <action>(StepOver)
nmap <C-m>i <action>(StepInto)
nmap <C-m>I <action>(ForceStepInto)
nmap <C-m>o <action>(StepOut)
nmap <C-m>c <action>(RunToCursor)
nmap <C-m>e <action>(EvaluateExpression)
nmap <C-m>r <action>(Resume)
nmap <C-m>b <action>(ViewBreakpoints)
nmap <C-m>B <action>(MuteBreakpoints)
nmap <C-m>q <action>(Stop)
"nmap <Leader>x :action Tool_External Tools_toolname<CR> " define external tool in idea settings
"nmap <C-j>e <Action>(ShowErrorDescription)
"nmap <C-s><C-s> <Action>(SmartSelect)
"nmap <C-s>e <Action>(EditSmartGroup) " not useful
" Test Running
nmap ,T <action>(ActivateRunToolWindow)
nmap ,t <action>(ContextRun)
nmap ,c <action>(RunClass)
nmap ,C <action>(ChooseRunConfiguration)
nmap ,r <action>(Rerun)
nmap ,f <action>(RerunFailedTests)
nmap ,g <action>(Generate)
" Action Mappings
" Use "IdeaVIM: Track Action Ids" (from "Search Everywhere", <Shift><Shift>)
" :actionlist for full list of actions
vmap <C-l> <action>(SmartUnSelect)
nmap <C-y>a :call AnnotateLines()<CR>
nmap == <action>(ReformatCode)
vmap = <action>(ReformatCode)
" text-objects emulation
nmap vad <action>($SelectAll)
nmap vmm :call SelectMethod()<CR>
nmap vim :call SelectMethodInner()<CR>
nmap vam :call SelectMethodFull()<CR>
nmap dim :call DeleteMethodInner()<CR>
nmap dam :call DeleteMethodFull()<CR>
nmap dom :call AltSelectMethod()<CR>
" Folds
nmap zc <action>(CollapseRegion)
nmap zC <action>(CollapseRegionRecursively)
nmap zo <action>(ExpandRegion)
nmap zO <action>(ExpandRegionRecursively)
nmap za <action>(ExpandRegion)
nmap zA <action>(ExpandRegionRecursively)
nmap zR <action>(ExpandAllRegions)
nmap zM <action>(CollapseAllRegions)
"}}}
""" Java Method text-object Emulation"{{{
""" https://youtrack.jetbrains.com/issue/VIM-480/Add-text-objects-for-code-constructs-like-a-method-and-a-class
function! SelectMethodBase(post)
normal }
action MethodUp
exe "normal " . "_Vg_%" . a:post
endfunction
" Center Method
function! SelectMethod(post="")
let l:base = "o" . "zz" . a:post
call SelectMethodBase(l:base)
endfunction
" Select contents of method
function! SelectMethodInner(post="")
let l:base = "j" . "o" . "k" . "o" . a:post
call SelectMethod(l:base)
endfunction
" Select full method, including preceding whitespace
function! SelectMethodFull(post="")
let l:base = "{" . a:post
call SelectMethod(l:base)
endfunction
function! DeleteMethodInner()
call SelectMethodInner("d")
endfunction
function! DeleteMethodFull()
call SelectMethodFull("d")
endfunction
function! AltSelectMethod()
normal }
action MethodUp
let lines = {'first': 0, 'last': 0, 'first_nb': 0}
let lines['first'] = line(".")
normal k
exe "/{"
normal _f{%
let lines['last'] = line(".")
exe "normal " . lines['first'] . "G"
exe "?^$"
let lines['first_ext'] = line(".") + 1
let lines['last_ext'] = lines['last'] + 1
" echo lines['first'] . "," . lines['last']
"exe "normal " . lines['first'] . "G" . "V" . lines['last'] . "G"
exe "normal " . lines['first_ext'] . "G" . "V" . lines['last_ext'] . "G" . "o"
endfunction
"}}}
""" General Functions"{{{
function! Refresh()
action Refresh
action HideSideWindows
set rnu
set nu
noh
endfunction
function! ReloadConfiguration()
source ~/.ideavimrc
echo "Reloaded .ideavimrc"
endfunction
function! AnnotateLines()
set nornu
set nonu
action Annotate
endfunction
function! WhyNotBoth()
action ShowErrorDescription
"action QuickJavaDoc
endfunction
echo "Loaded .ideavimrc"
"}}}