local lint = require("lint")
lint.linters.c_trencada = {
name = "c_trencada",
cmd = "cç",
args = {
"-check",
},
stdin = false,
stream = "stderr",
ignore_exitcode = true,
parser = function(output, bufnr, linter_cwd)
local match = function(buffer_path, line)
local matches = { line:match([[^(%S+):(%d+).(%d+)-(%d+): (%S+): (.+)$]]) }
if not next(matches) then
return nil
end
local file = matches[1]
local path
if string.match(file, "^%w:") or vim.startswith(file, "/") then
path = file
else
path = vim.fn.simplify(linter_cwd .. "/" .. file)
end
if vim.fs.normalize(path) ~= vim.fs.normalize(buffer_path) then
return nil
end
local lnum = tonumber(matches[2]) - 1
local line_text = vim.api.nvim_buf_get_lines(bufnr or 0, lnum, lnum + 1, false)[1]
local col = vim.str_byteindex(line_text, "utf-16", tonumber(matches[3]) - 1, false)
local end_col = vim.str_byteindex(line_text, "utf-16", tonumber(matches[4]) - 1, false)
local severity = matches[5]
local message = matches[6]
local severity_map = {
["Error"] = vim.lsp.protocol.DiagnosticSeverity.Error,
["Avís"] = vim.lsp.protocol.DiagnosticSeverity.Warning,
}
return {
lnum = lnum,
end_lnum = lnum,
col = col,
end_col = end_col,
severity = severity_map[severity],
message = message,
}
end
local result = {}
local buffer_path = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":p")
for line in vim.gsplit(output, "\n", true) do
local diagnostic = match(buffer_path, line, bufnr)
if diagnostic then
table.insert(result, diagnostic)
end
end
return result
end,
}
lint.linters_by_ft["c-trencada"] = { "c_trencada" }c-trencada/c-trencada.vim
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|