Last active
November 12, 2020 15:19
-
-
Save remynguyen96/f5f6da0156f334f37b22b5f7aebe9f20 to your computer and use it in GitHub Desktop.
Coc nvim (~/.config/nvim/coc.vim)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Leader | |
| "let mapleader = " " | |
| " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
| " delays and poor user experience. | |
| set updatetime=300 | |
| " always show signcolumns | |
| set signcolumn=yes | |
| " Use tab for trigger completion with characters ahead and navigate. | |
| " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
| " other plugin before putting this into your config. | |
| inoremap <silent><expr> <TAB> | |
| \ pumvisible() ? "\<C-n>" : | |
| \ <SID>check_back_space() ? "\<TAB>" : | |
| \ coc#refresh() | |
| "inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
| function! s:check_back_space() abort | |
| let col = col('.') - 1 | |
| return !col || getline('.')[col - 1] =~# '\s' | |
| endfunction | |
| " Use <c-space> to trigger completion. | |
| inoremap <silent><expr> <c-space> coc#refresh() | |
| " Make <CR> auto-select the first completion item and notify coc.nvim to | |
| " format on enter, <cr> could be remapped by other vim plugin | |
| inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() | |
| \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
| " coc.vim config | |
| " Use `[g` and `]g` to navigate diagnostics | |
| nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
| nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
| " Remap keys for gotos | |
| 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> K :call <SID>show_documentation()<CR> | |
| function! s:show_documentation() | |
| if (index(['vim','help'], &filetype) >= 0) | |
| execute 'h '.expand('<cword>') | |
| elseif (coc#rpc#ready()) | |
| call CocActionAsync('doHover') | |
| else | |
| execute '!' . &keywordprg . " " . expand('<cword>') | |
| endif | |
| endfunction | |
| " Highlight symbol under cursor on CursorHold | |
| autocmd CursorHold * silent call CocActionAsync('highlight') | |
| " Remap for rename current word | |
| nmap <leader>rn <Plug>(coc-rename) | |
| 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 keys for applying codeAction to the current buffer. | |
| nmap <leader>ac <Plug>(coc-codeaction) | |
| " Apply AutoFix to problem on the current line. | |
| nmap <leader>qf <Plug>(coc-fix-current) | |
| " Map function and class text objects | |
| " NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
| xmap if <Plug>(coc-funcobj-i) | |
| omap if <Plug>(coc-funcobj-i) | |
| xmap af <Plug>(coc-funcobj-a) | |
| omap af <Plug>(coc-funcobj-a) | |
| xmap ic <Plug>(coc-classobj-i) | |
| omap ic <Plug>(coc-classobj-i) | |
| xmap ac <Plug>(coc-classobj-a) | |
| omap ac <Plug>(coc-classobj-a) | |
| " Remap <C-f> and <C-b> for scroll float windows/popups. | |
| " Note coc#float#scroll works on neovim >= 0.4.3 or vim >= 8.2.0750 | |
| nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
| nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
| inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
| inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
| " prettier command for coc | |
| command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
| " Add `:Format` command to format current buffer. | |
| command! -nargs=0 Format :call CocAction('format') | |
| " Add `:OR` command for organize imports of the current buffer. | |
| command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
| " Formatting selected code. | |
| xmap <leader>l <Plug>(coc-format-selected) | |
| nmap <leader>l <Plug>(coc-format-selected) | |
| nmap <leader>al :Format <CR> |
Author
Author
List of Coc extensions
{
"dependencies": {
"coc-clangd": "^0.4.14",
"coc-css": "^1.2.5",
"coc-emmet": "^1.1.6",
"coc-eslint": "^1.3.2",
"coc-graphql": "0.0.1",
"coc-highlight": "^1.2.6",
"coc-html": "^1.2.4",
"coc-json": "^1.3.2",
"coc-markdownlint": "^1.6.0",
"coc-pairs": "^1.2.21",
"coc-prettier": "^1.1.17",
"coc-sh": "^0.6.0",
"coc-snippets": "^2.2.1",
"coc-tslint-plugin": "^1.1.1",
"coc-tsserver": "^1.5.8"
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Coc nvim