-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.ideavimrc
219 lines (190 loc) · 7.04 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
" .ideavimrc is a configuration file for IdeaVim plugin; it uses
" the same commands as the original .vimrc configuration
"
" You can find a list of commands here: https://jb.gg/h38q75
" Find more examples here: https://jb.gg/share-ideavimrc
" Parts of the following configuration are taken from here:
" https://amine-elhattami.medium.com/destination-ideavim-day-1-the-basics-793a514af57f
" and here: https://towardsdatascience.com/the-essential-ideavim-remaps-291d4cd3971b
""" General settings
" Show a few lines of context around the cursor; note that this makes the
" text scroll if you mouse-click near the start or end of the window
set scrolloff=3
" Do incremental searching (highlight results as you type)
set incsearch
" Use relative line numbers, except for the one under the cursor
set number
set relativenumber
" Enable copy paste from the system and PyCharm clipboards
set clipboard+=unnamed
set clipboard+=ideaput
" Use PyCharm lines join (with J)
set ideajoin
let mapleader = " "
" Specify which of Vim or the IDE should handle the conflicting mappings
sethandler <c-g> a:ide
sethandler <c-n> a:ide
sethandler <c-p> a:ide
sethandler <c-r> a:vim
sethandler <TAB> n-v:vim i:ide
sethandler <s-TAB> n-v:vim i:ide
""" Key mappings
" See the documentation here: https://jb.gg/abva4t
"" IdeaVim setup
nmap <leader>,e :edit ~/.ideavimrc<CR>
nmap <leader>,r <Action>(IdeaVim.ReloadVimRc.reload)
nmap <leader>,t <Action>(VimFindActionIdAction)
"" Projects management
nmap <c-SPACE>c <Action>(ManageRecentProjects)
nmap <c-SPACE>n <Action>(NextProjectWindow)
nmap <c-SPACE>p <Action>(PreviousProjectWindow)
nmap <c-SPACE>q <Action>(CloseProject)
"" Splits management
nmap <leader>v <Action>(MoveTabRight)
nmap <leader>V <Action>(SplitVertically)
nmap <leader>h <Action>(MoveTabDown)
nmap <leader>H <Action>(SplitHorizontally)
nmap <leader>u <Action>(Unsplit)
nmap <leader>U <Action>(UnsplitAll)
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nmap <c-m> <Action>(MoveEditorToOppositeTabGroup)
"" Tabs management
nmap <TAB> <Action>(NextTab)
nmap <s-TAB> <Action>(PreviousTab)
"" Files management
nmap <leader>a <Action>(NewElement)
nmap <leader>ro <Action>(ReopenClosedTab)
nmap <leader>x <Action>(CloseContent)
nmap <leader>X <Action>(CloseAllEditorsButActive)
"" Tool windows management
nmap <leader>l <Action>(JumpToLastWindow)
nmap <leader>n <Action>(ActivateProjectToolWindow)
nmap <leader>pyc <Action>(ActivatePythonConsoleToolWindow)
nmap <leader>q <Action>(HideActiveWindow)
nmap <leader>Q <Action>(CloseActiveTab)
nmap <leader>td <Action>(ActivateDebugToolWindow)
nmap <leader>te <Action>(ActivateProblemsViewToolWindow)
nmap <leader>tf <Action>(ActivateFindToolWindow)
nmap <leader>tg <Action>(ActivateVersionControlToolWindow)
nmap <leader>tm <Action>(ActivateBookmarksToolWindow)
nmap <leader>tr <Action>(ActivateRunToolWindow)
nmap <leader>tt <Action>(ActivateTODOToolWindow)
"" Modes & Python setups
nmap <leader>z <Action>(ToggleDistractionFreeMode)
nmap <leader>ps <Action>(TogglePowerSave)
nmap <leader>pyi <Action>(PySwitchSdkAction)
nmap <leader>th <Action>(QuickChangeScheme)
"" Search
map <leader>fa <Action>(SearchEverywhere)
map <leader>fc <Action>(GotoClass)
map <leader>ff <Action>(GotoFile)
map <leader>fi <Action>(Find)
map <leader>Fi <Action>(FindInPath)
map <leader>fo <Action>(RecentFiles)
map <leader>fr <Action>(Replace)
map <leader>Fr <Action>(ReplaceInPath)
map <leader>fs <Action>(GotoSymbol)
map <leader>fu <Action>(FindUsages)
vmap <leader>fw <Action>($SearchWeb)
"" Bookmarks
nmap m <Action>(ToggleBookmarkWithMnemonic)
nmap ' <Action>(ShowBookmarks)
"" Code navigation
nmap gd <Action>(GotoDeclaration)
nmap gi <Action>(GotoImplementation)
nmap gs <Action>(GotoSuperMethod)
nmap gte <Action>(GotoTest)
nmap gty <Action>(GotoTypeDeclaration)
"" Buffer navigation
nmap ]c <Action>(VcsShowNextChangeMarker)
nmap [c <Action>(VcsShowPrevChangeMarker)
nmap ]m <Action>(MethodDown)
nmap [m <Action>(MethodUp)
nmap ]u <Action>(GotoNextElementUnderCaretUsage)
nmap [u <Action>(GotoPrevElementUnderCaretUsage)
nmap ]e <Action>(GotoNextError)
nmap [e <Action>(GotoPreviousError)
"" Preview
nmap <leader>pd <Action>(QuickJavaDoc)
nmap <leader>ph <Action>(VcsShowCurrentChangeMarker)
nmap <leader>pi <Action>(QuickImplementations)
nmap <leader>pmo <Action>(Markdown.Layout.EditorAndPreview)
nmap <leader>pmc <Action>(Markdown.Layout.EditorOnly)
nmap <leader>pp <Action>(ParameterInfo)
nmap <leader>pt <Action>(QuickTypeDefinition)
"" Edition
nmap <leader>rh <Action>(Vcs.RollbackChangedLines)
nmap <leader>rn <Action>(RenameElement)
"" Code commenting
""" These keymaps are inspired from the plugin 'tpope/commentary-vim', however, the plugin
""" emulation for IdeaVim doesn't work on my setup.
nmap gca A # <Esc>a
nmap gcc <Action>(CommentByLineComment)
nmap gci I# <Esc>i
nmap gco o# <Esc>a
nmap gcO O# <Esc>a
vmap gc <Action>(CommentByLineComment)
"" Code running and debugging
nmap <leader>db <Action>(ToggleLineBreakpoint)
nmap <leader>de <Action>(DebugClass)
nmap <leader>re <Action>(Resume)
nmap <leader>rr <Action>(Rerun)
nmap <leader>ru <Action>(RunClass)
nmap <c-c> <Action>(Stop)
"" Code formatting
nmap <leader>fm <Action>(Tool_External Tools_Black)
nmap <leader>is <Action>(Tool_External Tools_isort)
nmap <leader>pr <Action>(Tool_External Tools_Prettier)
nmap <leader>rf <Action>(Tool_External Tools_Ruff)
"" Code folding
nmap <c-=> <Action>(ExpandRegion)
nmap <c-s-=> <Action>(ExpandAllRegions)
nmap <c--> <Action>(CollapseRegion)
nmap <c-s--> <Action>(CollapseAllRegions)
"" Insert mode mappings
""" <Home> goes to the very beginning of the line, including the indentation
imap <c-b> <Esc>^i
imap <c-e> <End>
imap <c-SPACE> <Action>(CodeCompletion)
"" Visual mode mappings
vmap <TAB> <Action>(EditorIndentLineOrSelection)
vmap <s-TAB> <Action>(EditorUnindentSelection)
""" IdeaVim plugins
" See the list of available plugins here: https://jb.gg/ideavim-plugins
"" NERDTree
" Vim-style project view
Plug 'preservim/nerdtree'
let g:NERDTreeMapOpenSplit='h'
let g:NERDTreeMapPreviewSplit='gh'
let g:NERDTreeMapOpenVSplit='v'
let g:NERDTreeMapPreviewVSplit='gv'
"" vim-highlightedyank
" Highlight the code region when yanked
Plug 'machakann/vim-highlightedyank'
"" surround.vim
" Provide mappings to easily manipulate parentheses, brackets, etc. and their content
Plug 'tpope/vim-surround'
"" EasyMotion
" Provide simpler ways to use motions in vim; see the documentation of the original plugin:
" https://github.com/easymotion/vim-easymotion/blob/master/doc/easymotion.txt
Plug 'easymotion/vim-easymotion'
" Disable the default mappings
let g:EasyMotion_do_mapping=0
let g:EasyMotion_keys = 'hgjfkdlsmqyturieozpabvn'
" Change the leader from <Leader><Leader> to <Leader>
map <Leader> <Plug>(easymotion-prefix)
" Define EasyMotion mappings
map s <Plug>(easymotion-s)
map f <Plug>(easymotion-fl)
map F <Plug>(easymotion-Fl)
map t <Plug>(easymotion-tl)
map T <Plug>(easymotion-Tl)
map <Leader>w <Plug>(easymotion-wl)
map <Leader>b <Plug>(easymotion-bl)
map <Leader>e <Plug>(easymotion-el)
map <Leader>ge <Plug>(easymotion-gel)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)