junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
33.7k stars 1.9k forks source link

Multiple post install commands with "do" #1243

Closed PezCoder closed 1 year ago

PezCoder commented 1 year ago

What?

I have a usecase where as part of installing coc.nvim through Plug, I want to specify multiple dependencies to be installed which are:

  1. :CocInstall <bunch of plugins>
  2. !brew install watchman I'm unsure in terms of how to do that as do only support providing a single command.

Minimal config

call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': ':CocInstall coc-tsserver coc-json coc-css coc-html coc-pyright coc-styled-components'}
" I want to add 'brew install watchman' as a dependency when coc.nvim is installed
call plug#end()

:version

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@Mac-1650023513425.local
ghost commented 1 year ago

coc.nvim, there is a variable called g:coc_global_extensions, and you can use that variable to automatically install LS.

so, you can write only brew install watchman to do of vim-plug

junegunn commented 1 year ago

You can specify a function as the post-update hook.

See https://github.com/junegunn/vim-plug/issues/944

PezCoder commented 1 year ago

Ah thanks, this worked! Thanks!

This is what I used for the above usecase:

" How post update hook works
" https://github.com/junegunn/vim-plug/blob/master/README.md#post-update-hooks
function! PostInstallCocNvim(info)
  if a:info.status == 'installed' || a:info.force
    !brew install watchman
    CocInstall coc-tsserver  "... other plugins
  endif
endfunction

Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': function('PostInstallCocNvim') }