1
0
mirror of https://github.com/chylex/dotfiles.git synced 2026-05-03 03:32:08 +02:00
Files
dotfiles/.ideavimrc

353 lines
8.7 KiB
Plaintext

set clipboard-=ideaput
set hlsearch
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-e> a:vim
sethandler <A-h> a:vim
sethandler <A-j> a:vim
sethandler <A-k> a:vim
sethandler <A-l> a:vim
sethandler <A-m> a:vim
sethandler <A-n> a:vim
sethandler <A-o> a:vim
sethandler <A-p> a:vim
sethandler <A-S-b> a:vim
sethandler <A-S-e> a:vim
sethandler <A-S-h> a:vim
sethandler <A-S-j> a:vim
sethandler <A-S-k> a:vim
sethandler <A-S-l> a:vim
sethandler <A-S-m> a:vim
sethandler <A-S-o> a:vim
sethandler <A-v> a:vim
sethandler <A-x> a:vim
sethandler <C-A-S-d> a:vim
sethandler <C-A-S-s> 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-S-w> a:vim
sethandler <C-u> a:vim
sethandler <D-S-d> a:vim
sethandler <D-S-s> a:vim
sethandler <S-BS> a:vim
sethandler <C-Enter> a:vim
sethandler <D-Enter> a:vim
sethandler <C-Left> a:vim
sethandler <S-Left> a:vim
sethandler <C-Right> a:vim
sethandler <S-Right> a:vim
if &ide =~? 'rider'
" These shortcuts are broken in Rider for some reason...
sethandler <A-S-H> a:ide
sethandler <A-S-L> a:ide
endif
" 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
map ů %
nnoremap ú @@
noremap , +
noremap § `
noremap §§ ``
nnoremap m§ m
sunmap ů
sunmap §
" Enter visual block mode
map <A-v> <C-v>
" Navigate camel humps
noremap L [w
noremap H [b
nnoremap L [w
nnoremap H [b
" Navigate to end of previous word
noremap <A-e> ge
noremap <A-S-e> gE
" Navigate unmatched parentheses/braces
noremap g( [(
noremap g) ])
noremap g{ [{
noremap g} ]}
" Edit from cursor to start/end of parenthesized block
nnoremap c) c])
nnoremap d) d])
nnoremap c( c[((
nnoremap d( c[((<Esc>l
" Create lines
nnoremap go o<Esc>$
nnoremap gO O<Esc>$
nnoremap g<CR> i<CR><Left><Esc>
" Edit current line
nnoremap C cc
xnoremap C cc
nnoremap D dd
xnoremap D dd
nnoremap < <<
nnoremap > >>
" Indent keeping selection
xnoremap < <gv
xnoremap > >gv
xnoremap = =gv
" Extend selection
map <A-m> <Action>(EditorSelectWord)
map <A-S-m> <Action>(EditorUnSelectWord)
" 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
" Clear search highlights
nnoremap <Esc> :nohlsearch<Return><Esc>
" Code completion
if &ide !~? 'rider'
imap <expr> ! pumvisible() ? '<Action>(EditorChooseLookupItem)<Esc>mzF.bi!<Esc>`zla' : '!'
endif
" Show parameter info
nmap <A-p> <Action>(ParameterInfo)
imap <A-p> <Action>(ParameterInfo)
" Navigate back/forward
map <BS> <Action>(Back)
map <S-BS> <Action>(Forward)
" Navigate inspection highlights
map ( <Action>(GotoPreviousError)
map ) <Action>(GotoNextError)
map <C-A-S-s> <Action>(KM.GotoPreviousErrorInOtherMode)
map <D-S-s> <Action>(KM.GotoPreviousErrorInOtherMode)
map <C-A-S-d> <Action>(KM.GotoNextErrorInOtherMode)
map <D-S-d> <Action>(KM.GotoNextErrorInOtherMode)
" Navigate to previous/next method
map [ <Action>(MethodUp)
map ] <Action>(MethodDown)
" Navigate paragraphs at indentation
map { <Plug>(ParagraphPrevMotion)$
map } <Plug>(ParagraphNextMotion)$
" Move statement/element
map <A-S-h> <Action>(MoveElementLeft)
map <A-S-l> <Action>(MoveElementRight)
map <A-S-j> <Action>(MoveStatementDown)
map <A-S-k> <Action>(MoveStatementUp)
" Multiple carets
map <expr> <A-j> pumvisible() ? '<Action>(EditorDown)' : '<Action>(EditorCloneCaretBelow)'
map <expr> <A-k> pumvisible() ? '<Action>(EditorUp)' : '<Action>(EditorCloneCaretAbove)'
imap <expr> <A-j> pumvisible() ? '<Action>(EditorDown)' : '<Action>(EditorCloneCaretBelow)'
imap <expr> <A-k> pumvisible() ? '<Action>(EditorUp)' : '<Action>(EditorCloneCaretAbove)'
xmap gl <Action>(EditorAddCaretPerSelectedLine)
" 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)
map <C-w>p <Action>(PinActiveEditorTab)
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
noremap g] ]
noremap g[ [
nnoremap M m
nnoremap Z z
" Repurpose 'Enter' for statement completion ('isactionenabled' requires a custom version of IdeaVIM)
nmap <Enter> <Action>(EditorCompleteStatement)
imap <expr> <C-Enter> isactionenabled('Console.Jdbc.Execute')? '<Action>(Console.Jdbc.Execute)' : '<Action>(EditorCompleteStatement)'
imap <expr> <D-Enter> isactionenabled('Console.Jdbc.Execute')? '<Action>(Console.Jdbc.Execute)' : '<Action>(EditorCompleteStatement)'
nmap <C-Enter> <Action>(Console.Jdbc.Execute)
nmap <D-Enter> <Action>(Console.Jdbc.Execute)
vmap <C-Enter> <Action>(Console.Jdbc.Execute)
vmap <D-Enter> <Action>(Console.Jdbc.Execute)
" Repurpose 'g' for navigation (VimJumpToSource requires a custom version of IdeaVIM)
map gb <Action>(GotoNextBookmark)
map gB <Action>(GotoPreviousBookmark)
map gD <Action>(GotoTypeDeclaration)
map ge <Action>(VcsShowNextChangeMarker)
map gE <Action>(VcsShowPrevChangeMarker)
map gf <Action>(VimJumpToSource)<Action>(HideActiveWindow)
map gi <Action>(GotoImplementation)
map gr <Action>(RecentLocations)
map gR <Action>(RecentChangedFiles)
map gs <Action>(GotoSuperMethod)
map gS <Action>(ShowSiblings)
map gt gg<Action>(KM.GotoNextTypeInFile)
map gT <Action>(KM.GotoNextTypeInFile)
map gu <Action>(ShowUsages)
map gU <Action>(FindUsages)
" Repurpose 'z' for view actions and debugger
map za <Action>(Annotate)
map zb <Action>(ViewBreakpoints)
map zc <Action>(EditorContextInfo)
map zd <Action>(CompareClipboardWithSelection)
map ze <Action>(ShowErrorDescription)
map zf <Action>(SelectInProjectView)
map zi <Action>(ShowHoverInfo)
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)
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)
" Repurpose 'm' for refactoring
map mc <Action>(IntroduceConstant)
map md <Action>(SafeDelete)
map me <Action>(Move)
map mf <Action>(IntroduceField)
map mg <Action>(Generate)
map mi <Action>(Inline)
map mm <Action>(ExtractMethod)
map mM <Action>(ExtractFunction)
map mn <Action>(RenameElement)
map mo <Action>(OverrideMethods)
map mp <Action>(IntroduceParameter)
map mP <Action>(IntroduceProperty)
map mr <Action>(Refactorings.QuickListPopupAction)
map ms <Action>(ChangeSignature)
map mS <Action>(NewScratchFile)
map mt <Action>(InsertLiveTemplate)
map mv <Action>(IntroduceVariable)
map 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)