aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-12-02 22:03:41 +0100
committerOxbian <got.dacs@slmail.me>2023-12-02 22:03:41 +0100
commit6c5f19bf6524fc38c4288858f9f03c0fbc325556 (patch)
treeff16fe3d4429b0309756eab4f38e4908d04204c0
parent900c5ae36832b3426596b59cb89b6e5c1f87e38b (diff)
downloadvimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.tar.gz
vimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.zip
ADD: CoC Lsp, and update README
-rw-r--r--README.md28
-rw-r--r--vim/keymaps.vim74
-rw-r--r--vim/options.vim4
-rw-r--r--vim/plugins.vim28
4 files changed, 70 insertions, 64 deletions
diff --git a/README.md b/README.md
index 39817e3..ba83d11 100644
--- a/README.md
+++ b/README.md
@@ -22,18 +22,17 @@ This config has just the necessary plugins installed:
### Themes
- [OneDark](https://github.com/joshdick/onedark.vim) onedark theme.
+- [Zenbones](https://github.com/mcchrish/zenbones.nvim) zenbones theme.
### Graphics utilities
- [Vim which key](https://github.com/liuchengxu/vim-which-key) show leader keybinds in a GUI.
- [Vim gitgutter](https://github.com/airblade/vim-gitgutter) to see diff between files with git.
+- [Css color](https://github.com/ap/vim-css-color) preview css colors.
### LSP
-- [Vim-lsp](https://github.com/prabirshrestha/vim-lsp) linter & formatter for language.
-- [Vim-lsp settings](https://github.com/mattn/vim-lsp-settings) easily setup lsp servers for languages.
-- [Asyncomplete](https://github.com/prabirshrestha/asyncomplete.vim) async autocompletion
-- [Asyncomplete & lsp-vim](https://github.com/prabirshrestha/asyncomplete-lsp.vim) use vim-lsp as source for autocompletion lsp server.
+- [CoC](https://github.com/neoclide/coc.nvim) a LSP plugin that work like VsCode LSP, and in Node (yeah I don't like it too but no choice...).
- [Vim Wakatime](https://github.com/wakatime/vim-wakatime) to have wakatime time tracking in vim.
### Languages utilities
@@ -112,18 +111,17 @@ Hunks are the difference between your file and the git file.
### LSP
-For help, use `:help vim-lsp`.
+For help, use `:help coc`.
Keybinds:
-- `<leader>ld` go to the definition,
-- `<leader>lnd` go to the next diagnostic,
-- `<leader>lpd` go to the previous diagnostic,
-- `<leader>lf` go to the reference,
-- `<leader>lr` rename element,
-- `<leader>ls` stop lsp server,
-- `<leader>lp` peek a view to the definition,
-- `<leader>la` code action,
-- `<leader>lh` lsp hover,
-- `<leader>ldf` format document.
+- `<leader>gd` go to the definition,
+- `<leader>gn` go to the next diagnostic,
+- `<leader>gp` go to the previous diagnostic,
+- `<leader>gr` go to the reference,
+- `<leader>gR` rename element,
+- `<leader>gy` type definition,
+- `<leader>gi` go to implementation,
+- `<leader>gh` documentation,
+- `<leader>gf` format document.
## Linters & fixers
diff --git a/vim/keymaps.vim b/vim/keymaps.vim
index 9570949..e568816 100644
--- a/vim/keymaps.vim
+++ b/vim/keymaps.vim
@@ -7,6 +7,9 @@ let g:maplocalleader = ','
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
+" Treat long paragraph as a line
+map j gj
+map k gk
""""""""""""""""""""
" Window movement
@@ -146,34 +149,43 @@ noremap <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>
-
+inoremap <silent><expr> <TAB>
+ \ coc#pum#visible() ? coc#pum#next(1) :
+ \ CheckBackspace() ? "\<Tab>" :
+ \ coc#refresh()
+inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
+
+" Make <CR> to accept selected completion item or notify coc.nvim to format
+" <C-g>u breaks current undo, please make your own choice
+inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
+ \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
+
+nmap <silent> gp <Plug>(coc-diagnostic-prev)
+nmap <silent> gn <Plug>(coc-diagnostic-next)
+
+" GoTo code navigation
+nmap <silent> gd <Plug>(coc-definition)
+nmap <silent> gy <Plug>(coc-type-definition)
+nmap <silent> gi <Plug>(coc-implementation)
+nmap <silent> gr <Plug>(coc-references)
+
+" Use K to show documentation in preview window
+nnoremap <silent> gh :call ShowDocumentation()<CR>
+
+function! ShowDocumentation()
+ if CocAction('hasProvider', 'hover')
+ call CocActionAsync('doHover')
+ else
+ call feedkeys('K', 'in')
+ endif
+endfunction
+
+" Highlight the symbol and its references when holding the cursor
+autocmd CursorHold * silent call CocActionAsync('highlight')
+
+" Symbol renaming
+nmap <leader>gR <Plug>(coc-rename)
+
+" Formatting selected code
+xmap <leader>gf <Plug>(coc-format-selected)
+nmap <leader>gf <Plug>(coc-format-selected)
diff --git a/vim/options.vim b/vim/options.vim
index 7ffd2a9..650df04 100644
--- a/vim/options.vim
+++ b/vim/options.vim
@@ -6,8 +6,9 @@ set hlsearch " Highlight all match search pattern
" Graphics options
syntax on " Show syntax color
+set termguicolors
set background=dark " Set vim style as dark
-colorscheme onedark " Set colorscheme as onedark
+colorscheme zenwritten " Set colorscheme as onedark
set number " Show line number
set relativenumber " Show relative line number
set cursorline " Select the current line
@@ -44,6 +45,7 @@ set updatetime=500 " Delay before vim write swap file, lower better for gitgutte
" Autocomplete
set completeopt=menu,menuone,popup,noselect,noinsert " Show a pop up for command completion
set wildmenu " Turn on wildmenu
+filetype plugin on
" Avoid garbled characters in Chinese language windows OS
let $LANG='en' " Setting lang as en
diff --git a/vim/plugins.vim b/vim/plugins.vim
index 7822826..a32da64 100644
--- a/vim/plugins.vim
+++ b/vim/plugins.vim
@@ -16,16 +16,14 @@ call plug#begin('~/.vim/plugged')
" UI & Themes
Plug 'joshdick/onedark.vim' " Onedark themes for vim
+Plug 'mcchrish/zenbones.nvim' " White / dark colorscheme
Plug 'liuchengxu/vim-which-key' " Show leader mapping cheatsheet
" Git integration
Plug 'airblade/vim-gitgutter' " Git diff
" Autocompletion, linter, syntax
-Plug 'prabirshrestha/vim-lsp' " Linter & formatter
-Plug 'mattn/vim-lsp-settings' " Automatic vim-lsp installation
-Plug 'prabirshrestha/asyncomplete.vim' " Autocompletion
-Plug 'prabirshrestha/asyncomplete-lsp.vim' " Autocompletion & connection with vim-lsp
+Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Tools
Plug 'wakatime/vim-wakatime' " Wakatime
@@ -71,9 +69,6 @@ set statusline+=\ \|\ [%{&fileformat}\]
set statusline+=\ \|\ %l:%c
set statusline+=\ [%p%%]\
-" VIM lsp
-let g:lsp_diagnostics_echo_cursor = 1
-let g:lsp_diagnostics_virtual_text_enabled = 0
" Which Key
call which_key#register('<Space>', "g:which_key_map")
@@ -123,16 +118,15 @@ let g:which_key_map.h = {
\ }
" LSP key help
-let g:which_key_map.l = {
+let g:which_key_map.g = {
\ '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',
+ \ 'n' : 'next diagnostic',
+ \ 'p' : 'previous diagnostic',
+ \ 'r' : 'go to reference',
+ \ 'R' : 'rename object',
+ \ 'y' : 'type definition',
+ \ 'i' : 'go to implementation',
+ \ 'h' : 'documentation',
+ \ 'f' : 'format document',
\ }
ArKa projects. All rights to me, and your next child right arm.