Compare commits

...

5 commits

Author SHA1 Message Date
0fbce67a99 home: vim: lspconfig: migrate to 'bashls'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
Since `none-ls` has removed their `shellcheck` built-in. This actually
makes the diagnostics more robust to POSIX/non-POSIX scripts (the LSP
server detects it at runtime, which is more robust than the `ftdetect`
scripts).

Nice bonus: the shellcheck code is shown in the diagnostics message
without any configuration!

I'm not sure if I can configure `avoid-nullary-conditions` -- though it
seems like this check is broken at the moment (I couldn't get it to
trigger during my tests).
2024-03-11 12:23:50 +00:00
e3d7847679 home: vim: lspconfig: add 'hls'
If I ever end up actually learning it...
2024-03-11 12:04:41 +00:00
3a66e25ae2 home: vim: lspconfig: add 'ruff-lsp'
Since everybody is moving towards using it instead of other linters...
2024-03-11 12:01:19 +00:00
c23185ef25 home: vim: fix none-ls breaking changes
The end goal would be to remove none-ls-shellcheck-nvim, and migrate to
bashls (if it supports POSIX/non-POSIX satisfyingly).

Similarly, I should add a Haskell language server (if I ever actually
sit down to learn it...). And test out `ruff` as a `flake8` replacement.
2024-03-11 11:53:21 +00:00
bc64e43590 overlays: add none-ls-shellcheck-nvim 2024-03-11 11:52:42 +00:00
5 changed files with 44 additions and 51 deletions

View file

@ -105,7 +105,7 @@ in
nixpkgs-fmt
# Shell
shellcheck
nodePackages.bash-language-server
shfmt
];
};

View file

@ -29,6 +29,14 @@ if utils.is_executable("clangd") then
})
end
-- Haskell
if utils.is_executable("haskell-language-server-wrapper") then
lspconfig.hls.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Nix
if utils.is_executable("nil") then
lspconfig.nil_ls.setup({
@ -52,6 +60,13 @@ if utils.is_executable("pyright") then
})
end
if utils.is_executable("ruff-lsp") then
lspconfig.ruff_lsp.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Rust
if utils.is_executable("rust-analyzer") then
lspconfig.rust_analyzer.setup({
@ -59,3 +74,12 @@ if utils.is_executable("rust-analyzer") then
on_attach = lsp.on_attach,
})
end
-- Shell
if utils.is_executable("bash-language-server") then
lspconfig.bashls.setup({
filetypes = { "bash", "sh", "zsh" },
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end

View file

@ -28,14 +28,6 @@ null_ls.register({
}),
})
-- Haskell
null_ls.register({
null_ls.builtins.formatting.brittany.with({
-- Only used if available
condition = utils.is_executable_condition("brittany"),
}),
})
-- Nix
null_ls.register({
null_ls.builtins.formatting.nixpkgs_fmt.with({
@ -50,16 +42,6 @@ null_ls.register({
-- Python
null_ls.register({
null_ls.builtins.diagnostics.flake8.with({
-- Only used if available, but prefer pflake8 if available
condition = function()
return utils.is_executable("flake8") and not utils.is_executable("pflake8")
end,
}),
null_ls.builtins.diagnostics.pyproject_flake8.with({
-- Only used if available
condition = utils.is_executable_condition("pflake8"),
}),
null_ls.builtins.diagnostics.mypy.with({
-- Only used if available
condition = utils.is_executable_condition("mypy"),
@ -81,22 +63,6 @@ null_ls.register({
-- Shell (non-POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
-- Restrict to bash and zsh
filetypes = { "bash", "zsh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message
diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test, use bash dialect
extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" },
-- Restrict to bash and zsh
filetypes = { "bash", "zsh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use bash dialect
@ -110,22 +76,6 @@ null_ls.register({
-- Shell (POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message
diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test
extra_args = { "-o", "avoid-nullary-conditions" },
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use POSIX

View file

@ -0,0 +1,4 @@
self: prev:
{
vimPlugins = prev.vimPlugins.extend (self.callPackage ./generated.nix { });
}

View file

@ -0,0 +1,15 @@
{ vimUtils, fetchFromGitHub }:
_final: _prev:
{
none-ls-shellcheck-nvim = vimUtils.buildVimPlugin {
pname = "none-ls-shellcheck.nvim";
version = "2024-02-28";
src = fetchFromGitHub {
owner = "gbprod";
repo = "none-ls-shellcheck.nvim";
rev = "1eed283a7ede771b522a0a9f30bb604f02f51d64";
sha256 = "1hs0q9a0xwyqml0bfmplk89f1dk4nyg6aapfarnx44zqiw1183kn";
};
meta.homepage = "https://github.com/gbprod/none-ls-shellcheck.nvim/";
};
}