diff --git a/vim/vimrc b/vim/vimrc index b708bf3..63a4176 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -36,6 +36,10 @@ Plug 'reedes/vim-pencil', Cond(!exists('g:vscode')) "" markdown Plug 'suan/vim-instant-markdown', Cond(!exists('g:vscode')) +Plug 'dense-analysis/ale', Cond(!exists('g:vscode')) + +Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode'), {'branch': 'release'}) + call plug#end() filetype plugin indent on @@ -98,7 +102,7 @@ set nowritebackup " == swap == set swapfile set updatecount=200 -set updatetime=10000 +set updatetime=300 " == undo == set undolevels=1000 @@ -144,6 +148,8 @@ set termguicolors " === keybinds === set pastetoggle= +set signcolumn=yes + let maplocalleader = "รถ" let mapleader = "\" " map w: w! @@ -209,6 +215,10 @@ else syntax enable silent! colorscheme monokai + highlight Comment guifg=#64d86b + highlight SpecialComment guifg=#64d86b + highlight Todo guibg=#a9ebad + let g:lightline = { \ 'colorscheme': 'wombat', \ 'active': { @@ -250,6 +260,8 @@ else " == limelight == let g:limelight_default_coefficient = 0.5 + let g:ale_linters = {'rust': ['rust-analyzer']} + " === functions === function! DeleteTrailingWS() exe "normal mz" @@ -269,6 +281,40 @@ else let g:rustfmt_autosave = 1 + inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + + " Make to accept selected completion item or notify coc.nvim to format + " u breaks current undo, please make your own choice. + inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + + function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Use to trigger completion. + if has('nvim') + inoremap coc#refresh() + else + inoremap coc#refresh() + endif + + if has('nvim') + inoremap coc#refresh() + else + inoremap coc#refresh() + endif + " https://stackoverflow.com/a/8585343 map q :bpspbnbd + + nmap gd (coc-definition) + nmap gy (coc-type-definition) + nmap gi (coc-implementation) + nmap gr (coc-references) endif