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 " Examples to map IDE actions to IdeaVim -- https://jb.gg/abva4t
" Enable IdeaVim plugins https://jb.gg/ideavim-plugins " Enable IdeaVim plugins https://jb.gg/ideavim-plugins
"source ~/.vimrc " FIX: Macros does NOT work
" FIX: "u" appears randomly when deleting words and other times " TODO: Add Jetbrains shortcut-config-file to dotfiles repo
" TODO: Keep the mappings same across Neovim & Idea
" Keymap structure: " Resolve Shortcut conflicts with Jetbrains
" b+: [B]buffer Operations sethandler <S-Tab> a:vim
" c+: [C]oding Stuff sethandler <C-S-CR> a:vim
" d+: [D]iagnostics sethandler <C-6> a:vim
" f+: [F]ile Operations sethandler <C-;> a:vim
" g+: [G]it Operations sethandler <C-S-;> a:vim
" l+: [L]ist Things sethandler <C-A> a:vim
" n+: [N]eoVim Stuff sethandler <C-B> a:vim
" s+: Grep/[S]earch Things sethandler <C-C> a:vim
" t+: [T]est runner stuff sethandler <C-D> a:vim
" x+: close/dismiss something sethandler <C-E> a:vim
" e: explorer sethandler <C-F> a:ide
" j: EasyMotion jump sethandler <C-G> a:vim
" p: Paste from system clipboard sethandler <C-H> a:vim
" y: Copy selected stuff to system clipboard sethandler <C-I> a:vim
" u: Open undo-tree side-panel sethandler <C-J> a:vim
" v: Open document symbol explorer 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/configs.vim
source ~/.vim/key_maps.vim source ~/.vim/key_maps.vim
source ~/.vim/plugin_config.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 " Common settings
set gdefault " substitute all occurrences in line
set clipboard^=unnamed,unnamedplus,ideaput " Copy to and from system clipboard set clipboard^=unnamed,unnamedplus,ideaput " Copy to and from system clipboard
"set ideavimsupport=+singleline,dialog
set showmode
set idearefactormode=keep
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enabled plugins " Enabled plugins
set ideajoin quickscope set commentary " gc [motion]
Plug "easymotion/vim-easymotion" " <leader>j or J [2 characters] set easymotion " <leader>j
Plug "preservim/nerdtree" " <leader>e set exchange " cx[motion] 2 times, cxc <- cancel exchange
Plug "tpope/vim-surround" " ys or cs or ds [motion] set highlightedyank
Plug "tpope/vim-commentary" " gc [motion] set indent-object " ai, ii, aI, iI <- Select indent
Plug "machakann/vim-highlightedyank" set quickscope
Plug "dbakker/vim-paragraph-motion" set paragraph-motion
Plug "chrisbra/matchit" set matchit
Plug "tpope/vim-repeat" " Repeat for Surround set multiple-cursors
Plug "vim-indent-object" " Select indent with ai, ii, aI, iI 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 " IdeaVIM specific plugins
"map <leader>d <Action>(Debug) set argtextobj " vaa, caa, daa <- Works on function args
" Map \b to toggle breakpoint let g:argtextobj_pairs="[:],(:),<:>"
"map \b <Action>(ToggleLineBreakpoint) set ideajoin
set ideamarks " m[A-Z] <- sets marks
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""" SHORTCUTS """""""""""""""""""""""""
" Easy Motion
map <leader>j <Plug>(easymotion-s)
" Multiple Cursors " Multiple Cursors
map mc <A-n> nmap <C-n> <Plug>NextWholeOccurrence
map mx <A-x> xmap <C-n> <Plug>NextWholeOccurrence
map mp <A-p> 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 " NerdTree """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <leader>of :action GotoFile<CR> nnoremap <leader>e :NERDTreeToggle<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>
" When in the tree use the below default keybindings " When in the tree use the below default keybindings
" j, k - To go down and up " j, k - To go down and up
" p - Go to the parent directory " p - Go to the parent directory
@@ -99,24 +100,66 @@ nmap <leader>e :NERDTreeToggle<CR>
" A - expand the file tree " A - expand the file tree
" x - close the file tree " x - close the file tree
nmap <C-p> :action ParameterInfo<CR> " File Navigation """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
imap <C-p> <C-o>:action ParameterInfo<CR> nnoremap <leader>ls :action Switcher<cr>
nmap <leader>n :action GotoNextError<CR> nnoremap <c-p> :action GotoFile<cr>
map gh <Action>(ShowErrorDescription) nnoremap <c-s-enter> :action ActivateTerminalToolWindow<cr>
" Code refactoring " Code Navigation, Formatting, Others """""""""""""""""""""""""""""""""""""""
nmap <leader>ri :action Inline<CR> nnoremap ]] :action GotoNextElementUnderCaretUsage<cr>
nmap <leader>rr :action RenameElement<CR> nnoremap [[ :action GotoPrevElementUnderCaretUsage<cr>
nmap <leader>rev :action IntroduceVariable<CR> nnoremap ]f :action MethodDown<cr>
vmap <leader>rev :action IntroduceVariable<CR> nnoremap [f :action MethodUp<cr>
nmap <leader>rem :action ExtractMethod<CR> nmap <c-o> :action Back<cr>
vmap <leader>rem :action ExtractMethod<CR> nmap <c-i> :action Forward<cr>
nmap <leader>rm :action Move<CR> nnoremap <leader>cS :action GotoSymbol<cr>
nmap <leader>ro :action OptimizeImports<CR> noremap <leader>v :action FileStructurePopup<cr>
nmap <leader>rG :action Generate<CR>
nmap <leader>rf :action ReformatCode<CR>
" Easy motion map == V<Action>(ReformatCode)
map <leader>j <Plug>(easymotion-s)
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 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. " 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 " Comments in Grey color and italic
hi Comment guifg=#5C6370 ctermfg=50 cterm=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 " Changes the pwd to the opened file's directory
nnoremap <leader>cd :lcd %:h<CR> 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 " Close Tab
nnoremap <leader>xt :tabclose nnoremap <leader>xt :tabclose

View File

@@ -2,6 +2,15 @@
let g:NERDTreeShowHidden = 1 let g:NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 25 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 " Quickscope
" Trigger a highlight in the appropriate direction when pressing these keys: " Trigger a highlight in the appropriate direction when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']

View File

@@ -1,24 +1,28 @@
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive' "Fugitive Vim GitHub Wrapper Plug 'tpope/vim-fugitive' "Fugitive Vim GitHub Wrapper
Plug 'tpope/vim-surround' "Surround Plugin Plug 'tpope/vim-surround' "Surround Plugin
Plug 'tpope/vim-repeat' "Repeat for the surround plugin Plug 'tpope/vim-repeat' "Repeat for the surround plugin
Plug 'tpope/vim-commentary' "Comments Plugin Plug 'tpope/vim-commentary' "Comments Plugin
Plug 'tpope/vim-sensible' "Sensible options Plug 'tpope/vim-sensible' "Sensible options
Plug 'rstacruz/vim-closer' "Auto-close brackets Plug 'rstacruz/vim-closer' "Auto-close brackets
Plug 'machakann/vim-highlightedyank' "Highlight Yank Plug 'machakann/vim-highlightedyank' "Highlight Yank
Plug 'dbakker/vim-paragraph-motion' "Paragraph Motion Plug 'dbakker/vim-paragraph-motion' "Paragraph Motion
Plug 'airblade/vim-gitgutter' "Git in the left-side gutter Plug 'airblade/vim-gitgutter' "Git in the left-side gutter
Plug 'junegunn/rainbow_parentheses.vim' "Rainbow parenthesis Plug 'junegunn/rainbow_parentheses.vim' "Rainbow parenthesis
Plug 'easymotion/vim-easymotion' "Easy Motion to quickly jump across the buffer Plug 'easymotion/vim-easymotion' "Easy Motion to quickly jump across the buffer
Plug 'preservim/nerdtree' "Nerd Tree Plug 'preservim/nerdtree' "Nerd Tree
Plug 'tpope/vim-obsession' "Obsessions -> saves sessions Plug 'tpope/vim-obsession' "Obsessions -> saves sessions
Plug 'christoomey/vim-tmux-navigator' "Syncs with Tmux pane navigation keymaps Plug 'christoomey/vim-tmux-navigator' "Syncs with Tmux pane navigation keymaps
Plug 'mbbill/undotree' "Show the undo tree 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------------" "------------Style Plugins------------"
" Status Styles " Status Styles
Plug 'itchyny/lightline.vim' Plug 'itchyny/lightline.vim'
Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' } "ColorScheme - Challenger-deep Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }
Plug 'cocopon/iceberg.vim' "Color Scheme - Iceberg Plug 'cocopon/iceberg.vim'
Plug 'tyrannicaltoucan/vim-deep-space' "Color Scheme - Deep-space Plug 'tyrannicaltoucan/vim-deep-space'
call plug#end() call plug#end()

View File

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