From 6425e9cfb0d179b804b7aee58f53c4109d437431 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 16 Oct 2024 05:42:01 +0300 Subject: [PATCH] WIP stuff Cba with commit messages --- lib/languages.nix | 9 +++++++-- modules/plugins/languages/bash.nix | 19 +++++-------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/languages.nix b/lib/languages.nix index 1ccee3b..93a449a 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 c0066b3..b6eea7d 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"]; }; };