- Accommodating Ideavimrc with Jetbrains quirks

- VIM: New useful keymaps created
- VIM: Config refactored for better portability to many NVim distros
- NVim: Trials with LSP Autocompletion failed :(
This commit is contained in:
Pratik Tripathy
2024-01-10 22:03:06 +05:30
parent 44d124735d
commit f9688cf616
12 changed files with 216 additions and 189 deletions

View File

@@ -17,13 +17,13 @@ set cursorline " Hightlight cursor line
set showmatch " Highlight matching braces
set noshowmode " Donot write "--INSERT--" etc.
set showcmd " Write out commands on status line
set ls=2 " Show a status line
set laststatus=2 " Show a status line
set wrap " Wrap text
set number " Show line numbers
set ruler
set relativenumber " Relative line numbers
set shortmess+=I " Disable the default Vim startup message.
set noerrorbells visualbell t_vb= " Disable audible bell because it's annoying.
set noerrorbells novisualbell t_vb= " Disable audible bell because it's annoying.
set mouse+=a " Enable mouse support
set encoding=utf-8 " Encoding
set autoread
@@ -46,6 +46,7 @@ set noswapfile
set undofile
set undolevels=10000
set undoreload=100000
set timeoutlen=500
" Vim, by default, won't let you jump to a different file without saving the
" current one. With the below, unsaved files are just hidden.
@@ -58,8 +59,8 @@ set incsearch hlsearch ignorecase smartcase
hi Comment guifg=#5C6370 ctermfg=50 cterm=italic
" Highlight and remove trailing blank spaces on save
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" highlight ExtraWhitespace ctermbg=red guibg=red
" match ExtraWhitespace /\s\+$/
autocmd BufWritePre * %s/\s\+$//e
" Vim is based on Vi. Setting `nocompatible` switches from the default

View File

@@ -36,28 +36,49 @@ nnoremap N Nzzzv
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Better indenting
vnoremap < <gv
vnoremap > >gv
xnoremap < <gv
xnoremap > >gv
" Keeps the cursor at the same place when doing J
" And not move to end of the line
nnoremap J mzJ`z:delmarks z<CR>
" Better Up/Down
nnoremap j gj
xnoremap j gj
nnoremap k gk
xnoremap k gk
" Better window/split navigation
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-h> <C-w>h
map <C-l> <C-w>l
" Clear searches
nnoremap <leader>/ :call clearmatches()<CR>:noh<CR>
" Navigate buffers
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
" Changes the pwd to the opened file's directory
nnoremap <leader>cd :lcd %:h<CR>
" Resize window using <ctrl> arrow keys
nnoremap <C-Up> :resize +2<CR>
nnoremap <C-Down> :resize -2<CR>
nnoremap <C-Left> :vertical resize -2<CR>
nnoremap <C-Right> :vertical resize +2<CR>
" Map easymotion Plugin to <Leader>j
map <leader>j <Plug>(easymotion-s)
" Saner search n & N
nnoremap <expr> n 'Nn'[v:searchforward]
xnoremap <expr> n 'Nn'[v:searchforward]
onoremap <expr> n 'Nn'[v:searchforward]
nnoremap <expr> N 'nN'[v:searchforward]
xnoremap <expr> N 'nN'[v:searchforward]
onoremap <expr> N 'nN'[v:searchforward]
" Map nerdtree to <Leader>e
" Changes the pwd and opens the VCS root
nnoremap <leader>e :tcd %:h<CR> :NERDTreeToggleVCS<CR>
" Clear search highlights
nnoremap <esc> :nohlsearch<CR><esc>
inoremap <esc> :nohlsearch<CR><esc>
" <ctrl-q> to save everything and quit Neovim
nnoremap <C-q> :wqa<CR>
@@ -65,3 +86,21 @@ vnoremap <C-q> :wqa<CR>
nnoremap <C-s> :wa<CR>
vnoremap <C-s> :wa<CR>
" Move cursor in insert mode
inoremap <C-b> <ESC>^i
inoremap <C-e> <END>
inoremap <C-h> <Left>
inoremap <C-l> <Right>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
" Copy entire content of the current buffer
nnoremap <C-c> :%y+<CR>
" Clear search, diff update and redraw
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 <leader>j <Plug>(easymotion-s)

View File

@@ -33,3 +33,9 @@ autocmd! bufwritepost $VIMRC source %
" Save inside vim config directory
set undodir=$VIMDIR/undo//
" Map easymotion Plugin to <Leader>j
map <leader>j <Plug>(easymotion-s)
" Map nerdtree to <Leader>e
" Changes the pwd and opens the VCS root
nnoremap <leader>e :tcd %:h<CR> :NERDTreeToggleVCS<CR>