aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-06-29 23:07:21 +0200
committerOxbian <got.dacs@slmail.me>2023-06-29 23:07:21 +0200
commit70a1687c7487bbe7397d1db71e04f4cb2380fc27 (patch)
tree6675f942fd87dbc32ca17dd2ce4ffb9fcdd11f46
parent5c9f71e376c5ca7334aa3d884c34413b2efacb0d (diff)
downloadvimrc-70a1687c7487bbe7397d1db71e04f4cb2380fc27.tar.gz
vimrc-70a1687c7487bbe7397d1db71e04f4cb2380fc27.zip
Updating lsp settings & documentation
-rw-r--r--.vim/after/ftplugin/markdown.vim1
-rw-r--r--.vim/keymaps.vim136
-rw-r--r--.vim/options.vim90
-rw-r--r--.vim/plugins.vim49
-rw-r--r--.vim/spell/en.utf-8.add11
-rw-r--r--.vim/spell/en.utf-8.add.splbin0 -> 211 bytes
-rw-r--r--readme.md98
7 files changed, 237 insertions, 148 deletions
diff --git a/.vim/after/ftplugin/markdown.vim b/.vim/after/ftplugin/markdown.vim
new file mode 100644
index 0000000..bcda2dd
--- /dev/null
+++ b/.vim/after/ftplugin/markdown.vim
@@ -0,0 +1 @@
+setlocal spell
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>"
diff --git a/.vim/options.vim b/.vim/options.vim
index 29f9f2c..431bfc7 100644
--- a/.vim/options.vim
+++ b/.vim/options.vim
@@ -9,9 +9,10 @@ set hlsearch " Highlight all match search pattern
" Graphics options
syntax on " Show syntax color
-set background=dark
-colorscheme onedark
+set background=dark " Set vim style as dark
+colorscheme onedark " Set colorscheme as onedark
set number " Show line number
+set relativenumber " Show relative line number
set cursorline " Select the current line
set showmatch " Show matching brackets when overred
set laststatus =2 " Fix for tabline
@@ -38,19 +39,20 @@ set autoread " Automatically read extern changes on the file
" System
if has('unnamedplus') " ALlow OS & vim clipboard sync
- set clipboard = "unnamedplus"
+ set clipboard = unnamedplus
endif
set undofile " Save undo history
set history =500 " Max line vim remember
set updatetime=500 " Delay before vim write swap file, lower better for gitgutter
" Autocomplete
-set completeopt = "menuone,noselect" " Show a pop up for command completion
+set completeopt=menu,menuone,popup,noselect,noinsert " Show a pop up for command completion
set wildmenu " Turn on wildmenu
" Avoid garbled characters in Chinese language windows OS
-let $LANG='en'
-set langmenu=en
+let $LANG='en' " Setting lang as en
+set langmenu=en " Setting menu lang as en
+" This delete all the defined menu
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
@@ -71,23 +73,9 @@ set whichwrap+=<,>,h,l
" Don't redraw while executing macros (good performance config)
set lazyredraw
-" For regular expressions turn magic on
-set magic
-
" How many tenths of a second to blink when matching brackets
set mat=2
-" No annoying sound on errors
-set noerrorbells
-set novisualbell
-set t_vb=
-set tm=500
-
-" Properly disable sound on errors on MacVim
-if has("gui_macvim")
- autocmd GUIEnter * set vb t_vb=
-endif
-
" Add a bit extra margin to the left
set foldcolumn=1
@@ -97,69 +85,7 @@ set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" => Files, backups and undo
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git etc. anyway...
set nobackup
set nowb
set noswapfile
-
-" Close the current buffer
-map <leader>bd :Bclose<cr>:tabclose<cr>gT
-
-" Close all the buffers
-map <leader>ba :bufdo bd<cr>
-
-map <leader>l :bnext<cr>
-map <leader>h :bprevious<cr>
-
-" Useful mappings for managing tabs
-map <leader>tn :tabnew<cr>
-map <leader>to :tabonly<cr>
-map <leader>tc :tabclose<cr>
-map <leader>tm :tabmove
-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
-
-
-""""""""""""""""""""""""""""""
-" => Status line
-""""""""""""""""""""""""""""""
-" Always show the status line
-set laststatus=2
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" => Spell checking
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Pressing ,ss will toggle and untoggle spell checking
-map <leader>ss :setlocal spell!<cr>
-
-" Shortcuts using <leader>
-map <leader>sn ]s
-map <leader>sp [s
-map <leader>sa zg
-map <leader>s? z=
-
diff --git a/.vim/plugins.vim b/.vim/plugins.vim
index d881f6a..e7e9f6e 100644
--- a/.vim/plugins.vim
+++ b/.vim/plugins.vim
@@ -19,17 +19,16 @@ 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
" Git integration
-Plug 'tpope/vim-fugitive' " Git commands & informations
Plug 'airblade/vim-gitgutter' " Git diff
" Autocompletion, linter, syntax
-Plug 'dense-analysis/ale' " Swiss-knife for all this
-
-" Snippets
-Plug 'hrsh7th/vim-vsnip'
-Plug 'rafamadriz/friendly-snippets'
+Plug 'prabirshrestha/vim-lsp'
+Plug 'mattn/vim-lsp-settings'
+Plug 'prabirshrestha/asyncomplete.vim'
+Plug 'prabirshrestha/asyncomplete-lsp.vim'
call plug#end()
@@ -47,12 +46,12 @@ 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.linenr = 'ΒΆ'
+let g:airline_symbols.linenr = ' ΒΆ'
let g:airline_symbols.maxlinenr = ''
-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 = 'Þ'
@@ -60,15 +59,34 @@ 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 = 'Ξ'
-let g:airline#extensions#ale#enabled = 1 " Allow ALE to use status line
+let g:airline_symbols.whitespace = ' Ξ'
" ALE
+" ALE linter
let g:ale_linters = {
\ 'javascript': ['eslint'],
-\ 'python': ['flake8'],
+\ 'python': ['flake8', 'pylint', 'pydocstyle', 'bandit', 'mypy']
\ }
+let g:ale_lint_on_save = 1
+let g:ale_lint_on_text_changed = 0
+let g:ale_open_list = 1
+
+" ALE fixer
+let g:ale_fixers = {
+\ '*': ['remove_trailing_lines', 'trim_whitespace'],
+\ 'python': ['black', 'isort']
+\}
+let g:ale_fix_on_save = 1
+
+let g:ale_echo_msg_error_str = 'E'
+let g:ale_echo_msg_warning_str = 'W'
+let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
+
+let g:ale_set_loclist = 0
+let g:ale_set_signs = 1
+let g:ale_set_highlights = 1
+
let g:ale_completion_enabled = 1
let g:ale_completion_symbols = {
\ 'text': 'ξ˜’',
@@ -101,14 +119,15 @@ let g:ale_completion_symbols = {
" 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
let g:plug_window = 'noautocmd vertical topleft new' " Stop crash if vimplug command called on the nerdtree window
-
-" VIM snip
-let g:vsnip_filetypes = {}
diff --git a/.vim/spell/en.utf-8.add b/.vim/spell/en.utf-8.add
new file mode 100644
index 0000000..283920b
--- /dev/null
+++ b/.vim/spell/en.utf-8.add
@@ -0,0 +1,11 @@
+linters
+nerdtree
+GitGutter
+keybinds
+onedark
+LSP
+vscode
+autocompleter
+linter
+neovim
+untoggle
diff --git a/.vim/spell/en.utf-8.add.spl b/.vim/spell/en.utf-8.add.spl
new file mode 100644
index 0000000..29528b3
--- /dev/null
+++ b/.vim/spell/en.utf-8.add.spl
Binary files differ
diff --git a/readme.md b/readme.md
index e4457a7..f2ca3d5 100644
--- a/readme.md
+++ b/readme.md
@@ -1,62 +1,104 @@
# VIM
-This repo contains my vim configuration, hope it will be usefull for you.
+This repo contains my vim configuration, hope it will be useful for you.
-## Installation
+## Installation
-You will need `vim` and `git` to be able to use this config.
+You will need `vim` and `git` to be able to use this configuration.
-Normally if you run the `install.sh` script it will work, but if you have a problem, try to install vim plug and check if your problem is solved.
+Normally if you run the `install.sh` script it will work, but if you have a problem, try to install vim plug and check if your problem is solved.
```bash
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
-Oh and remove neovim, it make some problems with vim.
+Oh and remove neovim, it make some problems with vim.
## Plugins
-This config has just the necessarry 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 filetree in vim.
-- [Vim devicons](https://github.com/ryanoasis/vim-devicons) language icons for vim.
- [Vim gitgutter](https://github.com/airblade/vim-gitgutter) to see diff between files with git.
-- [Vim fugitive](https://github.com/tpope/vim-fugitive) to be able to use some powerful git commands in git.
-- [ALE](https://github.com/dense-analysis/ale) vim linter, autocompleter, a swiss knife for all the LSP things.
-- [Vim vsnip](https://github.com/hrsh7th/vim-vsnip/tree/master) vscode snippets for vim.
-- [Vim friendly snippets](https://github.com/rafamadriz/friendly-snippets) vim snippets collection in vscode format.
+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.
+- [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.
+- [Vim LSP](https://github.com/prabirshrestha/vim-lsp) to add LSP
+- [Vim LSP settings](https://github.com/mattn/vim-lsp-settings) auto configuration for installing LSP-server
+- [Asyncomplete](https://github.com/prabirshrestha/asyncomplete.vim) async autocompletion
+- [Asyncomplete lsp](https://github.com/prabirshrestha/asyncomplete-lsp.vim) LSP server for asyncomplete & vim-lsp
## Command & keybinds
### General
-- `Ctrl+h` move to the left window
+- `<leader>hl` remove highlighting
+
+#### Window
+
+- `Ctrl+h` move to the left window
- `Ctrl+j` move to the bottom window
- `Ctrl+k` move to the upper window
- `Ctrl+l` move to the right window
-- `<leader>h` remove highligthing
+
+#### Buffer
+
+- `<leader>bd` close the current buffer
+- `<leader>ba` close all the buffers
+- `<leader>l` go to the next buffer
+- `<leader>h` go to the precedent buffer
+
+#### Tabs
+
+- `<leader>tn` open a new tab
+- `<leader>to` close all other tabs
+- `<leader>tc` close current tab page
+- `<leader>tm` move the tab after another
+- `<leader>t<leader>` go to the next tab
+- `<leader>tl` toggle between this tab and the last accessed tab
+- `<leader>te` open a new tab with the current buffer
+
+#### Spell check
+
+- `<leader>ss` toggle / untoggle spellchecking
+- `<leader>sn` go to the next word to spellcheck
+- `<leader>sp` go to the previous word to spellcheck
+- `<leader>sa` add a word into the dictionary
+- `<leader>s?` show the list of alternatives for the word
+
+More help at `:help spell`
### NerdTree
-For help, use `:help NERDTree`.
+For help, use `:help NERDTree`.
Keybinds:
-- `Ctrl+f` open or close the nerdtree window
+- `Ctrl+f` open or close the nerdtree window
-### Vim Gutter
+### Vim Gutter
-For help, use `:help gitgutter`.
-Keybinds:
-- `[c` & `]c` to jump between hunks,
-- `<leader>hp` to preview hunk,
-- `<leader>hs` to stage hunk,
-- `<leader>hu` to undo hunk,
-- `<leader>d` to toggle GitGutter.
+For help, use `:help gitgutter`.
+Keybinds:
+- `[c` & `]c` to jump between hunks,
+- `<leader>hp` to preview hunk,
+- `<leader>hs` to stage hunk,
+- `<leader>hu` to undo hunk,
+- `<leader>d` to toggle GitGutter.
Hunks are the difference between your file and the git file.
### Vim Fugitive
-For help, use `:help fugitive`.
+For help, use `:help fugitive`.
+
+## Linters & fixers
+
+### Python
+For using python linters & fixers, you will need to setup a virtual env & install the linters & fixers.
+
+```bash
+python -m venv .venv
+source .venv/bin/activate
+pip install flake8 pylint pydocstyle bandit mypy black isort
+```
ArKa projects. All rights to me, and your next child right arm.