Closed deathlyfrantic closed 11 months ago
Filetype isn't supported as it's too error prone and most of the time it just isn't necessary anyway. If it is necessary then it is a bad plugin.
The docs need to be updated.
Fair enough - I can do without it. Thanks for the reply!
@lewis6991 I'm still using packer, but I think I will do something like this about filetype loader when I migrate to pckr, as I've found it useful for filetype specific plugins (nvim-jdtls, flutter-tools, nvim-metals, ...). Would you mind explaining what might go wrong with the following approach?
cond = function(load_plugin)
vim.api.nvim_creata_autocmd("FileType", {
pattern = { "sbt", "scala" },
group = vim.api.nvim_create_augroup("pckr/loader", { clear = false }),
callback = function(e)
load_plugin()
vim.api.nvim_exec_autocmds("FileType", { pattern = vim.bo[e.buf].filetype })
end,
once = true,
})
end
I use nvim-metals and I unconditionally load it since it doesn't contain a plugin/
dir. Then in my config block I have:
local function setup()
local metals = require'metals'
metals.initialize_or_attach(vim.tbl_deep_extend('force', metals.bare_config(), {
...
}))
end
vim.api.nvim_create_autocmd('FileType', {
pattern = {'scala', 'sbt'},
callback = setup
})
This avoids having to re-invoke FileType
which could cause issues. I don't think you need to re-invoke FileType
anyway for this case.
To re-iterate, if a plugin does not contain a plugin/
dir or has a small amount of code in plugin/
(which should be all plugins!), then there is little need to lazy load.
I'm trying to switch over to Pckr from Packer and from what I can tell, it looks like filetype conditions are not currently supported. Is that right? In the example in the readme, it's mentioned but not shown:
i.e.
I'm guessing this is leftover from the Packer fork. Is filetype support planned? Or does it exist and I'm just not seeing it? I don't see any code in
/lua/pckr/loader
that looks related but I'm not familiar with this codebase.Thanks!