Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On demand loading with user defined commands? #1261

Closed
shmerl opened this issue Jan 10, 2024 · 2 comments
Closed

On demand loading with user defined commands? #1261

shmerl opened this issue Jan 10, 2024 · 2 comments

Comments

@shmerl
Copy link

shmerl commented Jan 10, 2024

I'm trying to load a few plugins based on a custom command. So I defined something like this:

" Command to trigger loading of debugging related plugins on-demand
command LoadDebug echo 'Loading debug plugins'
...

And then in the vim-plug section, I was doing this:

" DAP debugging support
Plug 'mfussenegger/nvim-dap', { 'on': 'LoadDebug' }
Plug 'rcarriga/nvim-dap-ui', { 'on': 'LoadDebug' }

But it doesn't work. It does work with some other commands defined by plugins themselves. Is there a way to make it work or may be I'm missing something?

  • Type:
    • [✓] Bug
  • OS:
    • [✓] Linux
  • Vim:
    • [✓] Neovim
@wookayin
Copy link
Contributor

vim-plug currently can't source lua plugins when lazy-loaded. #1157

@junegunn
Copy link
Owner

junegunn commented Feb 24, 2024

#1157 is now merged. Thanks @wookayin


Plug 'mfussenegger/nvim-dap', { 'on': 'LoadDebug' }

That's not how you do it. When you write { 'on': 'LoadDebug' }, vim-plug defines a proxy command in that name which loads the plugin and executes the command from the loaded plugin.

Instead, you can pass an empty array as on so that the plugins are not loaded, and call plug#load from your command to load those plugins later.

Plug 'mfussenegger/nvim-dap', { 'on': [] }
Plug 'rcarriga/nvim-dap-ui', { 'on': [] }

command! LoadDebug call plug#load('nvim-dap', 'nvim-dap-ui')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants