Closed aloknigam247 closed 1 year ago
You can use enabled
for that. It can be a function like your cond()
You can use enabled for that. It can be a function like your cond()
if the enabled function returns false lazy marks the plugins for clean. so if user runs clean or sync they'll be deleted. cond doesn't do that. I think that was the distinction between cond and disabled in packer.
I had it set so if NOTS
env set nothing related to tree-sitter gets loaded. in packer it was handled by cond. in lazy I'm reinstalling all the treesitter-related and dependent plugins plus all the parsers :/ . It'd be nice to avoid that.
Another difference is cond
can evaluate filetype after that file is loaded, while, enabled
evaluates too early.
I have vim-polyglot
enabled when the current buffer isn't empty. This will always evaluate to false no matter what the filetype is :/
enabled = function()
return vim.bo.filetype ~= '';
end,
(not relevant to this issue, it would be helpful if lazy.nvim
could load a plugin when the filetype is NOT a given table or string)
@Congee just use event="FileType"
for this
Ahh thanks, I was using event="VeryLazy"
😃
Be aware, that a of of plugins set filetypes like noice
, notify
, lualine
, etc, so that will pretty much make it load on startup anyway.
Better would be event="BufReadPre"
. That will only kick in when an actual file is being read.
Interesting, I switched to "BufReadPre". thanks for the pro tip 😁
@folke Another use case for this feature is when using neovim inside VSCode.
In that case, you want your treesitter, LSP, colorscheme, statusline, etc... plugins to load only when not running inside vscode but you don't want your plugin manager to uninstall/reinstall everything each time you switch editors. With packer you can do that with e.g.:
use {
'nvim-treesitter/nvim-treesitter',
cond = [[not vim.g.vscode]],
}
As @shadmansaleh mentioned, enabled
is not equivalent to packer's cond
or vim-plug's Cond
function.
It would be nice if lazy could support this feature.
Any alternative to cond in packer: my packer config usecase
load vim-oscyank only when connected via SSH