is "BufRead <file>" a valid event? #122
{
'crates.nvim',
for_cat = 'rust',
event = "BufRead Cargo.toml", -- is this even valid?
after = function ()
require('crates').setup()
end
}, |
Replies: 1 comment 2 replies
|
Yes. this is correct event spec useage {
'crates.nvim',
for_cat = 'rust',
event = "BufRead Cargo.toml",
after = function ()
require('crates').setup()
end
},as would this {
'crates.nvim',
for_cat = 'rust',
event = {
{ event = "BufRead", pattern = "Cargo.toml", }
},
after = function ()
require('crates').setup()
end
},To be honest, I thought it would fail at first glance, because when I do this in an autocommand on BufRead But yes. Should be valid. I tested it just now with {
"TEST_SPEC",
load = function(name)
print("Hello from " .. name)
end,
event = {
{ event = "BufRead", pattern = "Cargo.toml" }
}
}and also with {
"TEST_SPEC",
load = function(name)
print("Hello from " .. name)
end,
event = "BufRead Cargo.toml",
}Both print when I enter a Cargo.toml file. If you are having errors, I'm not 100% sure what it would be, do you have a message of some kind? One thing to keep in mind is that BufRead is before filetype event? Maybe it is the wrong event to load the plugin on, or But yeah, the easiest way to test triggers IMO is to make a fake spec which prints instead of its normal load spec (which calls |
Yes.
this is correct event spec useage
{ 'crates.nvim', for_cat = 'rust', event = "BufRead Cargo.toml", after = function () require('crates').setup() end },as would this
{ 'crates.nvim', for_cat = 'rust', event = { { event = "BufRead", pattern = "Cargo.toml", } }, after = function () require('crates').setup() end },To be honest, I thought it would fail at first glance, because when I do this in an autocommand on BufRead
callback = function (e) print(vim.inspect(e)) endit says it provides an absolute path for the pattern field. I forgot that its a P…