Add experimental coc.nvim module
This commit is contained in:
parent
f778d2c536
commit
1b12ca0d13
6 changed files with 108 additions and 0 deletions
|
@ -40,6 +40,8 @@ runtime! pluglist/**/*.vim
|
|||
call plug#end()
|
||||
endif
|
||||
|
||||
colo one
|
||||
|
||||
" }}}
|
||||
" VIM SETTINGS {{{
|
||||
" ================================================================================
|
||||
|
|
106
.config/nvim/modules_experimental/coc-completion.vim
Normal file
106
.config/nvim/modules_experimental/coc-completion.vim
Normal file
|
@ -0,0 +1,106 @@
|
|||
" some things do not work perfectly yet
|
||||
" I have to take a look at the bindings
|
||||
" MOSTLY, it works
|
||||
" but startup takes ages (>1s)
|
||||
|
||||
" one more thing needs to be done for clever coc linting/fixing:
|
||||
" create a file called coc-settings.json in nvim config dir with the
|
||||
" following content:
|
||||
"
|
||||
"{
|
||||
" // Require .prettierrc
|
||||
" "prettier.requireConfig": true,
|
||||
" // Tslint on save
|
||||
" "tslint.enable": true,
|
||||
" "tslint.autoFixOnSave": true,
|
||||
" // Run prettier (and others)
|
||||
" "coc.preferences.formatOnSaveFiletypes": [
|
||||
" "css",
|
||||
" "markdown",
|
||||
" "Markdown",
|
||||
" "javascript",
|
||||
" "javascriptreact",
|
||||
" "typescript",
|
||||
" "typescriptreact"
|
||||
" ]
|
||||
"}
|
||||
|
||||
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}, 'on': [], 'for': []}
|
||||
Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-prettier', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-tslint', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'}
|
||||
" Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} " color highlighting
|
||||
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-rls', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'neoclide/coc-git', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'fannheyward/coc-rust-analyzer', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'fannheyward/coc-markdownlint', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'fannheyward/coc-texlab', {'do': 'yarn install --frozen-lockfile'}
|
||||
Plug 'iamcco/coc-vimlsp', {'do': 'yarn install --frozen-lockfile'}
|
||||
|
||||
" lazy loading since they require a lot of startup time
|
||||
augroup load_ide_features
|
||||
autocmd!
|
||||
autocmd InsertEnter * call plug#load('coc.nvim')
|
||||
\| autocmd! load_ide_features
|
||||
augroup end
|
||||
|
||||
" https://github.com/neoclide/coc.nvim#example-vim-configuration
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
|
||||
" gd - go to definition of word under cursor
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
|
||||
" gi - go to implementation
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
|
||||
" gr - find references
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" gh - get hint on whatever's under the cursor
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
nnoremap <silent> gh :call <SID>show_documentation()<CR>
|
||||
|
||||
function! s:show_documentation()
|
||||
if &filetype == 'vim'
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" " Highlight symbol under cursor on CursorHold
|
||||
" autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
nnoremap <silent> <leader>co :<C-u>CocList outline<cr>
|
||||
nnoremap <silent> <leader>cs :<C-u>CocList -I symbols<cr>
|
||||
|
||||
" List errors
|
||||
nnoremap <silent> <leader>cl :<C-u>CocList locationlist<cr>
|
||||
|
||||
" list commands available in tsserver (and others)
|
||||
nnoremap <silent> <leader>cc :<C-u>CocList commands<cr>
|
||||
|
||||
" restart when tsserver gets wonky
|
||||
nnoremap <silent> <leader>cR :<C-u>CocRestart<CR>
|
||||
|
||||
" view all errors
|
||||
nnoremap <silent> <leader>cl :<C-u>CocList locationlist<CR>
|
||||
|
||||
" manage extensions
|
||||
nnoremap <silent> <leader>cx :<C-u>CocList extensions<cr>
|
||||
|
||||
" rename the current word in the cursor
|
||||
nmap <leader>cr <Plug>(coc-rename)
|
||||
nmap <leader>cf <Plug>(coc-format-selected)
|
||||
vmap <leader>cf <Plug>(coc-format-selected)
|
||||
|
||||
" run code actions
|
||||
vmap <leader>ca <Plug>(coc-codeaction-selected)
|
||||
nmap <leader>ca <Plug>(coc-codeaction-selected)
|
Loading…
Reference in a new issue