aboutsummaryrefslogtreecommitdiff
path: root/vim
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 /vim
parent900c5ae36832b3426596b59cb89b6e5c1f87e38b (diff)
downloadvimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.tar.gz
vimrc-6c5f19bf6524fc38c4288858f9f03c0fbc325556.zip
ADD: CoC Lsp, and update README
Diffstat (limited to 'vim')
-rw-r--r--vim/keymaps.vim74
-rw-r--r--vim/options.vim4
-rw-r--r--vim/plugins.vim28
3 files changed, 57 insertions, 49 deletions
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.