]> git.lizzy.rs Git - micro.git/blobdiff - runtime/plugins/linter/linter.lua
Adding additional Python and Objective-C linting (#524)
[micro.git] / runtime / plugins / linter / linter.lua
index 9fb347f50b1931a877db2e429748c3ab41ca3b6f..88892797b5a48f1611cc973c96c0f7c1742d13f5 100644 (file)
@@ -13,24 +13,30 @@ function runLinter()
     local ft = CurView().Buf:FileType()
     local file = CurView().Buf.Path
     local devnull = "/dev/null"
+    local temp = os.getenv("TMPDIR")
     if OS == "windows" then
         devnull = "NUL"
+        temp = os.getenv("TEMP")
     end
     if ft == "go" then
-        lint("gobuild", "go build -o " .. devnull, "%f:%l: %m")
-        lint("golint", "golint " .. CurView().Buf.Path, "%f:%l:%d+: %m")
+        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")
+        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")
+        lint("mypy", "mypy", {file}, "%f:%l: %m")
+        lint("pylint", "pylint", {"--output-format=parseable", "--reports=no", file}, "%f:%l: %m")
     elseif ft == "c" then
-        lint("gcc", "gcc -fsyntax-only -Wall -Wextra " .. file, "%f:%l:%d+:.+: %m")
+        lint("gcc", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", file}, "%f:%l:%d+:.+: %m")
+    elseif ft == "Objective-C" then
+        lint("clang", "xcrun", {"clang", "-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")
+        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")
+        lint("javac", "javac", {"-d", temp, file}, "%f:%l: error: %m")
     elseif ft == "javascript" then
-        lint("jshint", "jshint " .. file, "%f: line %l,.+, %m")
+        lint("jshint", "jshint", {file}, "%f: line %l,.+, %m")
     end
 end
 
@@ -42,10 +48,10 @@ function onSave(view)
     end
 end
 
-function lint(linter, cmd, errorformat)
+function lint(linter, cmd, args, errorformat)
     CurView():ClearGutterMessages(linter)
 
-    JobStart(cmd, "", "", "linter.onExit", linter, errorformat)
+    JobSpawn(cmd, args, "", "", "linter.onExit", linter, errorformat)
 end
 
 function onExit(output, linter, errorformat)