mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2026-09-11 05:16:22 -07:00
update nvim
This commit is contained in:
@@ -1,39 +1,53 @@
|
||||
return {
|
||||
"mfussenegger/nvim-lint",
|
||||
event = { "BufNewFile", "BufReadPre" },
|
||||
config = function()
|
||||
local lint = require("lint")
|
||||
local parser = require("lint.parser")
|
||||
|
||||
lint.linters.pydoclint = {
|
||||
cmd = "pydoclint",
|
||||
args = { "--show-filenames-in-every-violation-message=true", "-q" },
|
||||
stdin = false,
|
||||
stream = "stderr",
|
||||
ignore_exitcode = true,
|
||||
parser = parser.from_pattern("(.+):(%d+): (DOC%d+): (.+)", { "file", "lnum", "code", "message" }, nil, {
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
source = "pydoclint",
|
||||
}),
|
||||
}
|
||||
local python_linters = { "ruff" }
|
||||
if vim.fn.executable("pydoclint") == 1 then
|
||||
table.insert(python_linters, "pydoclint")
|
||||
end
|
||||
|
||||
lint.linters_by_ft = {
|
||||
markdown = { "markdownlint" },
|
||||
lua = { "luacheck" },
|
||||
python = { "ruff" },
|
||||
sh = { "shellcheck" },
|
||||
json = { "jsonlint" },
|
||||
yaml = { "yamllint" },
|
||||
vim = { "vint" },
|
||||
go = { "golangcilint" },
|
||||
json = { "jsonlint" },
|
||||
lua = { "luacheck" },
|
||||
markdown = { "markdownlint" },
|
||||
python = python_linters,
|
||||
sh = { "shellcheck" },
|
||||
typescript = { "eslint" },
|
||||
typescriptreact = { "eslint" },
|
||||
vim = { "vint" },
|
||||
yaml = { "yamllint" },
|
||||
}
|
||||
lint.linters.jsonlint.cmd = "vscode-json-language-server"
|
||||
lint.linters.shellcheck.args = {
|
||||
"-s",
|
||||
"bash",
|
||||
"-o",
|
||||
"all",
|
||||
"-e",
|
||||
"2250",
|
||||
}
|
||||
-- Save original function
|
||||
local orig_try_lint = lint.try_lint
|
||||
|
||||
lint.try_lint = function(...)
|
||||
local opts = select(2, ...)
|
||||
local bufnr = (type(opts) == "table" and opts.bufnr) or vim.api.nvim_get_current_buf()
|
||||
if vim.api.nvim_get_option_value("buftype", { buf = bufnr }) ~= "" then
|
||||
return
|
||||
end
|
||||
return orig_try_lint(...)
|
||||
end
|
||||
lint.linters.shellcheck.args = { "-s", "bash", "-o", "all", "-e", "2250" }
|
||||
|
||||
local lint_group = vim.api.nvim_create_augroup("LintOnSave", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
group = lint_group,
|
||||
callback = function(args)
|
||||
if vim.bo[args.buf].buftype ~= "" then
|
||||
return
|
||||
end
|
||||
lint.try_lint(nil, { bufnr = args.buf })
|
||||
if vim.fn.executable("codespell") == 1 then
|
||||
lint.try_lint("codespell", { bufnr = args.buf })
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user