-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/add-pmd-linter
- Loading branch information
Showing
6 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
local severities = { | ||
Error = vim.diagnostic.severity.ERROR, | ||
Warning = vim.diagnostic.severity.WARN, | ||
} | ||
|
||
return { | ||
cmd = "sqruff", | ||
stdin = true, | ||
args = { | ||
"lint", | ||
"--format=json", | ||
"-", | ||
}, | ||
ignore_exitcode = true, | ||
parser = function(output, _) | ||
if vim.trim(output) == "" or output == nil then | ||
return {} | ||
end | ||
|
||
local decoded = vim.json.decode(output) | ||
local diagnostics = {} | ||
local messages = decoded["<string>"] | ||
|
||
for _, msg in ipairs(messages or {}) do | ||
table.insert(diagnostics, { | ||
lnum = msg.range.start.line - 1, | ||
end_lnum = msg.range["end"].line - 1, | ||
col = msg.range.start.character - 1, | ||
end_col = msg.range["end"].character - 1, | ||
message = msg.message, | ||
code = msg.code, | ||
source = msg.source, | ||
severity = assert(severities[msg.severity], "missing mapping for severity " .. msg.severity), | ||
}) | ||
end | ||
|
||
return diagnostics | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
local binary_name = "ts-standard" | ||
local pattern = "[^:]+:(%d+):(%d+):([^%.]+%.?)%s%(([%a-]+)%)%s?%(?(%a*)%)?" | ||
local groups = { "lnum", "col", "message", "code", "severity" } | ||
local severities = { | ||
[""] = vim.diagnostic.severity.ERROR, | ||
["warning"] = vim.diagnostic.severity.WARN, | ||
} | ||
|
||
return { | ||
cmd = function() | ||
local local_binary = vim.fn.fnamemodify("./node_modules/.bin/" .. binary_name, ":p") | ||
return vim.loop.fs_stat(local_binary) and local_binary or binary_name | ||
end, | ||
stdin = true, | ||
args = { "--stdin" }, | ||
ignore_exitcode = true, | ||
parser = require("lint.parser").from_pattern(pattern, groups, severities, { ["source"] = "ts-standard" }, {}), | ||
} |