Open againstpetra opened 3 months ago
Sounds like the output isn't JSON. Is it empty instead?
Could be that it needs a check like this:
diff --git a/lua/lint/linters/ktlint.lua b/lua/lint/linters/ktlint.lua
index a5d6880..7219803 100644
--- a/lua/lint/linters/ktlint.lua
+++ b/lua/lint/linters/ktlint.lua
@@ -3,16 +3,16 @@ return {
stdin = true,
args = { '--reporter=json', '--stdin' },
stream = 'stderr',
ignore_exitcode = true,
parser = function(output)
- local ktlint_output = vim.json.decode(output)
- if vim.tbl_isempty(ktlint_output) then
+ if output == "" then
return {}
end
+ local ktlint_output = vim.json.decode(output)
local diagnostics = {}
- for _, error in pairs(ktlint_output[1].errors) do
+ for _, error in ipairs((ktlint_output[1] or {}).errors or {}) do
table.insert(diagnostics, {
lnum = error.line - 1,
col = error.column - 1,
end_lnum = error.line - 1,
end_col = error.column - 1,
I'm seeing this error opening an android kotlin project:
running ktlint in command line works fine.