feat(vim): Better IdeaVIM and VIM configs

- IdeaVIM: List all JB and IdeaVIM shortcut mappings explicitly
- IdeaVIM: More plugins
- IdeaVIM: Plugins reconfigured to be as similiar to NeoVIM as possible
- IdeaVIM: Keymapping updated to be as similar to NeoVIM as possible
- JetBrains: Added JB keymap copies to repo
- VIM: Plugin specific keymaps moved to plugin_config.vim
- VIM: New plugins: vim-exchange, quickscope, vim-visual-multi
This commit is contained in:
Pratik Tripathy
2024-07-12 22:26:33 +05:30
parent 1094014803
commit 6690831bc5
11 changed files with 282 additions and 116 deletions

View File

@@ -0,0 +1,3 @@
Create a script that
- links keymaps in each subfolder
- To the _Latest_ corresponding product folder in ~/.config/JetBrains

View File

@@ -0,0 +1,17 @@
<keymap version="1" name="Sublime Text (macOS) copy" parent="Sublime Text (Mac OS X)">
<action id="ActivateTerminalToolWindow">
<keyboard-shortcut first-keystroke="alt f12" />
<keyboard-shortcut first-keystroke="shift f1" />
</action>
<action id="RenameElement">
<keyboard-shortcut first-keystroke="shift f6" />
<keyboard-shortcut first-keystroke="f2" />
</action>
<action id="RenameFile">
<keyboard-shortcut first-keystroke="f2" />
</action>
<action id="RenameProject">
<keyboard-shortcut first-keystroke="f2" />
</action>
<action id="ShowContent" />
</keymap>

View File

@@ -0,0 +1,74 @@
<keymap version="1" name="Sublime Text copy" parent="Sublime Text">
<action id="ActivateTerminalToolWindow">
<keyboard-shortcut first-keystroke="alt f12" />
<keyboard-shortcut first-keystroke="shift f1" />
</action>
<action id="ChooseRunConfiguration">
<keyboard-shortcut first-keystroke="shift alt f10" />
<keyboard-shortcut first-keystroke="f5" />
</action>
<action id="CloseContent">
<keyboard-shortcut first-keystroke="ctrl w" />
</action>
<action id="Documentation.ViewExternal" />
<action id="EditorBackwardParagraph">
<keyboard-shortcut first-keystroke="shift alt p" second-keystroke="p" />
</action>
<action id="EditorCloneCaretAbove">
<keyboard-shortcut first-keystroke="ctrl alt up" />
<keyboard-shortcut first-keystroke="shift alt up" />
</action>
<action id="EditorCloneCaretBelow">
<keyboard-shortcut first-keystroke="ctrl alt down" />
<keyboard-shortcut first-keystroke="shift alt down" />
</action>
<action id="EditorCodeBlockEnd">
<keyboard-shortcut first-keystroke="shift alt b" second-keystroke="e" />
</action>
<action id="EditorCodeBlockStart">
<keyboard-shortcut first-keystroke="shift alt b" second-keystroke="s" />
</action>
<action id="EditorForwardParagraph">
<keyboard-shortcut first-keystroke="shift alt p" second-keystroke="n" />
</action>
<action id="ExternalJavaDoc" />
<action id="ExternalSystem.ProjectRefreshAction" />
<action id="GotoNextError">
<keyboard-shortcut first-keystroke="alt n" />
</action>
<action id="GotoPreviousError">
<keyboard-shortcut first-keystroke="shift alt n" />
</action>
<action id="OpenFile">
<keyboard-shortcut first-keystroke="ctrl o" />
<keyboard-shortcut first-keystroke="shift ctrl o" />
</action>
<action id="Refactorings.QuickListPopupAction">
<keyboard-shortcut first-keystroke="shift ctrl alt t" />
<keyboard-shortcut first-keystroke="shift ctrl alt r" />
</action>
<action id="RenameElement">
<keyboard-shortcut first-keystroke="shift f6" />
<keyboard-shortcut first-keystroke="f2" />
</action>
<action id="ResizeToolWindowDown">
<keyboard-shortcut first-keystroke="ctrl alt down" />
</action>
<action id="ResizeToolWindowLeft">
<keyboard-shortcut first-keystroke="ctrl alt left" />
</action>
<action id="ResizeToolWindowRight">
<keyboard-shortcut first-keystroke="ctrl alt right" />
</action>
<action id="ResizeToolWindowUp">
<keyboard-shortcut first-keystroke="ctrl alt up" />
</action>
<action id="Run">
<keyboard-shortcut first-keystroke="shift f10" />
<keyboard-shortcut first-keystroke="f6" />
</action>
<action id="Terminal.CloseTab" />
<action id="VimPluginToggle">
<keyboard-shortcut first-keystroke="shift meta v" />
</action>
</keymap>

View File

@@ -0,0 +1,19 @@
<keymap version="1" name="VSCode copy" parent="VSCode">
<action id="ActivateTerminalToolWindow">
<keyboard-shortcut first-keystroke="ctrl back_quote" />
<keyboard-shortcut first-keystroke="shift f1" />
</action>
<action id="EditorDown">
<keyboard-shortcut first-keystroke="down" />
<keyboard-shortcut first-keystroke="alt n" />
</action>
<action id="EditorUp">
<keyboard-shortcut first-keystroke="up" />
<keyboard-shortcut first-keystroke="alt p" />
</action>
<action id="ExternalJavaDoc" />
<action id="ShowIntentionActions">
<keyboard-shortcut first-keystroke="ctrl period" />
<keyboard-shortcut first-keystroke="shift ctrl period" />
</action>
</keymap>

View File

@@ -0,0 +1,6 @@
<keymap version="1" name="macOS copy" parent="Mac OS X 10.5+">
<action id="ActivateTerminalToolWindow">
<keyboard-shortcut first-keystroke="alt f12" />
<keyboard-shortcut first-keystroke="shift f1" />
</action>
</keymap>

View File

@@ -3,88 +3,89 @@
" Examples to map IDE actions to IdeaVim -- https://jb.gg/abva4t
" Enable IdeaVim plugins https://jb.gg/ideavim-plugins
"source ~/.vimrc
" FIX: "u" appears randomly when deleting words and other times
" TODO: Keep the mappings same across Neovim & Idea
" Keymap structure:
" b+: [B]buffer Operations
" c+: [C]oding Stuff
" d+: [D]iagnostics
" f+: [F]ile Operations
" g+: [G]it Operations
" l+: [L]ist Things
" n+: [N]eoVim Stuff
" s+: Grep/[S]earch Things
" t+: [T]est runner stuff
" x+: close/dismiss something
" e: explorer
" j: EasyMotion jump
" p: Paste from system clipboard
" y: Copy selected stuff to system clipboard
" u: Open undo-tree side-panel
" v: Open document symbol explorer
" FIX: Macros does NOT work
" TODO: Add Jetbrains shortcut-config-file to dotfiles repo
" Resolve Shortcut conflicts with Jetbrains
sethandler <S-Tab> a:vim
sethandler <C-S-CR> a:vim
sethandler <C-6> a:vim
sethandler <C-;> a:vim
sethandler <C-S-;> a:vim
sethandler <C-A> a:vim
sethandler <C-B> a:vim
sethandler <C-C> a:vim
sethandler <C-D> a:vim
sethandler <C-E> a:vim
sethandler <C-F> a:ide
sethandler <C-G> a:vim
sethandler <C-H> a:vim
sethandler <C-I> a:vim
sethandler <C-J> a:vim
sethandler <C-K> a:vim
sethandler <C-L> a:vim
sethandler <C-N> a:vim
sethandler <A-N> a:ide
sethandler <C-O> a:vim
sethandler <C-P> a:ide
sethandler <C-R> a:vim
sethandler <C-S> a:ide
sethandler <C-T> a:vim
sethandler <C-U> a:vim
sethandler <C-V> a:vim
sethandler <C-W> a:vim
sethandler <C-X> a:vim
sethandler <C-Y> a:vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
source ~/.vim/configs.vim
source ~/.vim/key_maps.vim
source ~/.vim/plugin_config.vim
" Because :noh does not work in Jetbrains
nnoremap <esc> <esc>
inoremap <esc> <esc>
" Set Tabs to 4 characters
set expandtab
set tabstop=4
set shiftwidth=4
" Searches
set hlsearch ignorecase smartcase incsearch wrapscan
" Common settings
set gdefault " substitute all occurrences in line
set clipboard^=unnamed,unnamedplus,ideaput " Copy to and from system clipboard
"set ideavimsupport=+singleline,dialog
set showmode
set idearefactormode=keep
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enabled plugins
set ideajoin quickscope
Plug "easymotion/vim-easymotion" " <leader>j or J [2 characters]
Plug "preservim/nerdtree" " <leader>e
Plug "tpope/vim-surround" " ys or cs or ds [motion]
Plug "tpope/vim-commentary" " gc [motion]
Plug "machakann/vim-highlightedyank"
Plug "dbakker/vim-paragraph-motion"
Plug "chrisbra/matchit"
Plug "tpope/vim-repeat" " Repeat for Surround
Plug "vim-indent-object" " Select indent with ai, ii, aI, iI
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set commentary " gc [motion]
set easymotion " <leader>j
set exchange " cx[motion] 2 times, cxc <- cancel exchange
set highlightedyank
set indent-object " ai, ii, aI, iI <- Select indent
set quickscope
set paragraph-motion
set matchit
set multiple-cursors
set nerdtree " <leader>e
set repeat
set surround " ys or cs or ds [motion]
set textobj-entire " yae, cae, dae <- operates on entire file
set ReplaceWithRegister
" Map <leader>d to start debug
"map <leader>d <Action>(Debug)
" Map \b to toggle breakpoint
"map \b <Action>(ToggleLineBreakpoint)
" IdeaVIM specific plugins
set argtextobj " vaa, caa, daa <- Works on function args
let g:argtextobj_pairs="[:],(:),<:>"
set ideajoin
set ideamarks " m[A-Z] <- sets marks
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""" SHORTCUTS """""""""""""""""""""""""
" Easy Motion
map <leader>j <Plug>(easymotion-s)
" Multiple Cursors
map mc <A-n>
map mx <A-x>
map mp <A-p>
nmap <C-n> <Plug>NextWholeOccurrence
xmap <C-n> <Plug>NextWholeOccurrence
nmap g<C-n> <Plug>NextOccurrence
xmap g<C-n> <Plug>NextOccurrence
xmap <C-x> <Plug>SkipOccurrence
xmap <C-p> <Plug>RemoveOccurrence
" Find/Open file
nmap <leader>of :action GotoFile<CR>
nmap <leader>or :action RecentFiles<CR>
" Find/Navigate to different parts of code
nmap <leader>gf :action FindInPath<CR>
nmap <leader>gr :action ShowUsages<CR>
nmap <leader>gi :action GotoImplementation<CR>
nmap <leader>gs :action GotoSuperMethod<CR>
" Tabs
nmap <leader>tn :action NextTab<CR>
nmap <leader>tp :action PreviousTab<CR>
" NerdTree
nmap <leader>e :NERDTreeToggle<CR>
" NerdTree """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>e :NERDTreeToggle<cr>
" When in the tree use the below default keybindings
" j, k - To go down and up
" p - Go to the parent directory
@@ -99,24 +100,66 @@ nmap <leader>e :NERDTreeToggle<CR>
" A - expand the file tree
" x - close the file tree
nmap <C-p> :action ParameterInfo<CR>
imap <C-p> <C-o>:action ParameterInfo<CR>
nmap <leader>n :action GotoNextError<CR>
map gh <Action>(ShowErrorDescription)
" File Navigation """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>ls :action Switcher<cr>
nnoremap <c-p> :action GotoFile<cr>
nnoremap <c-s-enter> :action ActivateTerminalToolWindow<cr>
" Code refactoring
nmap <leader>ri :action Inline<CR>
nmap <leader>rr :action RenameElement<CR>
nmap <leader>rev :action IntroduceVariable<CR>
vmap <leader>rev :action IntroduceVariable<CR>
nmap <leader>rem :action ExtractMethod<CR>
vmap <leader>rem :action ExtractMethod<CR>
nmap <leader>rm :action Move<CR>
nmap <leader>ro :action OptimizeImports<CR>
nmap <leader>rG :action Generate<CR>
nmap <leader>rf :action ReformatCode<CR>
" Code Navigation, Formatting, Others """""""""""""""""""""""""""""""""""""""
nnoremap ]] :action GotoNextElementUnderCaretUsage<cr>
nnoremap [[ :action GotoPrevElementUnderCaretUsage<cr>
nnoremap ]f :action MethodDown<cr>
nnoremap [f :action MethodUp<cr>
nmap <c-o> :action Back<cr>
nmap <c-i> :action Forward<cr>
nnoremap <leader>cS :action GotoSymbol<cr>
noremap <leader>v :action FileStructurePopup<cr>
" Easy motion
map <leader>j <Plug>(easymotion-s)
map == V<Action>(ReformatCode)
nmap <leader>gr :action Vcs.RollbackChangedLines<CR>
nnoremap <leader>cr :action RenameElement<cr>
nnoremap <leader>ca :action ShowIntentionActions<cr>
nnoremap <leader>cR :action FindUsages<cr>
map <C-s> <Action>(ReformatCode) \| <Action>(SaveAll)
" Diagnostics """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>dd :action ActivateProblemsViewToolWindow<cr>
nnoremap <leader>dw :action InspectCode<cr>
nnoremap ]d :action GotoNextError<cr>
nnoremap [d :action GotoPreviousError<cr>
" Git """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>gg :action ActivateCommitToolWindow<cr>
nnoremap <leader>gr :action Vcs.RollbackChangedLines<cr>
nnoremap <leader>gb :action Git.Branches<cr>
nnoremap <leader>gG :action ActivateVersionControlToolWindow<cr>
nnoremap <leader>ga :action Annotate<cr>
nnoremap <leader>gf :action ShowTabbedFileHistory<cr>
nnoremap ]g :action VcsShowNextChangeMarker<cr>
nnoremap [g :action VcsShowPrevChangeMarker<cr>
" List stuff """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>lt :action ActivateTODOToolWindow<cr>
nnoremap <leader>lb :action RecentFiles<cr>
nnoremap <leader>lc :action RecentLocations<cr>
" Search stuff """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>sg :action FindInPath<cr>
nnoremap <leader>sb :action TextSearchAction<cr>
nnoremap <leader>sc :action GotoClass<cr>
" Close stuff """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <leader>xo :action CloseAllEditorsButActive<cr>
nnoremap <leader>z :action ToggleDistractionFreeMode<cr>
nnoremap <leader>/ :nohlsearch<cr>
" Run, debug & test """""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>rd :action Debug<cr>
map <leader>rx :action Run<cr>
map <leader>rs :action Stop<cr>
map <leader>rt :action RunTests<cr>
map <leader>rb :action ToggleLineBreakpoint<cr>
" Split window
nnoremap <c-w>m :action MoveEditorToOppositeTabGroup<CR>
nnoremap <c-w>x :action Unsplit<cr>

View File

@@ -46,7 +46,7 @@ set shiftwidth=4 tabstop=4 softtabstop=4 expandtab smarttab
set autoindent smartindent breakindent " Proper indentation
" Enable searching as you type, rather than waiting till you press enter. Highlight search pattern. Intelligently handle cases in search.
set incsearch hlsearch ignorecase smartcase
set incsearch hlsearch ignorecase smartcase wrapscan
" Comments in Grey color and italic
hi Comment guifg=#5C6370 ctermfg=50 cterm=italic

View File

@@ -119,14 +119,5 @@ nnoremap <leader>/ :nohlsearch<CR>:diffupdate<CR>:normal! <C-L><CR>
" Changes the pwd to the opened file's directory
nnoremap <leader>cd :lcd %:h<CR>
" Map easymotion Plugin to <Leader>j
nnoremap <leader>j <Plug>(easymotion-s)
" Show the undo tree
nnoremap <leader>u :UndotreeToggle<CR>
" Fugitive
nnoremap <leader>gg :0G<cr>
" Close Tab
nnoremap <leader>xt :tabclose

View File

@@ -2,6 +2,15 @@
let g:NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 25
" Map easymotion Plugin to <Leader>j
nnoremap <leader>j <Plug>(easymotion-s)
" Show the undo tree
nnoremap <leader>u :UndotreeToggle<CR>
" Fugitive
nnoremap <leader>gg :0G<cr>
" Quickscope
" Trigger a highlight in the appropriate direction when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']

View File

@@ -1,24 +1,28 @@
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive' "Fugitive Vim GitHub Wrapper
Plug 'tpope/vim-surround' "Surround Plugin
Plug 'tpope/vim-repeat' "Repeat for the surround plugin
Plug 'tpope/vim-commentary' "Comments Plugin
Plug 'tpope/vim-sensible' "Sensible options
Plug 'rstacruz/vim-closer' "Auto-close brackets
Plug 'machakann/vim-highlightedyank' "Highlight Yank
Plug 'dbakker/vim-paragraph-motion' "Paragraph Motion
Plug 'airblade/vim-gitgutter' "Git in the left-side gutter
Plug 'tpope/vim-fugitive' "Fugitive Vim GitHub Wrapper
Plug 'tpope/vim-surround' "Surround Plugin
Plug 'tpope/vim-repeat' "Repeat for the surround plugin
Plug 'tpope/vim-commentary' "Comments Plugin
Plug 'tpope/vim-sensible' "Sensible options
Plug 'rstacruz/vim-closer' "Auto-close brackets
Plug 'machakann/vim-highlightedyank' "Highlight Yank
Plug 'dbakker/vim-paragraph-motion' "Paragraph Motion
Plug 'airblade/vim-gitgutter' "Git in the left-side gutter
Plug 'junegunn/rainbow_parentheses.vim' "Rainbow parenthesis
Plug 'easymotion/vim-easymotion' "Easy Motion to quickly jump across the buffer
Plug 'preservim/nerdtree' "Nerd Tree
Plug 'tpope/vim-obsession' "Obsessions -> saves sessions
Plug 'christoomey/vim-tmux-navigator' "Syncs with Tmux pane navigation keymaps
Plug 'mbbill/undotree' "Show the undo tree
Plug 'easymotion/vim-easymotion' "Easy Motion to quickly jump across the buffer
Plug 'preservim/nerdtree' "Nerd Tree
Plug 'tpope/vim-obsession' "Obsessions -> saves sessions
Plug 'christoomey/vim-tmux-navigator' "Syncs with Tmux pane navigation keymaps
Plug 'mbbill/undotree' "Show the undo tree
Plug 'tommcdo/vim-exchange' " cx{motion} 2 times. cxc <- cancel exchange
Plug 'michaeljsmith/vim-indent-object' " ai, ii, aI, iI <- select indent
Plug 'unblevable/quick-scope' " f, t <- Highlight unique letter on the line
Plug 'mg979/vim-visual-multi' " <Ctrl+n>
"------------Style Plugins------------"
" Status Styles
Plug 'itchyny/lightline.vim'
Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' } "ColorScheme - Challenger-deep
Plug 'cocopon/iceberg.vim' "Color Scheme - Iceberg
Plug 'tyrannicaltoucan/vim-deep-space' "Color Scheme - Deep-space
Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }
Plug 'cocopon/iceberg.vim'
Plug 'tyrannicaltoucan/vim-deep-space'
call plug#end()

View File

@@ -4,15 +4,15 @@ let $VIMRC="$VIMDIR/vimrc"
" Load plugins
source $VIMDIR/plugins.vim
" Load plugin configurations
source $VIMDIR/plugin_config.vim
" Load VIM Configurations
source $VIMDIR/configs.vim
" Load Keybindings
source $VIMDIR/key_maps.vim
" Load plugin configurations
source $VIMDIR/plugin_config.vim
" Load Autocommand
source $VIMDIR/autocommands.vim