AddOption("linter", true)
end
-MakeCommand("lint", "linter.runLinter", 0)
+MakeCommand("lint", "linter.lintCommand", 0)
-function runLinter()
+function lintCommand()
CurView():Save(false)
- local ft = CurView().Buf.FileType
+ runLinter()
+end
+
+function runLinter()
+ local ft = CurView().Buf:FileType()
local file = CurView().Buf.Path
local devnull = "/dev/null"
if OS == "windows" then
elseif ft == "lua" then
lint("luacheck", "luacheck --no-color " .. file, "%f:%l:%d+: %m")
elseif ft == "python" then
- lint("pyflakes", "pyflakes " .. file, "%f:%l: %m")
+ lint("pyflakes", "pyflakes " .. file, "%f:%l:.-:? %m")
elseif ft == "c" then
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
elseif ft == "d" then
end
end
-function onSave()
+function onSave(view)
if GetOption("linter") then
runLinter()
else
function onExit(output, linter, errorformat)
local lines = split(output, "\n")
- local regex = errorformat:gsub("%%f", "(.+)"):gsub("%%l", "(%d+)"):gsub("%%m", "(.+)")
+ local regex = errorformat:gsub("%%f", "(..-)"):gsub("%%l", "(%d+)"):gsub("%%m", "(.+)")
for _,line in ipairs(lines) do
-- Trim whitespace
line = line:match("^%s*(.+)%s*$")