plugin: linter: Use new onBufferOptionChanged callback

This commit is contained in:
Jöran Karl 2024-12-29 13:22:35 +01:00
parent 415ceee46b
commit 771b84141f

View File

@ -141,6 +141,32 @@ function onSave(bp)
return true
end
function onBufferOptionChanged(buf, option, old, new)
if option == "filetype" then
if old ~= new then
for k, v in pairs(linters) do
local ftmatch = old == v.filetype
if v.domatch then
ftmatch = string.match(old, v.filetype)
end
local hasOS = contains(v.os, runtime.GOOS)
if not hasOS and v.whitelist then
ftmatch = false
end
if hasOS and not v.whitelist then
ftmatch = false
end
if ftmatch then
buf:ClearMessages(k)
end
end
end
end
return true
end
function lint(buf, linter, cmd, args, errorformat, loff, coff, callback)
buf:ClearMessages(linter)