vim-plug icon indicating copy to clipboard operation
vim-plug copied to clipboard

Grouping plugins for same filetypes

Open dracorp opened this issue 7 years ago • 5 comments

What is the best way to group plugins for same filetype? I wanted to use this:

if index(['pm','perl','xs'], &filetype) > -1
  Plug 'vim-perl/vim-perl'
  Plug 'vim-scripts/perl-support.vim'
endif

But it does not work. I want to avoid use multiply keyword for:

  Plug 'vim-perl/vim-perl', {'for',['perl','xs','pm']}
  Plug 'vim-scripts/perl-support.vim', {'for',['perl','xs','pm']}

Of course xs and pm files have same filetype: perl. This is only example.

Best regards Piotr

dracorp avatar Mar 04 '18 15:03 dracorp

What are you trying to achieve? Using for option for filetype-specific plugins is mostly unnecessary and discouraged. They are inherently designed to be loaded on demand, and an additional lazy loading mechanism from vim-plug is completely unnecessary for them.

See https://github.com/junegunn/vim-plug/wiki/faq#when-should-i-use-on-or-for-option

junegunn avatar Mar 05 '18 08:03 junegunn

Sometimes I don't need additional menu in Gvim. Sometimes there is a conflict in mapping. So using for option is useful. The above example (my code) is stupid or at least incorrect, but the question is still valid.

dracorp avatar Mar 05 '18 17:03 dracorp

Since Plug is the central piece for downloading plugins and placing them to be autoloaded, I think it is the perfect place to organize on demand rules.

For me it's not a matter of optimization. Can't always rely on plugin authors to implement specifically for certain file types and I wouldn't want them to. The scope for use cases and user preference is too big.

SephVelut avatar Sep 18 '18 04:09 SephVelut

Related: I've tried and failed to split Plug calls into relevant ftplugins, problem being that plug#end() call would have to come after all the ftplugins are loaded.

Similarly, it would also be nice to group the non-filetype-specific Plug calls into files under plugin/ without explicitely sourcing them, relying on Vim runtime load order instead, but this has similar problems.

Loading plugs incrementally as per https://github.com/junegunn/vim-plug/issues/615 would likely solve this.

mwgkgk avatar Feb 23 '19 07:02 mwgkgk