Coc.nvim: Ability to declare coc extensions to have installed.

Created on 18 Dec 2018  路  5Comments  路  Source: neoclide/coc.nvim

It would be great to have coc extensions setup through configuration rather than manual :CocInstall my-extension commands. I'm un-opinionated as to how this would be accomplished, but I do see a few potential solutions right off the bat:

  • Minimal "wrapper" vim plugins for each extension (eg Plug 'neoclide/coc-extension' would suffice)
  • A variable that can be set in the vimrc file, eg: g:coc_extensions = [ 'json', 'rls', 'prettier', ...]

Or however feels best. Ideally, I'd like to be able to clone my vim config, run :PlugInstall, then :CocUpdate and have everything I need without needing to remember or write down which extensions I have installed.

enhancement

Most helpful comment

Would be cool to have builtin. I do it already through vim-plug though:

.vimrc#L23-L32 / .vimrc#L134-L150

function! PlugCoc(info) abort
  if a:info.status ==? 'installed' || a:info.force
    !yarn install
    call coc#util#install_extension(join(get(s:, 'coc_extensions', [])))
  elseif a:info.status ==? 'updated'
    !yarn install
    call coc#util#update()
  endif
  call PlugRemotePlugins(a:info)
endfunction

let s:coc_extensions = [
\   'coc-css',
\   'coc-rls',
\   'coc-html',
\   'coc-json',
\   'coc-pyls',
\   'coc-yaml',
\   'coc-emmet',
\   'coc-emoji',
\   'coc-vetur',
\   'coc-eslint',
\   'coc-prettier',
\   'coc-tsserver',
\   'coc-ultisnips'
\ ]
Plug 'neoclide/coc-neco'
Plug 'neoclide/coc.nvim', {'do': function('PlugCoc')}

All 5 comments

Would be cool to have builtin. I do it already through vim-plug though:

.vimrc#L23-L32 / .vimrc#L134-L150

function! PlugCoc(info) abort
  if a:info.status ==? 'installed' || a:info.force
    !yarn install
    call coc#util#install_extension(join(get(s:, 'coc_extensions', [])))
  elseif a:info.status ==? 'updated'
    !yarn install
    call coc#util#update()
  endif
  call PlugRemotePlugins(a:info)
endfunction

let s:coc_extensions = [
\   'coc-css',
\   'coc-rls',
\   'coc-html',
\   'coc-json',
\   'coc-pyls',
\   'coc-yaml',
\   'coc-emmet',
\   'coc-emoji',
\   'coc-vetur',
\   'coc-eslint',
\   'coc-prettier',
\   'coc-tsserver',
\   'coc-ultisnips'
\ ]
Plug 'neoclide/coc-neco'
Plug 'neoclide/coc.nvim', {'do': function('PlugCoc')}

@oblitum's code doesn't quite work. If you swap out !yarn install with cos#util#install() then it really breaks things since CoC.nvim isn't done installing at that point and dies.

It would be really nice to have a global variable or (better yet) a coc-settings.json setting for configuring the desired plugins.

It wouldn't have to do anything special (like uninstall plugins or anything), just do what @oblitum's code does.

The only special check should be if someone uses :CoCUninstall foobar that it check if the install list contains foobar and if it does it should warn the user that next install/upgrade will re-install that extension.

@docwhat, dunno what you mean by it not working since you change it? I use it as-is without issues.

@docwhat use coc#add_extension

W00T! Thanks, @chemzqm.

...

Whups, I found a bug: #353 :cry:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andys8 picture andys8  路  3Comments

LinArcX picture LinArcX  路  4Comments

aareman picture aareman  路  3Comments

iago-lito picture iago-lito  路  3Comments

skylite21 picture skylite21  路  3Comments