X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=runtime%2Fplugins%2Flinter%2Flinter.lua;h=9fb347f50b1931a877db2e429748c3ab41ca3b6f;hb=e563211790e4819fc7a13aa279244550f5956876;hp=6cf07de73446771c56d9c36b9051624953d95799;hpb=8803d93872f15df346d8cd5c629ccd6a88d82da5;p=micro.git diff --git a/runtime/plugins/linter/linter.lua b/runtime/plugins/linter/linter.lua index 6cf07de7..9fb347f5 100644 --- a/runtime/plugins/linter/linter.lua +++ b/runtime/plugins/linter/linter.lua @@ -2,11 +2,15 @@ if GetOption("linter") == nil then 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 @@ -18,7 +22,7 @@ function runLinter() 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 @@ -30,7 +34,7 @@ function runLinter() end end -function onSave() +function onSave(view) if GetOption("linter") then runLinter() else @@ -47,7 +51,7 @@ end 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*$")