1
0
Fork 0
dotfiles/.ideavimrc

284 lines
6.8 KiB
Plaintext

set ignorecase
set incsearch
set number
set nrformats-=octal
set relativenumber
set scrolloff=999
set showcmd
set showmode
set sidescrolloff=999
set smartcase
set virtualedit=onemore
set visualbell
" Use WSL bash as shell
if has('win32')
set shell=bash.exe
set shellcmdflag=-lic
set shellxquote=
endif
" Configure IDEA settings (https://github.com/JetBrains/ideavim/wiki/set-commands)
set ideajoin
set idearefactormode=visual
" Configure IDE keybindings (https://github.com/JetBrains/ideavim/wiki/sethandler)
sethandler <C-A> a:ide
sethandler <C-B> a:ide
sethandler <C-C> a:ide
sethandler <C-E> a:ide
sethandler <C-F> a:ide
sethandler <C-G> a:ide
sethandler <C-H> a:ide
sethandler <C-I> a:ide
sethandler <C-J> a:ide
sethandler <C-K> a:ide
sethandler <C-L> a:ide
sethandler <C-M> a:ide
sethandler <C-R> a:ide
sethandler <C-S> a:ide
sethandler <C-T> a:ide
sethandler <C-V> a:ide
sethandler <C-W> a:ide
sethandler <C-X> a:ide
sethandler <C-Y> a:ide
sethandler <C-\> a:ide
sethandler <A-B> a:vim
sethandler <A-H> a:vim
sethandler <A-L> a:vim
sethandler <A-N> a:vim
sethandler <A-P> a:vim
sethandler <A-S-B> a:vim
sethandler <A-V> a:vim
sethandler <A-X> a:vim
sethandler <C-D> a:vim
sethandler <C-I> a:vim
sethandler <C-N> a:vim
sethandler <C-O> a:vim
sethandler <C-P> a:vim
sethandler <C-U> a:vim
sethandler <C-S-W> a:vim
sethandler <S-BS> a:vim
" Enable plugins (https://github.com/JetBrains/ideavim/wiki/IdeaVim-Plugins)
Plug 'argtextobj.vim'
Plug 'vim-exchange'
Plug 'vim-highlightedyank'
Plug 'vim-indent-object'
Plug 'vim-matchit'
Plug 'vim-multiple-cursors'
Plug 'vim-paragraph-motion'
Plug 'vim-surround'
Plug 'vim-textobj-entire'
" https://vimhelp.org/index.txt.html
" Map top row on Czech keyboard layout to digits
map + 1
map ě 2
map š 3
map č 4
map ř 5
map ž 6
map ý 7
map á 8
map í 9
map é 0
" Move some commands closer on Czech keyboard layout
nnoremap ú @@
noremap § ;
map ů %
map gů g%
" Camel humps
noremap L [w
noremap H [b
xnoremap L ]w
xnoremap H ]b
" Navigate to end of previous word
noremap <A-b> ge
noremap <A-S-b> gE
" Increment/decrement numbers
noremap <Bar>+ <C-a>
noremap <Bar>- <C-x>
" Edit from cursor to start/end of parenthesized block
nnoremap c) c])
nnoremap d) d])
nnoremap c( c[((
nnoremap d( c[((<ESC>l
" Delete lines
nnoremap C cc
xnoremap C cc
nnoremap D dd
xnoremap D dd
" Enter visual block mode
map <A-v> <C-V>
" Indent keeping selection
xnoremap < <gv
xnoremap > >gv
xnoremap = =gv
" Turn capital letters into opposite actions
" nnoremap U :redo<CR> " Handled by custom version of IdeaVIM
" Reselect pasted text
nnoremap gp `[v`]
" Put without yank
xnoremap p P
xnoremap P p
" Extend/shrink selection
xmap + <Action>(EditorSelectWord)
xmap - <Action>(EditorUnSelectWord)
" Show parameter info
nmap <A-p> <Action>(ParameterInfo)
imap <A-p> <Action>(ParameterInfo)
" Navigate back/forward
nmap <BS> <Action>(Back)
nmap <S-BS> <Action>(Forward)
" Navigate inspection highlights
nmap ( <Action>(GotoPreviousError)
nmap ) <Action>(GotoNextError)
" Navigate to previous/next method
nmap [[ <Action>(MethodUp)
nmap ]] <Action>(MethodDown)
" Navigate paragraphs at indentation
map { <Plug>(ParagraphPrevMotion)$
map } <Plug>(ParagraphNextMotion)$
" Manage editor tabs
map <C-w>m <Action>(MoveEditorToOppositeTabGroup)
map <C-w>s <Action>(MoveTabDown)
map <C-w>u <Action>(Unsplit)
map <C-w>U <Action>(UnsplitAll)
map <C-w>v <Action>(MoveTabRight)
noremap <C-w>S <C-w>s
noremap <C-w>V <C-w>v
map <C-w><C-w>a <Action>(CloseAllEditors)
map <C-w><C-w>h <Action>(CloseAllToTheLeft)
map <C-w><C-w>l <Action>(CloseAllToTheRight)
map <C-w><C-w>o <Action>(CloseAllEditorsButActive)
map \\ <C-w>
map \\\\ <C-w><C-w>
" Rebind repurposed commands
nnoremap M m
nnoremap Z z
" Repurpose 'Enter' for statement completion
nmap <Enter> <Action>(EditorCompleteStatement)
" Repurpose 'g' for navigation (VimJumpToSource requires a custom version of IdeaVIM)
nmap gb <Action>(GotoNextBookmark)
nmap gB <Action>(GotoPreviousBookmark)
nmap gD <Action>(GotoTypeDeclaration)
nmap ge <Action>(VcsShowNextChangeMarker)
nmap gE <Action>(VcsShowPrevChangeMarker)
nmap gf <Action>(VimJumpToSource)<Action>(HideActiveWindow)
nmap gi <Action>(GotoImplementation)
map gj <Action>(EditorCloneCaretBelow)
map gk <Action>(EditorCloneCaretAbove)
nmap gr <Action>(RecentLocations)
nmap gR <Action>(RecentChangedFiles)
nmap gs <Action>(GotoSuperMethod)
nmap gS <Action>(ShowSiblings)
map gt gg<Action>(KM.GotoNextTypeInFile)
map gT <Action>(KM.GotoNextTypeInFile)
nmap gu <Action>(ShowUsages)
nmap gU <Action>(FindUsages)
nmap g( <Action>(KM.GotoPreviousErrorInOtherMode)
nmap g) <Action>(KM.GotoNextErrorInOtherMode)
" Repurpose 'z' for view actions and debugger
map za <Action>(Annotate)
map zb <Action>(ViewBreakpoints)
map zc <Action>(EditorContextInfo)
map zd <Action>(ShowHoverInfo)
map ze <Action>(ShowErrorDescription)
map zf <Action>(SelectInProjectView)
map zht <Action>(TypeHierarchy)
map zhm <Action>(MethodHierarchy)
if &ide =~? 'rider'
map zhc <Action>(RiderShowIncomingCalls)
else
map zhc <Action>(CallHierarchy)
endif
nmap zhl <Action>(LocalHistory.ShowHistory)
xmap zhl <Action>(LocalHistory.ShowSelectionHistory)
nmap zhg <Action>(Vcs.ShowTabbedFileHistory)
xmap zhg <Action>(Vcs.ShowHistoryForBlock)
map zm <Action>(ShowBookmarks)
map zp <Action>(QuickImplementations)
map zP <Action>(QuickTypeDefinition)
map zr <Action>(RunToCursor)
map zR <Action>(ForceRunToCursor)
map zs <Action>(osmedile.intellij.stringmanip.PopupChoiceAction)
map zt <Action>(ExpressionTypeInfo)
map zx <Action>(EvaluateExpression)
" Repurpose 'm' for refactoring (normal mode)
nmap md <Action>(SafeDelete)
nmap me <Action>(Move)
nmap mg <Action>(Generate)
nmap mi <Action>(Inline)
nmap mn <Action>(RenameElement)
nmap mo <Action>(OverrideMethods)
nmap ms <Action>(ChangeSignature)
nmap mS <Action>(NewScratchFile)
" Repurpose 'm' for refactoring (normal / visual mode)
nmap mc <Action>(IntroduceConstant)
xmap mc <Action>(IntroduceConstant)
nmap mf <Action>(IntroduceField)
xmap mf <Action>(IntroduceField)
nmap mm <Action>(ExtractMethod)
xmap mm <Action>(ExtractMethod)
nmap mM <Action>(ExtractFunction)
xmap mM <Action>(ExtractFunction)
nmap mp <Action>(IntroduceParameter)
xmap mp <Action>(IntroduceParameter)
nmap mP <Action>(IntroduceProperty)
xmap mP <Action>(IntroduceProperty)
nmap mr <Action>(Refactorings.QuickListPopupAction)
xmap mr <Action>(Refactorings.QuickListPopupAction)
nmap mt <Action>(InsertLiveTemplate)
xmap mt <Action>(SurroundWithLiveTemplate)
nmap mv <Action>(IntroduceVariable)
xmap mv <Action>(IntroduceVariable)
nmap mw <Action>(SurroundWith)
xmap mw <Action>(SurroundWith)
" Remap NERDTree bindings
let g:NERDTreeMapOpenVSplit = 'v'
let g:NERDTreeMapPreviewVSplit = 'gv'
let g:NERDTreeMapOpenSplit = 's'
let g:NERDTreeMapPreviewSplit = 'gs'
" Actions for custom version of AceJump
set acejump
map <Space> <Action>(AceVimAction_JumpAllEditors)
map g<Space> <Action>(AceVimAction_JumpAllEditors_GoToDeclaration)