From e8c1a06d0e63fcf6d383dd3f1be14e4b095466e6 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Sun, 2 Jul 2023 20:39:30 +0200 Subject: Updating vim & documentation --- .vim/keymaps.vim | 40 +++++++++++++++++--- .vim/options.vim | 6 +-- .vim/plugins.vim | 109 ++++++++++++++++++++++++++++++++++++++++++------------- readme.md | 27 +++++++++----- 4 files changed, 139 insertions(+), 43 deletions(-) diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim index 1345178..57f9e8d 100644 --- a/.vim/keymaps.vim +++ b/.vim/keymaps.vim @@ -2,6 +2,12 @@ " Keymaps """"""""""""""""""""""""""""" +let g:mapleader = "\" +let g:maplocalleader = ',' +nnoremap :WhichKey '' +nnoremap :WhichKey ',' + + """""""""""""""""""" " Window movement """""""""""""""""""" @@ -38,10 +44,10 @@ map bd :Bclose:tabclosegT map ba :bufdo bd " Go to the next buffer -map ]b :bnext +map bn :bnext " Go to the previous buffer -map [b :bprevious +map bp :bprevious """""""""""""""""""""""""""" " Tabs @@ -89,18 +95,19 @@ au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g """"""""""""""""""""""" " Toggle nerdtree -nnoremap :NERDTreeToggle +nnoremap :Fern . """""""""""""""""""" " GitGutter """""""""""""""""""" + let g:gitgutter_enabled=1 " Enable by default gitgutter " Go to the previous hunk -nnoremap [h (GitGutterPrevHunk) +nnoremap hp (GitGutterPrevHunk) " Go to the next hunk -nnoremap ]h (GitGutterNextHunk) +nnoremap hn (GitGutterNextHunk) " Enable / Disable GitGutter nnoremap ht (GitGutterToggle) @@ -112,7 +119,7 @@ nnoremap hs (GitGutterStageHunk) nnoremap hu (GitGutterUndoHunk) " Preview Hunk -nnoremap hp :GitGutterPreviewHunk +nnoremap hP :GitGutterPreviewHunk " Always show the status line set laststatus=2 @@ -139,16 +146,37 @@ map 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 + +" Format document nnoremap ldf :LspDocumentFormat + diff --git a/.vim/options.vim b/.vim/options.vim index 431bfc7..353b9a5 100644 --- a/.vim/options.vim +++ b/.vim/options.vim @@ -1,6 +1,3 @@ -" Mapping -let mapleader =" " " Set mapleader - " Search options set incsearch " Search for partial typed match set ignorecase " Search not case sensitive @@ -89,3 +86,6 @@ set ffs=unix,dos,mac set nobackup set nowb set noswapfile + +" Timeout +set timeoutlen=500 diff --git a/.vim/plugins.vim b/.vim/plugins.vim index a98a9d2..53c76aa 100644 --- a/.vim/plugins.vim +++ b/.vim/plugins.vim @@ -17,9 +17,13 @@ call plug#begin('~/.vim/plugged') " UI & Themes Plug 'joshdick/onedark.vim' " Onedark themes for vim Plug 'vim-airline/vim-airline' " Vim statusline -Plug 'preservim/nerdtree' " Filetree in vim -Plug 'ryanoasis/vim-devicons' " Icons for vim -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Syntax in nerdtree for files extension +Plug 'lambdalisue/fern.vim' " Filetree in vim +Plug 'lambdalisue/fern-hijack.vim' " Open directory with fern +Plug 'lambdalisue/fern-renderer-devicons.vim' " Icon in fern +Plug 'ryanoasis/vim-devicons' " Devicons +Plug 'lambdalisue/fern-mapping-git.vim' " Fern git mapping +Plug 'andykog/fern-copynode.vim' " Fern copy node +Plug 'lambdalisue/fern-git-status.vim' " Fern git status Plug 'liuchengxu/vim-which-key' " Show leader mapping cheatsheet " Git integration @@ -45,39 +49,94 @@ if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_symbols.colnr = ' ㏇:' -let g:airline_symbols.colnr = ' β„…:' let g:airline_symbols.crypt = 'πŸ”’' -let g:airline_symbols.linenr = ' ☰' -let g:airline_symbols.linenr = ' ␊:' -let g:airline_symbols.linenr = ' ␀:' let g:airline_symbols.linenr = ' ΒΆ' let g:airline_symbols.maxlinenr = '' -let g:airline_symbols.maxlinenr = ' ㏑' let g:airline_symbols.branch = 'βŽ‡' let g:airline_symbols.paste = 'ρ' -let g:airline_symbols.paste = 'Þ' -let g:airline_symbols.paste = 'βˆ₯' let g:airline_symbols.spell = 'Ꞩ' let g:airline_symbols.notexists = 'Ι†' -let g:airline_symbols.notexists = 'βˆ„' let g:airline_symbols.whitespace = ' Ξ' " VIM lsp let g:lsp_diagnostics_echo_cursor = 1 let g:lsp_diagnostics_virtual_text_enabled = 0 -" NerdTree -let NERDTreeShowHidden=1 " Show hidden files -let NERDTreeQuitOnOpen = 1 " Close a nerdtree after opening the file - -" Close the tab if NERDTree is the only window remaining in it. -autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif - -" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. -autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | - \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif - -" If more than one window and previous buffer was NERDTree, go back to it. -autocmd BufEnter * if bufname('#') =~# "^NERD_tree_" && winnr('$') > 1 | b# | endif - +" Fern +let g:fern#default_hidden = 1 +let g:fern#renderer = 'devicons' +let g:fern_renderer_devicons_disable_warning = 1 + +" Multi window select in which you open the file +function! s:init_fern() abort + " Use 'select' instead of 'edit' for default 'open' action + nmap (fern-action-open) (fern-action-open:select) +endfunction + +augroup fern-custom + autocmd! * + autocmd FileType fern call s:init_fern() +augroup END + +" Which Key +call which_key#register('', "g:which_key_map") +let g:which_key_map = {} + +" Buffer key help +let g:which_key_map.b = { + \ 'name' : '+buffer', + \ 'd' : 'current buffer close', + \ 'a' : 'close all buffers', + \ 'n' : 'go to next buffer', + \ 'p' : 'go to previous buffer', + \ } + +" Tab key help +let g:which_key_map.t = { + \ 'name' : '+tab', + \ 't' : 'go to next tab', + \ 'n' : 'open new tab', + \ 'o' : 'close other tabs', + \ 'c' : 'close current tab', + \ 'm' : 'move tab after another', + \ 'l' : 'switch between this & last tab', + \ 'e' : 'open new tab with current buffer', + \ } + +" Spell key help +let g:which_key_map.s = { + \ 'name' : '+spell', + \ 's' : 'toggle spell check', + \ 'n' : 'next spell word', + \ 'p' : 'previous spell word', + \ 'a' : 'add word in dict', + \ '?' : 'list word alternatives', + \ } + +" Hunk key help +let g:which_key_map.h = { + \ 'name' : '+git hunk', + \ 'l' : 'remove highlight', + \ 'p' : 'go previous hunk', + \ 'n' : 'go next hunk', + \ 't' : 'enable/disable gitgutter', + \ 's' : 'stage hunk', + \ 'u' : 'undo hunk', + \ 'P' : 'preview hunk', + \ } + +" LSP key help +let g:which_key_map.l = { + \ 'name' : '+LSP', + \ 'd' : 'go to definition', + \ 'nd' : 'next diagnostic', + \ 'pd' : 'previous diagnostic', + \ 'f' : 'go to reference', + \ 'r' : 'rename object', + \ 's' : 'stop LSP server', + \ 'p' : 'peek definition', + \ 'a' : 'code action', + \ 'h' : 'hover information', + \ 'df' : 'format document', + \ } diff --git a/readme.md b/readme.md index b4a0bae..751f18e 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,13 @@ This config has just the necessary plugins installed: - [OneDark](https://github.com/joshdick/onedark.vim) onedark theme. - [Vim Airline](https://github.com/vim-airline/vim-airline) Vim statusline. -- [NerdTree](https://github.com/preservim/nerdtree) to have a file tree in vim. +- [Fern](https://github.com/lambdalisue/fern.vim) to have a file tree in vim. +- [Fern hijack](https://github.com/lambdaalisue/fern-hijack.vim) to open folder preview with fern. +- [Fern renderer devicons](https://github.com/lambdalisue/fern-renderer-devicons.vim) to have devicons in fern. +- [Fern git mapping](https://github.com/lambdalisue/fern-mapping-git.vim) to add git stage & unstage in fern. +- [Fern copy node](https://github.com/andykog/fern-copynode.vim) to copy filename or foldername or filepath or folderpath. +- [Fern git status](https://github.com/lambdalisue/fern-git-status.vim.git) show file git status in fern. +- [Vim which key](https://github.com/liuchengxu/vim-which-key) show leader keybinds in a GUI. - [Vim devicons](https://github.com/ryanoasis/vim-devicons) language icons for vim. - [Vim nerdtree syntax highlighting](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight) nerdtree syntax highlighting - [Vim gitgutter](https://github.com/airblade/vim-gitgutter) to see diff between files with git. @@ -47,8 +53,8 @@ This config has just the necessary plugins installed: - `bd` close the current buffer, - `ba` close all the buffers, -- `]b` go to the next buffer, -- `[b` go to the precedent buffer, +- `bn` go to the next buffer, +- `bp` go to the precedent buffer, #### Tabs @@ -70,19 +76,22 @@ This config has just the necessary plugins installed: More help at `:help spell` -### NerdTree +### Fern -For help, use `:help NERDTree`. +For help, use `:help fern`. Keybinds: -- `Ctrl+f` open or close the nerdtree window +- `Ctrl+f` open the treeview in the current window +- `ga` stage a file or unstage if already stagged (TODO) +- `cp` copy node name (file, folder..) +- `cP` copy node path ### Vim Gutter For help, use `:help gitgutter`. Keybinds: -- `[h` go to the previous hunk, -- `]h` go to the next hunk, -- `hp` to preview hunk, +- `hp` go to the previous hunk, +- `hn` go to the next hunk, +- `hP` to preview hunk, - `hs` to stage hunk, - `hu` to undo hunk, - `ht` to toggle GitGutter. -- cgit v1.2.3