Skip to content

Commit

Permalink
fix(nvim): protolint (custom linter)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jun 1, 2024
1 parent 0614fc2 commit 44fe5b5
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions nvim-fredrik/lua/lang/protobuf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,42 @@ return {
},
},
ft = { "proto" },
opts = {
linters_by_ft = {
proto = { "buf_lint", "protolint", },
},
},
opts = function(_, opts)
opts.linters_by_ft["proto"] = { "buf_lint", "protolint" }

-- custom protolint definition
-- see: https://github.com/mfussenegger/nvim-lint#custom-linters
require("lint").linters.protolint = {
cmd = "protolint",
stdin = false,
append_fname = true,
args = { "lint", "--reporter=json" },
stream = "stderr",
ignore_exitcode = true,
env = nil,
parser = function(output)
if output == "" then
return {}
end
local json_output = vim.json.decode(output)
local diagnostics = {}
if json_output.lints == nil then
return diagnostics
end
for _, item in ipairs(json_output.lints) do
table.insert(diagnostics, {
lnum = item.line - 1,
col = item.column - 1,
message = item.message,
file = item.filename,
code = item.rule,
severity = vim.diagnostic.severity.WARN,
})
end
return diagnostics
end,
}
end,
},

{
Expand Down

0 comments on commit 44fe5b5

Please sign in to comment.