WIP stuff

Cba with commit messages
This commit is contained in:
NotAShelf 2024-10-16 05:42:01 +03:00
parent bd2743fb45
commit 6425e9cfb0
No known key found for this signature in database
GPG key ID: AF26552424E53993
2 changed files with 12 additions and 16 deletions

View file

@ -4,7 +4,8 @@
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.lists) isList optionals; inherit (lib.strings) optionalString;
inherit (lib.lists) optionals;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
@ -46,17 +47,21 @@ in {
# `on_attach`. # `on_attach`.
# TODO: nixpkgs-like doc comments from that one RFC # TODO: nixpkgs-like doc comments from that one RFC
mkLspConfig = { mkLspConfig = {
# Mandatory arguments
name, name,
package, package,
# Optional arguments for the sake of flexibility
args ? [], args ? [],
cmd ? [(getExe package)] ++ lib.optionals (args != []) args, cmd ? [(getExe package)] ++ optionals (args != []) args,
capabilities ? "capabilities", capabilities ? "capabilities",
on_attach ? "on_attach", on_attach ? "on_attach",
init_opts ? "",
}: let }: let
generatedConfig = { generatedConfig = {
inherit cmd; inherit cmd;
capabilities = mkLuaInline capabilities; capabilities = mkLuaInline capabilities;
on_attach = mkLuaInline on_attach; on_attach = mkLuaInline on_attach;
init_opts = mkLuaInline (optionalString (init_opts != "") init_opts);
}; };
in { in {
inherit package; inherit package;

View file

@ -9,27 +9,18 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) enum either package listOf str bool; inherit (lib.types) enum either package listOf str bool;
inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.languages) diagnosticsToLua mkLspConfig;
inherit (lib.nvim.types) diagnostics mkGrammarOption; inherit (lib.nvim.types) diagnostics mkGrammarOption;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
defaultServer = "bash-ls"; defaultServer = "bashls";
servers = { servers = {
bash-ls = { bashls = mkLspConfig {
name = "bashls";
package = pkgs.bash-language-server; package = pkgs.bash-language-server;
lspConfig = '' args = ["start"];
lspconfig.bashls.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
};
}
'';
}; };
}; };