diff options
author | Oxbian <got.dacs@slmail.me> | 2023-07-02 20:39:30 +0200 |
---|---|---|
committer | Oxbian <got.dacs@slmail.me> | 2023-07-02 20:39:30 +0200 |
commit | e8c1a06d0e63fcf6d383dd3f1be14e4b095466e6 (patch) | |
tree | 931dd48087ac1f90028f089523686e26b779f5d0 | |
parent | 95f323522716f6b72133fefb615f4ede906dc0f2 (diff) | |
download | vimrc-e8c1a06d0e63fcf6d383dd3f1be14e4b095466e6.tar.gz vimrc-e8c1a06d0e63fcf6d383dd3f1be14e4b095466e6.zip |
Updating vim & documentation
-rw-r--r-- | .vim/keymaps.vim | 40 | ||||
-rw-r--r-- | .vim/options.vim | 6 | ||||
-rw-r--r-- | .vim/plugins.vim | 109 | ||||
-rw-r--r-- | 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 = "\<Space>" +let g:maplocalleader = ',' +nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR> +nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR> + + """""""""""""""""""" " Window movement """""""""""""""""""" @@ -38,10 +44,10 @@ map <leader>bd :Bclose<cr>:tabclose<cr>gT map <leader>ba :bufdo bd<cr> " Go to the next buffer -map <leader>]b :bnext<cr> +map <leader>bn :bnext<cr> " Go to the previous buffer -map <leader>[b :bprevious<cr> +map <leader>bp :bprevious<cr> """""""""""""""""""""""""""" " Tabs @@ -89,18 +95,19 @@ au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g """"""""""""""""""""""" " Toggle nerdtree -nnoremap <C-f> :NERDTreeToggle<CR> +nnoremap <C-f> :Fern .<CR> """""""""""""""""""" " GitGutter """""""""""""""""""" + let g:gitgutter_enabled=1 " Enable by default gitgutter " Go to the previous hunk -nnoremap <leader>[h <Plug>(GitGutterPrevHunk) +nnoremap <leader>hp <Plug>(GitGutterPrevHunk) " Go to the next hunk -nnoremap <leader>]h <Plug>(GitGutterNextHunk) +nnoremap <leader>hn <Plug>(GitGutterNextHunk) " Enable / Disable GitGutter nnoremap <leader>ht <Plug>(GitGutterToggle) @@ -112,7 +119,7 @@ nnoremap <leader>hs <Plug>(GitGutterStageHunk) nnoremap <leader>hu <Plug>(GitGutterUndoHunk) " Preview Hunk -nnoremap <leader>hp :GitGutterPreviewHunk<CR> +nnoremap <leader>hP :GitGutterPreviewHunk<CR> " Always show the status line set laststatus=2 @@ -139,16 +146,37 @@ map <leader>s? z= """"""""""""""""""" " LSP """"""""""""""""""" + inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" +" Go to definition nnoremap <leader>ld :LspDefinition<cr> + +" Go next diagnostic nnoremap <leader>lnd :LspNextDiagnostic<cr> + +" Go previous diagnostic nnoremap <leader>lpd :LspPreviousDiagnostic<cr> + +" Go to reference nnoremap <leader>lf :LspReferences<cr> + +" Rename object nnoremap <leader>lr :LspRename<cr> + +" LSP stop server nnoremap <leader>ls :LspStopServer<cr> + +" peek definition of object nnoremap <leader>lp :LspPeekDefinition<cr> + +" Code Action nnoremap <leader>la :LspCodeAction<cr> + +" Hover information nnoremap <leader>lh :LspHover<cr> + +" Format document nnoremap <leader>ldf :LspDocumentFormat<cr> + 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! \<C-W>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 <buffer> <Plug>(fern-action-open) <Plug>(fern-action-open:select) +endfunction + +augroup fern-custom + autocmd! * + autocmd FileType fern call s:init_fern() +augroup END + +" Which Key +call which_key#register('<Space>', "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<leader>' : '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', + \ } @@ -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: - `<leader>bd` close the current buffer, - `<leader>ba` close all the buffers, -- `<leader>]b` go to the next buffer, -- `<leader>[b` go to the precedent buffer, +- `<leader>bn` go to the next buffer, +- `<leader>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, -- `<leader>hp` to preview hunk, +- `<leader>hp` go to the previous hunk, +- `<leader>hn` go to the next hunk, +- `<leader>hP` to preview hunk, - `<leader>hs` to stage hunk, - `<leader>hu` to undo hunk, - `<leader>ht` to toggle GitGutter. |