You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before asking my question I was wondering if it would be a good idea to have (community contributed) collection of configs somewhere, index by plugins showing different ways to lazy load them? For many plugins I'm sometimes struggeling to find a good way to lazy load them. So I just thought it would be nice also for others to have a place where they can see examples and get ideas. Maybe this discussion section is a good place. Or maybe another repo packer.nvim-examples or similar :)
Anyway, I'm trying to figure out how to lazy load plugins/extensions of for example telescope or treesitter. For example I want to use zoxide.vim and telescope-zoxide with the following config:
which sort of works, except if I first want to use the telescope extension since there is nothing triggering the load (if I first do :Z it works fine). I tried to set keys = '<leader>nz' as commented out above but this doesn't work since it interferes with which-key. Any ideas how to do this better? cmd = Telescope zoxide list does not work and also not module = 'zoxide' since telescope does not actually call the module unless it's already registered.
Another issue I have is lazy loading a treesitter module on demand. For example I'm trying to setup a command to toggle nvim-ts-rainbow and only load it the first time since I found it slow to startup. I tried something like this:
use { -- treesitter {{{'nvim-treesitter/nvim-treesitter',
branch='0.5-compat',
run=':TSUpdate',
module='nvim-treesitter',
event="BufRead",
requires= {
{ -- rainbow brackets {{{ TODO how to lazy load properly?'p00f/nvim-ts-rainbow',
opt=true,
cmd='TSRainbowToggle',
-- after = 'nvim-treesitter',setup=function()
_G.ts= {
rainbow= {
enabled=false,
toggle=function()
ifts.rainbow.enabledthenprint('disable rainbow')
ts.rainbow.enable=falserequire'nvim-treesitter.configs'.setup {
rainbow= {enable=false},
}
elseprint('enable rainbow')
ts.rainbow.enable=truerequire'nvim-treesitter.configs'.setup {
rainbow= {enable=true},
}
endend
},
}
require('funcs.commands').define_commands({
TSRainbowToggle= {nargs=0, cmd='lua ts.rainbow.toggle()'},
})
end,
config=function() -- {{{-- require'nvim-treesitter.configs'.setup {-- rainbow = {enable = true},-- }vim.cmd("highlight! link rainbowcol1 GruvboxOrangeBold")
vim.cmd("highlight! link rainbowcol2 GruvboxPurpleBold")
vim.cmd("highlight! link rainbowcol3 GruvboxBlueBold")
vim.cmd("highlight! link rainbowcol4 GruvboxYellowBold")
vim.cmd("highlight! link rainbowcol5 GruvboxAquaBold")
vim.cmd("highlight! link rainbowcol6 GruvboxRedBold")
vim.cmd("highlight! link rainbowcol7 GruvboxGrayBold")
end, -- }}}
}, -- }}}
But the command TSRainbowToggle does not actually enable the module for some reason. And it also does not feel like the cleanest solution. Any thoughts also for this case how to do this properly?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Before asking my question I was wondering if it would be a good idea to have (community contributed) collection of configs somewhere, index by plugins showing different ways to lazy load them? For many plugins I'm sometimes struggeling to find a good way to lazy load them. So I just thought it would be nice also for others to have a place where they can see examples and get ideas. Maybe this discussion section is a good place. Or maybe another repo
packer.nvim-examples
or similar :)Anyway, I'm trying to figure out how to lazy load plugins/extensions of for example
telescope
ortreesitter
. For example I want to use zoxide.vim and telescope-zoxide with the following config:which sort of works, except if I first want to use the telescope extension since there is nothing triggering the load (if I first do
:Z
it works fine). I tried to setkeys = '<leader>nz'
as commented out above but this doesn't work since it interferes withwhich-key
. Any ideas how to do this better?cmd = Telescope zoxide list
does not work and also notmodule = 'zoxide'
since telescope does not actually call the module unless it's already registered.Another issue I have is lazy loading a treesitter module on demand. For example I'm trying to setup a command to toggle nvim-ts-rainbow and only load it the first time since I found it slow to startup. I tried something like this:
But the command
TSRainbowToggle
does not actually enable the module for some reason. And it also does not feel like the cleanest solution. Any thoughts also for this case how to do this properly?Thanks in advance! :)
Beta Was this translation helpful? Give feedback.
All reactions