Add boolean option to actions to disable the lua callback

This commit is contained in:
Zachary Yedidia
2016-08-17 14:16:27 -04:00
parent 8a58506c72
commit d17cc0f628
11 changed files with 395 additions and 250 deletions

View File

@@ -2,30 +2,37 @@ if GetOption("linter") == nil then
AddOption("linter", true)
end
MakeCommand("lint", "linter.runLinter", 0)
function runLinter()
CurView():Save(false)
local ft = CurView().Buf.FileType
local file = CurView().Buf.Path
local devnull = "/dev/null"
if OS == "windows" then
devnull = "NUL"
end
if ft == "Go" then
lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
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")
elseif ft == "C" then
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
elseif ft == "D" then
lint("dmd", "dmd -color=off -o- -w -wi -c " .. file, "%f%(%l%):.+: %m")
elseif ft == "Java" then
lint("javac", "javac " .. file, "%f:%l: error: %m")
elseif ft == "JavaScript" then
lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
end
end
function onSave()
if GetOption("linter") then
local ft = CurView().Buf.FileType
local file = CurView().Buf.Path
local devnull = "/dev/null"
if OS == "windows" then
devnull = "NUL"
end
if ft == "Go" then
lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
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")
elseif ft == "C" then
lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
elseif ft == "D" then
lint("dmd", "dmd -color=off -o- -w -wi -c " .. file, "%f%(%l%):.+: %m")
elseif ft == "Java" then
lint("javac", "javac " .. file, "%f:%l: error: %m")
elseif ft == "JavaScript" then
lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
end
runLinter()
else
CurView():ClearAllGutterMessages()
end