From adca2c13b740f73a6fda0ca3e96a491f52e9f6a1 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Sun, 19 Sep 2021 20:06:22 -0700 Subject: added coc --- nvim/.config/nvim/init.vim | 113 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'nvim/.config') diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index 486385d..8978c2d 100755 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -1,5 +1,6 @@ " vimplug call plug#begin() +Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'Shougo/deol.nvim' Plug 'ap/vim-css-color' Plug 'tpope/vim-eunuch' @@ -148,3 +149,115 @@ set statusline+=%#PrimaryBlock# set statusline+=\ %Y\ set statusline+=%#SecondaryBlock# set statusline+=\ %P\ + +" ------COC SETTINGS------ +" prettier command for coc +command! -nargs=0 Prettier :CocCommand prettier.formatFile +let g:coc_global_extensions = [ + \ 'coc-snippets', + \ 'coc-pairs', + \ 'coc-prettier', + \ 'coc-tsserver', + \ 'coc-html', + \ 'coc-css', + \ 'coc-json', + \ 'coc-clangd', + \ 'coc-python', + \ 'coc-sh', + \ 'coc-vimtex' + \ ] + +" From Coc Readme +set updatetime=300 + +" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup + +" don't give |ins-completion-menu| messages. +set shortmess+=c + +" always show signcolumns +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate. +" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current position. +" Coc only does snippet and additional edit on confirm. +inoremap pumvisible() ? "\" : "\u\" +" Or use `complete_info` if your vim support it, like: +" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" Remap keys for gotos +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Remap for rename current word +nmap (coc-rename) + +" Remap for format selected region +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Remap for do codeAction of selected region, ex: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap for do codeAction of current line +nmap ac (coc-codeaction) +" Fix autofix problem of current line +nmap qf (coc-fix-current) + +" Create mappings for function text object, requires document symbols feature of languageserver. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Use `:Format` to format current buffer +command! -nargs=0 Format :call CocAction('format') + +" Use `:Fold` to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" use `:OR` for organize import of current buffer +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add status line support, for integration with other plugin, checkout `:h coc-status` +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} -- cgit v1.2.3