From 317950a3b6af900031db32b9e9e74723dce59e19 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Tue, 8 Aug 2023 14:02:22 +0200 Subject: Updating folder configuration to use .config --- vim/keymaps.vim | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 vim/keymaps.vim (limited to 'vim/keymaps.vim') diff --git a/vim/keymaps.vim b/vim/keymaps.vim new file mode 100644 index 0000000..19cee2e --- /dev/null +++ b/vim/keymaps.vim @@ -0,0 +1,179 @@ +""""""""""""""""""""""""""""" +" Keymaps +""""""""""""""""""""""""""""" + +let g:mapleader = "\" +let g:maplocalleader = ',' +nnoremap :WhichKey '' +nnoremap :WhichKey ',' + + +"""""""""""""""""""" +" Window movement +"""""""""""""""""""" + +" Go to the bottom window +noremap j + +" Go to the top window +noremap k + +" Go to the right window +noremap l + +" Go to the left window +noremap h + +"""""""""""""""""""""""" +" Remove highlighting +"""""""""""""""""""""""" + +nnoremap hl :nohlsearch + +" Save file +nnoremap :w! + +"""""""""""""""""""""""""" +" Buffer +""""""""""""""""""""""""" + +" Close the current buffer +noremap bd :Bclose:tabclosegT + +" Close all the buffers +noremap ba :bufdo bd + +" Go to the next buffer +noremap bn :bnext + +" Go to the previous buffer +noremap bp :bprevious + +"""""""""""""""""""""""""""" +" Tabs +""""""""""""""""""""""""""" + +" Open a new tab +noremap tn :tabnew + +" Close all others tab +noremap to :tabonly + +" Close current tab page +noremap tc :tabclose + +" Move tabs after another +noremap tm :tabmove + +" Go to the next tab +noremap t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nnoremap tl :exe "tabn ".g:lasttab +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 +noremap te :tabedit =escape(expand("%:p:h"), " ")/ + +" Switch CWD to the directory of the open buffer +noremap cd :cd %:p:h:pwd + +" 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 + +"""""""""""""""""""""""" +" Fern +""""""""""""""""""""""" + +" Toggle fern tree view +nnoremap :Fern %:h -drawer -width=35 -toggle + +"""""""""""""""""""" +" GitGutter +"""""""""""""""""""" + +let g:gitgutter_enabled=1 " Enable by default gitgutter + +" Go to the previous hunk +nnoremap hp (GitGutterPrevHunk) + +" Go to the next hunk +nnoremap hn (GitGutterNextHunk) + +" Enable / Disable GitGutter +nnoremap ht (GitGutterToggle) + +" Stage Hunk in Git +nnoremap hs (GitGutterStageHunk) + +" Undo Hunk +nnoremap hu (GitGutterUndoHunk) + +" Preview Hunk +nnoremap hP :GitGutterPreviewHunk + +" Always show the status line +set laststatus=2 + +""""""""""""""""""""" +" Spell +""""""""""""""""""""" + +" Toggle and untoggle spell checking +noremap ss :setlocal spell! + +" Next word to spellcheck +noremap sn ]s + +" Previous word to spellcheck +noremap sp [s + +" Add word into the spellcheck dictionnary +noremap sa zg + +" show the list of alternatives for the word +noremap s? z= + +""""""""""""""""""" +" LSP +""""""""""""""""""" + +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" + +" Go to definition +nnoremap ld :LspDefinition + +" Go next diagnostic +nnoremap lnd :LspNextDiagnostic + +" Go previous diagnostic +nnoremap lpd :LspPreviousDiagnostic + +" Go to reference +nnoremap lf :LspReferences + +" Rename object +nnoremap lr :LspRename + +" LSP stop server +nnoremap ls :LspStopServer + +" peek definition of object +nnoremap lp :LspPeekDefinition + +" Code Action +nnoremap la :LspCodeAction + +" Hover information +nnoremap lh :LspHover + -- cgit v1.2.3