diff --git a/lib/languages.nix b/lib/languages.nix index 1ccee3b4..93a449ab 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -4,7 +4,8 @@ inherit (lib.options) mkOption; inherit (lib.types) bool; inherit (lib.meta) getExe; - inherit (lib.lists) isList optionals; + inherit (lib.strings) optionalString; + inherit (lib.lists) optionals; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.lua) toLuaObject; @@ -46,17 +47,21 @@ in { # `on_attach`. # TODO: nixpkgs-like doc comments from that one RFC mkLspConfig = { + # Mandatory arguments name, package, + # Optional arguments for the sake of flexibility args ? [], - cmd ? [(getExe package)] ++ lib.optionals (args != []) args, + cmd ? [(getExe package)] ++ optionals (args != []) args, capabilities ? "capabilities", on_attach ? "on_attach", + init_opts ? "", }: let generatedConfig = { inherit cmd; capabilities = mkLuaInline capabilities; on_attach = mkLuaInline on_attach; + init_opts = mkLuaInline (optionalString (init_opts != "") init_opts); }; in { inherit package; diff --git a/modules/plugins/languages/bash.nix b/modules/plugins/languages/bash.nix index c0066b3c..b6eea7de 100644 --- a/modules/plugins/languages/bash.nix +++ b/modules/plugins/languages/bash.nix @@ -9,27 +9,18 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; 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.lua) expToLua; cfg = config.vim.languages.bash; - defaultServer = "bash-ls"; + defaultServer = "bashls"; servers = { - bash-ls = { + bashls = mkLspConfig { + name = "bashls"; package = pkgs.bash-language-server; - lspConfig = '' - 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"}'' - }; - } - ''; + args = ["start"]; }; };