Don't enable shellcheck linting by default
Zeioth opened this issue · comments
Zeioth commented
What is the problem this feature will solve?
On neovim, when installing bash-language-server
along with shellcheck
, this triggers linting two times.
What is the feature you are proposing to solve the problem?
Make shellcheck linting disabled by default, and opt-in. As linting is the responsability of a linter, not the responsability of a lsp server.
Screenshot
Zeioth commented
Ok after further research I managed to disable it with
local lsp_opts = {}
if server_name == "bashls" then -- by default disable shellcheck
lsp_opts.settings = { bashIde = { shellcheckPath = "" } }
end
And while that keep the lsp capabilities, it disables the bash-language-server code actions for code fixes, which I find super valuable. So I'm closing this.
Zeioth commented
In case someone is interested, this is how I made compatilbe bash-language-server
and shellcheck
on my neovim config:
null-ls
-- null-ls [lsp code formatting]
-- https://github.com/nvimtools/none-ls.nvim
{
"nvimtools/none-ls.nvim",
dependencies = {
{
"jay-babu/mason-null-ls.nvim",
cmd = { "NullLsInstall", "NullLsUninstall" },
opts = { handlers = {} },
},
},
event = "BufEnter",
opts = function()
local nls = require "null-ls"
return {
sources = {
-- You can customize your formatters here.
nls.builtins.formatting.beautysh.with {
command = "beautysh",
args = { "--indent-size=2", "$FILENAME" },
},
-- TODO: Disable the next feature once this has been merged.
-- https://github.com/bash-lsp/bash-language-server/issues/933
nls.builtins.code_actions.shellcheck,
nls.builtins.diagnostics.shellcheck.with { diagnostics_format = "" },
},
on_attach = require("base.utils.lsp").on_attach,
}
end,
config = function(_, opts)
local nls = require "null-ls"
nls.setup(opts)
-- When running :LspStart, ensure null-ls starts too
vim.api.nvim_create_autocmd({ "LspAttach" }, {
desc = "Ensure null-ls run its sources a lsp client starts",
callback = function()
pcall(function() require("null-ls").enable({}) end)
end,
})
end
},
LSP config
if server_name == "bashls" then -- by default use mason shellcheck path
lsp_opts.settings = { bashIde = { shellcheckPath = vim.fn.stdpath "data" .. "/mason/bin/shellcheck" } }
end
This way bash-language-server
has all its normal capabilities and aditionally:
- Mason install shellcheck for us. (to eliminate external dependencies)
- Null ls disable diagnostics, but enable code actions. (to prevent double diagnostics + adding code actions for silencing rules)