Add support for job control

This commit adds support for job control (running processes
asynchronously from plugins) with the JobStart, JobSend, and JobStop
functions (copying neovim's job control).

This commit also makes the linter plugin work asynchronously, so the
editor won't be frozen while the linter checks your code for errors.
This commit is contained in:
Zachary Yedidia
2016-06-15 11:19:00 -04:00
parent ceb5760d6d
commit d2277a376a
6 changed files with 118 additions and 15 deletions

View File

@@ -34,9 +34,11 @@ end
function linter_lint(linter, cmd, errorformat)
CurView():ClearGutterMessages(linter)
local handle = io.popen("(" .. cmd .. ")" .. " 2>&1")
local lines = linter_split(handle:read("*a"), "\n")
handle:close()
JobStart(cmd, "", "", "linter_onExit", linter, errorformat)
end
function linter_onExit(output, linter, errorformat)
local lines = linter_split(output, "\n")
local regex = errorformat:gsub("%%f", "(.+)"):gsub("%%l", "(%d+)"):gsub("%%m", "(.+)")
for _,line in ipairs(lines) do