mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-28 22:08:12 +09:00
Add boolean option to actions to disable the lua callback
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user