fixing
This commit is contained in:
@@ -3,6 +3,56 @@ return {
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
local lint = require("lint")
|
||||
local api = vim.api
|
||||
local keymap = vim.keymap
|
||||
|
||||
lint.linters.dbml = {
|
||||
cmd = "dbml",
|
||||
args = { "lint" },
|
||||
stdin = false,
|
||||
stream = "stdout",
|
||||
ignore_exitcode = true,
|
||||
parser = function(output, bufnr)
|
||||
local diagnostics = {}
|
||||
for line in output:gmatch("[^\r\n]+") do
|
||||
local lnum, col, msg = line:match("(%d+):(%d+):%s*(.*)")
|
||||
if lnum and msg then
|
||||
table.insert(diagnostics, {
|
||||
bufnr = bufnr,
|
||||
lnum = tonumber(lnum) - 1,
|
||||
col = tonumber(col) - 1,
|
||||
message = msg,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
})
|
||||
end
|
||||
end
|
||||
return diagnostics
|
||||
end,
|
||||
}
|
||||
|
||||
lint.linters.sqlfluff = {
|
||||
cmd = "sqlfluff",
|
||||
args = { "lint", "--format", "json" },
|
||||
stdin = false,
|
||||
stream = "stdout",
|
||||
ignore_exitcode = true,
|
||||
parser = function(output, bufnr)
|
||||
local diagnostics = {}
|
||||
local parsed = vim.fn.json_decode(output)
|
||||
if parsed and parsed[1] and parsed[1].violations then
|
||||
for _, issue in ipairs(parsed[1].violations) do
|
||||
table.insert(diagnostics, {
|
||||
bufnr = bufnr,
|
||||
lnum = issue.line_no - 1,
|
||||
col = issue.line_pos - 1,
|
||||
message = issue.description,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
})
|
||||
end
|
||||
end
|
||||
return diagnostics
|
||||
end,
|
||||
}
|
||||
|
||||
lint.linters_by_ft = {
|
||||
javascript = { "eslint_d" },
|
||||
@@ -11,18 +61,20 @@ return {
|
||||
typescriptreact = { "eslint_d" },
|
||||
svelte = { "eslint_d" },
|
||||
python = { "pylint" },
|
||||
dbml = { "dbml" },
|
||||
sql = { "sqlfluff" },
|
||||
}
|
||||
|
||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||
local lint_augroup = api.nvim_create_augroup("lint", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
group = lint_augroup,
|
||||
callback = function()
|
||||
lint.try_lint()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>l", function()
|
||||
keymap.set("n", "<leader>l", function()
|
||||
lint.try_lint()
|
||||
end, { desc = "Trigger linting for current file" })
|
||||
end,
|
||||
|
||||
Reference in New Issue
Block a user