require("lint").linters.cython = {
name = "cython",
cmd = "cython",
stdin = false, -- or false if it doesn't support content input via stdin. In that case the filename is automatically added to the arguments.
append_fname = true, -- Automatically append the file name to `args` if `stdin = false` (default: true)
-- add time to the output file
args = { "-Wextra", "-o", ".cython_linter_output" }, -- list of arguments. Can contain functions with zero arguments that will be evaluated once the linter is used.
stream = "both", -- ('stdout' | 'stderr' | 'both') configure the stream to which the linter outputs the linting result.
ignore_exitcode = true, -- set this to true if the linter exits with a code != 0 and that's considered normal.
env = nil, -- custom environment table to use with the external process. Note that this replaces the *entire* environment, it is not additive.
parser = function(output, bufnr, cwd)
local result = {}
local pattern1 = "([%w ]*):? ?([^:]+):(%d+):(%d+): (.+)"
local pattern2 = "([^:]+):(%d+):(%d+): (.+)"
for line in output:gmatch("[^\n]+") do
local severities = {
["error"] = vim.diagnostic.severity.ERROR,
["warning"] = vim.diagnostic.severity.WARN,
["information"] = vim.diagnostic.severity.INFO,
["performance hint"] = vim.diagnostic.severity.HINT,
}
local file, lnum, col, message
local severity = line:match("^[^:]+")
if severity == "warning" or severity == "information" or severity == "performance hint" then
severity, file, lnum, col, message = line:match(pattern1)
else
severity = "error"
file, lnum, col, message = line:match(pattern2)
end
if file then
local diagnostic = {
bufnr = bufnr,
file = file,
lnum = tonumber(lnum) - 1,
col = tonumber(col),
message = message,
severity = severities[severity],
source = "cython",
}
table.insert(result, diagnostic)
end
end
return result
end,
}