Skip to content

Commit 771b841

Browse files
committed
plugin: linter: Use new onBufferOptionChanged callback
1 parent 415ceee commit 771b841

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

runtime/plugins/linter/linter.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,32 @@ function onSave(bp)
141141
return true
142142
end
143143

144+
function onBufferOptionChanged(buf, option, old, new)
145+
if option == "filetype" then
146+
if old ~= new then
147+
for k, v in pairs(linters) do
148+
local ftmatch = old == v.filetype
149+
if v.domatch then
150+
ftmatch = string.match(old, v.filetype)
151+
end
152+
153+
local hasOS = contains(v.os, runtime.GOOS)
154+
if not hasOS and v.whitelist then
155+
ftmatch = false
156+
end
157+
if hasOS and not v.whitelist then
158+
ftmatch = false
159+
end
160+
161+
if ftmatch then
162+
buf:ClearMessages(k)
163+
end
164+
end
165+
end
166+
end
167+
return true
168+
end
169+
144170
function lint(buf, linter, cmd, args, errorformat, loff, coff, callback)
145171
buf:ClearMessages(linter)
146172

0 commit comments

Comments
 (0)