nvim-lint
nvim-lint copied to clipboard
rubocop is throwing an error
Using
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave", "TextChanged" }, { callback = function() require("lint").try_lint() end, })
i debugged the rubocop.lua, the output variable on InsertLeave / TextChanged is "", only saving works. I have added the stdin function:
local severity_map = {
['fatal'] = vim.diagnostic.severity.ERROR,
['error'] = vim.diagnostic.severity.ERROR,
['warning'] = vim.diagnostic.severity.WARN,
['convention'] = vim.diagnostic.severity.HINT,
['refactor'] = vim.diagnostic.severity.INFO,
['info'] = vim.diagnostic.severity.INFO,
}
return {
cmd = 'rubocop',
stdin = true,
args = { '--format', 'json', '--force-exclusion', '--stdin'},
ignore_exitcode = true,
parser = function(output)
local diagnostics = {}
local decoded = vim.json.decode(output)
if not decoded.files[1] then
return diagnostics
end
local offences = decoded.files[1].offenses
for _, off in pairs(offences) do
table.insert(diagnostics, {
source = 'rubocop',
lnum = off.location.start_line - 1,
col = off.location.start_column - 1,
end_lnum = off.location.last_line - 1,
end_col = off.location.last_column,
severity = severity_map[off.severity],
message = off.message,
code = off.cop_name
})
end
return diagnostics
end,
}
The error:
Using guard.nvim, the diagnostics works using the same cmd + args (always returns the output).
After fixing this (probably is not waiting enough for the diagnostics or something like that), i will make a PR to add the bundle_rubocop to the config (uses bundle to run rubocop installed on project instead of running from the shell), like i did on guard:
https://github.com/nvimdev/guard.nvim/blob/main/lua/guard/tools/linter/rubocop.lua
When I add Rubocop
as a linter for ruby / rails, nvim becomes really sluggish taking several seconds to save the file and nvim becomes unresponsive.
Can this be related to this issue?
When I add
Rubocop
as a linter for ruby / rails, nvim becomes really sluggish taking several seconds to save the file and nvim becomes unresponsive.Can this be related to this issue?
@kjvdven I seem to be having the same issue.