-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ideavimrc
195 lines (155 loc) · 5.95 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
""" SETTINGS """
" Source local `.vimrc`.
source ~/.vim/.vimrc
""" IDEA SPECIFIC SETTINGS """
" TODO https://github.com/JetBrains/ideavim/wiki/%22set%22-commands
" Switches to English input method in Normal mode and restore input method in
" Insert mode.
set keep-english-in-normal-and-restore-in-insert
" Make sure `ideaput` is enabled for clipboard to enable native IDE's insertion
" in Vim.
set clipboard+=ideaput
" Throws an exception on IdeaVim error.
set ideastrictmode
" If true, creation of global mark will trigger creation of IDE's bookmark and
" vice versa.
set ideamarks
" Define the mode that would be enabled during the refactoring (renaming, live
" template, introduce variable, etc).
set idearefactormode=select
" "Smart join" like in Vim (<S-j>).
set ideajoin
" IdeaVim status icon.
set ideastatusicon=enabled
" Defines the behaviour of `:w` command.
set ideawrite=all
" Disable the use of the <Tab> key for finishing the lookup (autocompletion).
set lookupkeys-=<Tab>
" Define the list of additional buffers where IdeaVim is enabled.
set ideavimsupport=dialog
" IDK how, but it turns off all bells.
set visualbell
""" PLUGINS WITH MAPPINGS """
" INFO https://github.com/JetBrains/ideavim/wiki/Emulated-plugins
" " NOTE Requires AceJump and IdeaVim-EasyMotion plugins.
" Plug 'easymotion/vim-easymotion'
" " vim-easymotion's default prefix.
" map <Leader> <Plug>(easymotion-prefix)
" " Jump forward.
" nmap <Leader>e <Plug>(easymotion-W)
" " Jump backward.
" nmap <Leader>E <Plug>(easymotion-B)
" The missing motion for Vim.
" NOTE Requires 'IdeaVim-Sneak' plugin.
" `s{char}{char}` and two chars - sneaking forward.
" `S{char}{char}` - sneaking backward.
" `;` or `,` - continue sneaking.
set sneak
" Emulation of the `NERDTree` plugin.
" `r` - recursively refresh the current directory.
" `R` - recursively refresh the current root.
" `K` - navigate to the first sibling of current file/directory.
" `J` - navigate to the last sibling of current file/directory.
" `o` (<CR>) - open file in a new tab.
" `O` - recursively open the selected directory.
" `P` - jump to the root node.
" `p` - jump to current nodes parent.
" `A` - zoom (maximize/minimize) the NERDTree window.
" `v` - split vertically.
" `h` - split horizontally.
Plug 'preservim/nerdtree'
nnoremap <C-n> :NERDTreeFocus<CR>
let g:NERDTreeMapOpenVSplit='v'
let g:NERDTreeMapOpenSplit='h'
" Does not support `yss`.
Plug 'tpope/vim-surround'
" Does not support `gcA`.
Plug 'tpope/vim-commentary'
nmap <Leader><Leader> gcc
vmap <Leader><Leader> gc
" Commands: `gr`, `grr`.
Plug 'vim-scripts/ReplaceWithRegister'
" NOTE Does not refactor (like Ctrl + F6).
" Provides a text-object 'a' (argument).
" Useful commands: `daa`, `cia`.
" Plug 'vim-scripts/argtextobj.vim'
" Easy text exchange operator for Vim.
" `cx{motion}` - define the first {motion} to exchange, then define the second
" {motion} (for example, by `.` repeating) and perform the exchange.
" `cxx` - like `cx`, but use the current line.
" `X` - like `cx`, but for Visual mode => without `.` repeating.
" `cxc` - clear any {motion} pending for exchange.
Plug 'tommcdo/vim-exchange'
" Provides text objects (`ae` and `ie`) to select the entire content of a
" buffer. The best text object: `ie` (like `ae`, but does not include leading
" and trailing empty lines).
Plug 'kana/vim-textobj-entire'
" Make the yanked region apparent!
Plug 'machakann/vim-highlightedyank'
" A negative number makes the highlight persistent.
let g:highlightedyank_highlight_duration='-1'
let g:highlightedyank_highlight_color='rgba(241, 250, 140, 128)'
" Lines that only contain whitespace are also matched by the `{` and `}`
" motions.
Plug 'dbakker/vim-paragraph-motion'
" Text object, based on indentation levels (`a` - around, `i` - indent):
" Sorted by usefulness:
" ii - (I)nner (I)ndentation level (no line above).
" ai - (A)n (I)ndentation level and line above.
" aI - (A)n (I)ndentation level and lines above/below.
Plug 'michaeljsmith/vim-indent-object'
" Extended matching with `%`.
Plug 'chrisbra/matchit'
""" BASIC MAPPINGS """
" NOTE Mappings to <Action> don't work with `noremap` mappings.
" TODO Map all used actions.
" Additional functionality: clear last search highlighting.
" nnoremap <Esc> <Esc>/a_word_that_is_not_likely_to_be_searched<CR>:noh<CR>
" `a<BS><Esc>` is added to avoid unnecessary movement of the cursor.
" inoremap <Esc> <Esc>/a_word_that_is_not_likely_to_be_searched<CR>:noh<CR>
" vnoremap <Esc> <Esc>/a_word_that_is_not_likely_to_be_searched<CR>:noh<CR>
nnoremap <Esc> <Esc>:noh<CR>
inoremap <Esc> <Esc>:noh<CR>
vnoremap <Esc> <Esc>:noh<CR>
nmap <C-S-O> <Action>(IdeaVim.ReloadVimRc.reload) :noh<CR>a<BS><Esc>
" Move text up and down.
" nnoremap <A-Up> :m .-2<CR>==
" nnoremap <A-Down> :m .+1<CR>==
" inoremap <A-Up> <Esc>:m .-2<CR>==gi
" inoremap <A-Down> <Esc>:m .+1<CR>==gi
" NOTE It's not the same as using Vim's Ex-commands.
nmap <A-Up> <Action>(MoveStatementUp)
nmap <A-Down> <Action>(MoveStatementDown)
imap <A-Up> <Action>(MoveStatementUp)
imap <A-Down> <Action>(MoveStatementDown)
vmap <A-Up> <Action>(MoveStatementUp)
vmap <A-Down> <Action>(MoveStatementDown)
" Go to declaration/file.
nmap gd <Action>(GotoDeclaration)
" Fuzzy file search.
nmap <Leader>f <Action>(GotoFile)
" Lint (Ctrl + Alt + L).
nmap <Leader>l <Action>(ReformatCode)
" Rename (Shift + F6).
nmap <Leader>r <Action>(RenameElement)
" Close/reopen content (current tab, content window, etc).
nmap <Leader>q <Action>(CloseContent)
nmap <Leader>Q <Action>(ReopenClosedTab)
nmap Q <Action>(CloseAllEditors)
" Splits.
" Vertical split.
nmap <Leader>v <Action>(SplitVertically)
" Horizontal split.
nmap <Leader>h <Action>(SplitHorizontally)
" For better `.ideavimrc` reloading.
nmap <Leader>i :action RestartIde<CR>
" Emulate `tpope/vim-unimpaired`'s mappings `[<Space>` and `]<Space>`.
nnoremap [<Space> O<Esc>j
nnoremap ]<Space> o<Esc>k
" Line text-objects.
nnoremap yil ^vg_y
vnoremap il ^og_
" Write and save file (needed for `Editorconfig` plugin).
nnoremap <Leader>w :w<CR>
" Very useful menu.
nmap gh <Action>(RecentFiles)