From 6690831bc5ff59f5261a6f2bfdbb7671dfd3275f Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Fri, 12 Jul 2024 22:26:33 +0530 Subject: [PATCH] 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 --- common/.config/JetBrains/TODO.txt | 3 + .../keymaps/Sublime Text _macOS_ copy.xml | 17 ++ .../keymaps/Sublime Text copy.xml | 74 ++++++ .../WebStorm2024.1/keymaps/VSCode copy.xml | 19 ++ .../WebStorm2024.1/keymaps/macOS copy.xml | 6 + common/.config/ideavim/ideavimrc | 213 +++++++++++------- common/.vim/configs.vim | 2 +- common/.vim/key_maps.vim | 9 - common/.vim/plugin_config.vim | 9 + common/.vim/plugins.vim | 40 ++-- common/.vim/vimrc | 6 +- 11 files changed, 282 insertions(+), 116 deletions(-) create mode 100644 common/.config/JetBrains/TODO.txt create mode 100644 common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text _macOS_ copy.xml create mode 100644 common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text copy.xml create mode 100644 common/.config/JetBrains/WebStorm2024.1/keymaps/VSCode copy.xml create mode 100644 common/.config/JetBrains/WebStorm2024.1/keymaps/macOS copy.xml diff --git a/common/.config/JetBrains/TODO.txt b/common/.config/JetBrains/TODO.txt new file mode 100644 index 0000000..0d2f712 --- /dev/null +++ b/common/.config/JetBrains/TODO.txt @@ -0,0 +1,3 @@ +Create a script that + - links keymaps in each subfolder + - To the _Latest_ corresponding product folder in ~/.config/JetBrains diff --git a/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text _macOS_ copy.xml b/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text _macOS_ copy.xml new file mode 100644 index 0000000..2d2b1b0 --- /dev/null +++ b/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text _macOS_ copy.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text copy.xml b/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text copy.xml new file mode 100644 index 0000000..7ba6a49 --- /dev/null +++ b/common/.config/JetBrains/WebStorm2024.1/keymaps/Sublime Text copy.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/.config/JetBrains/WebStorm2024.1/keymaps/VSCode copy.xml b/common/.config/JetBrains/WebStorm2024.1/keymaps/VSCode copy.xml new file mode 100644 index 0000000..ec09af5 --- /dev/null +++ b/common/.config/JetBrains/WebStorm2024.1/keymaps/VSCode copy.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/.config/JetBrains/WebStorm2024.1/keymaps/macOS copy.xml b/common/.config/JetBrains/WebStorm2024.1/keymaps/macOS copy.xml new file mode 100644 index 0000000..311930e --- /dev/null +++ b/common/.config/JetBrains/WebStorm2024.1/keymaps/macOS copy.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/.config/ideavim/ideavimrc b/common/.config/ideavim/ideavimrc index d2db3fa..a12ce3f 100644 --- a/common/.config/ideavim/ideavimrc +++ b/common/.config/ideavim/ideavimrc @@ -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 a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:ide +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:ide +sethandler a:vim +sethandler a:ide +sethandler a:vim +sethandler a:ide +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim +sethandler a:vim """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" source ~/.vim/configs.vim source ~/.vim/key_maps.vim source ~/.vim/plugin_config.vim -" Because :noh does not work in Jetbrains -nnoremap -inoremap - -" 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" " j or J [2 characters] -Plug "preservim/nerdtree" " 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 " 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 " e +set repeat +set surround " ys or cs or ds [motion] +set textobj-entire " yae, cae, dae <- operates on entire file +set ReplaceWithRegister -" Map d to start debug -"map d (Debug) -" Map \b to toggle breakpoint -"map \b (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 j (easymotion-s) " Multiple Cursors -map mc -map mx -map mp +nmap NextWholeOccurrence +xmap NextWholeOccurrence +nmap g NextOccurrence +xmap g NextOccurrence +xmap SkipOccurrence +xmap RemoveOccurrence -" Find/Open file -nmap of :action GotoFile -nmap or :action RecentFiles - -" Find/Navigate to different parts of code -nmap gf :action FindInPath -nmap gr :action ShowUsages -nmap gi :action GotoImplementation -nmap gs :action GotoSuperMethod - -" Tabs -nmap tn :action NextTab -nmap tp :action PreviousTab - -" NerdTree -nmap e :NERDTreeToggle +" NerdTree """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap e :NERDTreeToggle " 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 e :NERDTreeToggle " A - expand the file tree " x - close the file tree -nmap :action ParameterInfo -imap :action ParameterInfo -nmap n :action GotoNextError -map gh (ShowErrorDescription) +" File Navigation """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap ls :action Switcher +nnoremap :action GotoFile +nnoremap :action ActivateTerminalToolWindow -" Code refactoring -nmap ri :action Inline -nmap rr :action RenameElement -nmap rev :action IntroduceVariable -vmap rev :action IntroduceVariable -nmap rem :action ExtractMethod -vmap rem :action ExtractMethod -nmap rm :action Move -nmap ro :action OptimizeImports -nmap rG :action Generate -nmap rf :action ReformatCode +" Code Navigation, Formatting, Others """"""""""""""""""""""""""""""""""""""" +nnoremap ]] :action GotoNextElementUnderCaretUsage +nnoremap [[ :action GotoPrevElementUnderCaretUsage +nnoremap ]f :action MethodDown +nnoremap [f :action MethodUp +nmap :action Back +nmap :action Forward +nnoremap cS :action GotoSymbol +noremap v :action FileStructurePopup -" Easy motion -map j (easymotion-s) +map == V(ReformatCode) -nmap gr :action Vcs.RollbackChangedLines +nnoremap cr :action RenameElement +nnoremap ca :action ShowIntentionActions +nnoremap cR :action FindUsages +map (ReformatCode) \| (SaveAll) + +" Diagnostics """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap dd :action ActivateProblemsViewToolWindow +nnoremap dw :action InspectCode +nnoremap ]d :action GotoNextError +nnoremap [d :action GotoPreviousError + +" Git """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap gg :action ActivateCommitToolWindow +nnoremap gr :action Vcs.RollbackChangedLines +nnoremap gb :action Git.Branches +nnoremap gG :action ActivateVersionControlToolWindow +nnoremap ga :action Annotate +nnoremap gf :action ShowTabbedFileHistory +nnoremap ]g :action VcsShowNextChangeMarker +nnoremap [g :action VcsShowPrevChangeMarker + +" List stuff """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap lt :action ActivateTODOToolWindow +nnoremap lb :action RecentFiles +nnoremap lc :action RecentLocations + +" Search stuff """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap sg :action FindInPath +nnoremap sb :action TextSearchAction +nnoremap sc :action GotoClass + +" Close stuff """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +nnoremap xo :action CloseAllEditorsButActive +nnoremap z :action ToggleDistractionFreeMode +nnoremap / :nohlsearch + +" Run, debug & test """"""""""""""""""""""""""""""""""""""""""""""""""""""""" +map rd :action Debug +map rx :action Run +map rs :action Stop +map rt :action RunTests +map rb :action ToggleLineBreakpoint + +" Split window +nnoremap m :action MoveEditorToOppositeTabGroup +nnoremap x :action Unsplit diff --git a/common/.vim/configs.vim b/common/.vim/configs.vim index 2e8550e..5b57947 100644 --- a/common/.vim/configs.vim +++ b/common/.vim/configs.vim @@ -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 diff --git a/common/.vim/key_maps.vim b/common/.vim/key_maps.vim index 1cfc5e2..24c2335 100644 --- a/common/.vim/key_maps.vim +++ b/common/.vim/key_maps.vim @@ -119,14 +119,5 @@ nnoremap / :nohlsearch:diffupdate:normal! " Changes the pwd to the opened file's directory nnoremap cd :lcd %:h -" Map easymotion Plugin to j -nnoremap j (easymotion-s) - -" Show the undo tree -nnoremap u :UndotreeToggle - -" Fugitive -nnoremap gg :0G - " Close Tab nnoremap xt :tabclose diff --git a/common/.vim/plugin_config.vim b/common/.vim/plugin_config.vim index c3e4f2b..c53aadb 100644 --- a/common/.vim/plugin_config.vim +++ b/common/.vim/plugin_config.vim @@ -2,6 +2,15 @@ let g:NERDTreeShowHidden = 1 let g:NERDTreeWinSize = 25 +" Map easymotion Plugin to j +nnoremap j (easymotion-s) + +" Show the undo tree +nnoremap u :UndotreeToggle + +" Fugitive +nnoremap gg :0G + " Quickscope " Trigger a highlight in the appropriate direction when pressing these keys: let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] diff --git a/common/.vim/plugins.vim b/common/.vim/plugins.vim index 79ca935..1975127 100644 --- a/common/.vim/plugins.vim +++ b/common/.vim/plugins.vim @@ -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' " + "------------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() - diff --git a/common/.vim/vimrc b/common/.vim/vimrc index de5b264..8fdba50 100644 --- a/common/.vim/vimrc +++ b/common/.vim/vimrc @@ -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