Skip to content

Multiple linters won't spawn properly #136

@UnderCooled

Description

@UnderCooled

I think you should put coroutine in for loop.

My modification in lint.lua:

-- NOTE: From for loop in coroutine to coroutine in for loop
  for i, lint in ipairs(linters) do
    lint = vim.deepcopy(lint)
    lint.args = lint.args or {}
    lint.args[#lint.args + 1] = fname
    lint.lines = prev_lines
    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
        -- FIXME: without changed namespace id, the first linter diag message will be override by the second.
        vd.set(ns + i, buf, results)
      end)
    end)
    coroutine.resume(co)
  end

"Working" example:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions