mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-16 22:10:26 +00:00
plugin: linter: Use new onBufferOptionChanged callback
This commit is contained in:
parent
415ceee46b
commit
771b84141f
1 changed files with 26 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue