diff options
author | Oxbian <got.dacs@slmail.me> | 2023-06-29 23:07:21 +0200 |
---|---|---|
committer | Oxbian <got.dacs@slmail.me> | 2023-06-29 23:07:21 +0200 |
commit | 70a1687c7487bbe7397d1db71e04f4cb2380fc27 (patch) | |
tree | 6675f942fd87dbc32ca17dd2ce4ffb9fcdd11f46 /.vim/keymaps.vim | |
parent | 5c9f71e376c5ca7334aa3d884c34413b2efacb0d (diff) | |
download | vimrc-70a1687c7487bbe7397d1db71e04f4cb2380fc27.tar.gz vimrc-70a1687c7487bbe7397d1db71e04f4cb2380fc27.zip |
Updating lsp settings & documentation
Diffstat (limited to '.vim/keymaps.vim')
-rw-r--r-- | .vim/keymaps.vim | 136 |
1 files changed, 113 insertions, 23 deletions
diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim index 993ef87..eef6409 100644 --- a/.vim/keymaps.vim +++ b/.vim/keymaps.vim @@ -2,46 +2,136 @@ " Keymaps """"""""""""""""""""""""""""" +"""""""""""""""""""" " Window movement +"""""""""""""""""""" + +" Go to the bottom window noremap <C-j> <C-w>j + +" Go to the top window noremap <C-k> <C-w>k + +" Go to the right window noremap <C-l> <C-w>l + +" Go to the left window noremap <C-h> <C-w>h +"""""""""""""""""""""""" " Remove highlighting -nnoremap <leader>h :nohlsearch<CR> +"""""""""""""""""""""""" + +nnoremap <leader>hl :nohlsearch<CR> " Save file nnoremap <C-s> :w!<CR> +"""""""""""""""""""""""""" +" Buffer +""""""""""""""""""""""""" + +" Close the current buffer +map <leader>bd :Bclose<cr>:tabclose<cr>gT + +" Close all the buffers +map <leader>ba :bufdo bd<cr> + +" Go to the next buffer +map <leader>l :bnext<cr> + +" Go to the previous buffer +map <leader>h :bprevious<cr> + +"""""""""""""""""""""""""""" +" Tabs +""""""""""""""""""""""""""" + +" Open a new tab +map <leader>tn :tabnew<cr> + +" Close all others tab +map <leader>to :tabonly<cr> + +" Close current tab page +map <leader>tc :tabclose<cr> + +" Move tabs after another +map <leader>tm :tabmove + +" Go to the next tab +map <leader>t<leader> :tabnext<cr> + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nmap <leader>tl :exe "tabn ".g:lasttab<CR> +au TabLeave * let g:lasttab = tabpagenr() + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +map <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/ + +" Switch CWD to the directory of the open buffer +map <leader>cd :cd %:p:h<cr>:pwd<cr> + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +"""""""""""""""""""""""" " NerdTree +""""""""""""""""""""""" + +" Toggle nerdtree nnoremap <C-f> :NERDTreeToggle<CR> +"""""""""""""""""""" " GitGutter +"""""""""""""""""""" let g:gitgutter_enabled=1 " Enable by default gitgutter -nnoremap <leader>d :GitGutterToggle<CR> + +" Enable / Disable GitGutter +nnoremap <leader>d :GitGutterToggle<CR> + +" Stage Hunk in Git nnoremap <leader>hs :GitGutterStageHunk<CR> + +" Undo Hunk nnoremap <leader>hu :GitGutterUndoHunk<CR> + +" Preview Hunk nnoremap <leader>hp :GitGutterPreviewHunk<CR> -" Vsnip -" Expand -imap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>' -smap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>' - -" Expand or jump -imap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>' -smap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>' - -" Jump forward or backward -imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' -smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' -imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' -smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' - -" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet. -" See https://github.com/hrsh7th/vim-vsnip/pull/50 -nmap s <Plug>(vsnip-select-text) -xmap s <Plug>(vsnip-select-text) -nmap S <Plug>(vsnip-cut-text) -xmap S <Plug>(vsnip-cut-text) +" Always show the status line +set laststatus=2 + +""""""""""""""""""""" +" Spell +""""""""""""""""""""" + +" Toggle and untoggle spell checking +map <leader>ss :setlocal spell!<cr> + +" Next word to spellcheck +map <leader>sn ]s + +" Previous word to spellcheck +map <leader>sp [s + +" Add word into the spellcheck dictionnary +map <leader>sa zg + +" show the list of alternatives for the word +map <leader>s? z= + +""""""""""""""""""" +" LSP +""""""""""""""""""" +inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>" +inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" |