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
|
@ -40,19 +40,18 @@
|
|||
"markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" },
|
||||
"markmap.nvim": { "branch": "main", "commit": "3befc2a54c2448a16c30c1c7762aab263f22946a" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "4eb8e15e3c0757303d4c6dea64d2981fc679e990" },
|
||||
"mason-null-ls.nvim": { "branch": "main", "commit": "d1f7258f80867f718d643d88eee66959671a4bef" },
|
||||
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
|
||||
"mdeval.nvim": { "branch": "master", "commit": "2654caf8ecaad702b50199d18e39cff23d81e0ba" },
|
||||
"mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" },
|
||||
"molten-nvim": { "branch": "main", "commit": "93f2f168e77cbd82a881e07030cdbd45a48ed070" },
|
||||
"neotest": { "branch": "master", "commit": "009328955066ae6c170d24bb0de5f168d8760ff8" },
|
||||
"neotest-python": { "branch": "master", "commit": "81d2265efac717bb567bc15cc652ae10801286b3" },
|
||||
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
||||
"nvim-FeMaco.lua": { "branch": "main", "commit": "6af458f0196215f397db31a6e1fb2df795811693" },
|
||||
"nvim-base16": { "branch": "master", "commit": "96e308958625a84940d5e443475465abf99c7bd9" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" },
|
||||
"nvim-coverage": { "branch": "main", "commit": "cf4b5c61dfac977026a51a2bcad9173c272986ce" },
|
||||
"nvim-lint": { "branch": "master", "commit": "849ccb610de3f6ce1a239ea1e68568ef1a53d5df" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "cf3dd4a290084a868fac0e2e876039321d57111c" },
|
||||
"nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
|
||||
"nvim-surround": { "branch": "main", "commit": "703ec63aa798e5e07d309b35e42def34bebe0174" },
|
||||
|
|
|
@ -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…
Reference in a new issue