nvim: Replace null-ls with nvim-lint
Fully replaced null-ls. Will need more tweaking on the nvim-lint setup but works generally for now. Works well in tandem with conform formatter.
This commit is contained in:
parent
5ccf8bc1fc
commit
ab06ef922b
3 changed files with 55 additions and 62 deletions
|
|
@ -59,7 +59,7 @@ local function on_attach(client, bufnr)
|
|||
{ buffer = bufnr, desc = "Next error" }
|
||||
)
|
||||
|
||||
require("which-key").register({ ["<localleader>l"] = { name = "+lsp" } })
|
||||
require("which-key").register({ ["<localleader>l"] = { name = "+language" } })
|
||||
map(
|
||||
"n",
|
||||
"<localleader>ld",
|
||||
|
|
@ -136,23 +136,22 @@ lspconfig.nushell.setup({})
|
|||
local python_path
|
||||
-- ensure python virtualenv is determined automatically on lsp start
|
||||
lspconfig.pyright.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
if python_path == nil then
|
||||
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||
end
|
||||
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||
client.config.settings.python.pythonPath = python_path
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
on_attach = function(client, bufnr)
|
||||
if python_path == nil then
|
||||
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||
end
|
||||
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||
client.config.settings.python.pythonPath = python_path
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
})
|
||||
lspconfig.ruff_lsp.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
if python_path == nil then
|
||||
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||
end
|
||||
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||
client.config.settings.python.pythonPath = python_path
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
@ -163,44 +162,3 @@ if require("util").is_available("arduino") then
|
|||
})
|
||||
end
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
null_ls.setup({})
|
||||
require("mason-null-ls").setup({
|
||||
ensure_installed = { "black", "prettier", "shfmt", "eslint-lsp", "stylua", "jq", "vale", "markdownlint" },
|
||||
automatic_installation = false,
|
||||
handlers = {
|
||||
shfmt = function(_, _)
|
||||
null_ls.register(null_ls.builtins.formatting.shfmt.with({
|
||||
extra_filetypes = { "bash", "zsh" },
|
||||
}))
|
||||
end,
|
||||
prettier = function(_, _)
|
||||
null_ls.register(null_ls.builtins.formatting.prettier.with({
|
||||
extra_filetypes = { "astro" },
|
||||
disabled_filetypes = { "markdown" },
|
||||
timeout = 7000,
|
||||
}))
|
||||
end,
|
||||
eslint = function(_, _)
|
||||
null_ls.register(null_ls.builtins.diagnostics.eslint.with({
|
||||
extra_filetypes = { "astro" },
|
||||
}))
|
||||
null_ls.register(null_ls.builtins.code_actions.eslint.with({
|
||||
extra_filetypes = { "astro" },
|
||||
}))
|
||||
end,
|
||||
markdownlint = function(_, _)
|
||||
null_ls.register(null_ls.builtins.diagnostics.markdownlint.with({
|
||||
extra_filetypes = { "quarto" },
|
||||
}))
|
||||
end,
|
||||
vale = function(_, _)
|
||||
null_ls.register(null_ls.builtins.diagnostics.vale.with({
|
||||
condition = function(utils)
|
||||
return (utils.root_has_file({ ".vale.ini", "_vale.ini" }) and utils.root_has_file({ "styles/" }))
|
||||
end,
|
||||
}))
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -55,14 +55,6 @@ return {
|
|||
"williamboman/mason-lspconfig.nvim",
|
||||
cmd = { "LspInstall", "LspUninstall" },
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"jay-babu/mason-null-ls.nvim",
|
||||
},
|
||||
event = "VeryLazy",
|
||||
},
|
||||
},
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
|
|
@ -75,6 +67,50 @@ return {
|
|||
} },
|
||||
},
|
||||
|
||||
-- linting setup
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
config = function()
|
||||
local linters = {
|
||||
astro = {},
|
||||
bash = {},
|
||||
javascript = {},
|
||||
javascriptreact = {},
|
||||
markdown = {},
|
||||
quarto = {},
|
||||
sh = {},
|
||||
svelte = {},
|
||||
text = {},
|
||||
typescript = {},
|
||||
typescriptreact = {},
|
||||
}
|
||||
local per_cmd = function(cmd, ft_table)
|
||||
if vim.fn.executable(cmd) == 1 then
|
||||
for _, v in pairs(ft_table) do
|
||||
table.insert(v, cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
per_cmd("markdownlint", { linters.markdown })
|
||||
per_cmd("vale", { linters.markdown, linters.text, linters.quarto })
|
||||
per_cmd("shellcheck", { linters.sh, linters.bash })
|
||||
per_cmd("eslint_d", {
|
||||
linters.astro,
|
||||
linters.javascript,
|
||||
linters.javascriptreact,
|
||||
linters.svelte,
|
||||
linters.typescript,
|
||||
linters.typescriptreact,
|
||||
})
|
||||
require("lint").linters_by_ft = linters
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost", "InsertLeave" }, {
|
||||
callback = function()
|
||||
require("lint").try_lint()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
},
|
||||
|
||||
-- formatting setup
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue