-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple linters won't spawn properly #136
Comments
I am a bit confused, what is this issue about? Could you state the problem first. |
I add two linters to '*', the second one won't spawn, I'm using those I checked "format.lua", it's in same situation, forloop in coroutine, maybe that's why there is #113 exist. |
print("1")
coroutine.resume(coroutine.create(function()
os.execute("sleep 5")
print("2")
end))
print("3") On executing this would always print |
The second linter not spawning is due to, I believe, the broken fix I introduced in #134 , I apologize for it :( |
不好意思,请允许我再用中文问一下。不是专业学编程的,异步只接触过早期 nodejs 那些。 也就是 forloop 包在协程里面,相当与是异步顺序执行,然后我这样改就是异步并行? 如果是这样,那么 format.lua 中的顺序异步执行,有道理,不过 lint 的话,并行然后放在不同命名空间上是不是也行?毕竟两个 linter 之间可能没有顺序问题。 |
|
So we can get rid of "namespace" property in for _, lint in ipairs(linters) do
lint = vim.deepcopy(lint)
lint.args = lint.args or {}
lint.args[#lint.args + 1] = fname
lint.lines = prev_lines
-- print(lint.cmd)
-- NOTE: make namespace for each linter
local lns = api.nvim_create_namespace('Guard' .. lint.cmd)
-- NOTE: reset the specific namespace
vd.reset(lns, buf)
lint.cmd = vim.fn.exepath(lint.cmd)
-- print("create co for " .. lint.cmd)
local co = coroutine.create(function()
local results
-- print("lint " .. lint.cmd)
local data = spawn(lint)
-- print('got data:\n' .. data)
if #data > 0 then
results = lint.parse(data, buf)
end
-- print('got results')
vim.schedule(function()
if not api.nvim_buf_is_valid(buf) or not results or #results == 0 then
return
end
-- NOTE: add diags to the specific namespace
vd.set(lns, buf, results)
end)
end)
coroutine.resume(co)
end Checkout |
I think you should put coroutine in for loop.
My modification in
lint.lua
:"Working" example:
The text was updated successfully, but these errors were encountered: