Skip to content

Lazy load a plugin given a command pattern ? #1784

Closed Answered by blob42
blob42 asked this question in Q&A
Discussion options

You must be logged in to vote

This is my solution so far if anyone encounters the same issue.

'tpope/vim-fugitive',
    init = function(_)
      vim.api.nvim_create_autocmd('CmdlineLeave', {
        group = vim.api.nvim_create_augroup('lazy_manual', { clear = true }),
        pattern = '*',
        callback = function()
          local cmdline = vim.fn.getcmdline()
          if cmdline:match '^G.*' then
            require('lazy').load { plugins = { 'vim-fugitive' } }
          end
        end,
      })
    end,
    lazy = true,
    ...
  },

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by blob42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant