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

Load plugins using denops.vim lazily #755

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

delphinus
Copy link

Denops is an ecosystem of Vim/Neovim which allows developers to write plugins in Deno.

https://vim-denops.github.io/denops-documentation/

This PR enables packer.nvim to load denops.vim plugins lazily. Such plugins can be used after the deno process has started and denops.vim has finished the initialization. packer.load can wait for them with this patch.

I have used the logic from dein.vim for reference to achieve this.

examples to use this
-- fuzzy-motion.vim needs denops.vim to be loaded before itself. I want to load
-- it lazily when 's' is pressed in the Normal mode.

{
  {'vim-denops/denops.vim'},

  {
    'yuki-yano/fuzzy-motion.vim',
    cmd = {'FuzzyMotion'},
    setup = function()
      vim.api.nvim_set_keymap('n', 's', '<Cmd>FuzzyMotion<CR>')
    end,
  },
}

-- You can load denops.vim lazily itself with `wants` option.

{
  {'vim-denops/denops.vim', opt = true},

  {
    'yuki-yano/fuzzy-motion.vim',
    cmd = {'FuzzyMotion'},
    wants = {'denops.vim'},
    setup = function()
      vim.api.nvim_set_keymap('n', 's', '<Cmd>FuzzyMotion<CR>')
    end,
  },
}

@delphinus
Copy link
Author

FYI: plugins using denops.vim can be found here.

@wbthomason
Copy link
Owner

Thanks, and sorry for taking so long to get to this. Is the idea that this will automatically load the Deno parts of any plugins which have them? I apologize for my confusion; I'm not familiar with denops/its uses.

@delphinus
Copy link
Author

@wbthomason Thank you for reviewing.

Usually, denops.vim automatically discovers other plugins using denops and load them.

https://github.com/vim-denops/denops.vim/blob/4e694e1ebd868e7448e7f6f82e844c88719f0756/plugin/denops.vim#L22-L22

But this func (denops#plugin#discover()) is called only once in loading denops.vim itself. So we should make denops.vim discover plugins we want to load lazily by calling denops#plugin#register() manually.

dein.vim does this the same things above here.

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

Successfully merging this pull request may close these issues.

None yet

2 participants