From 2f0efdbf15ed20192bfa67eecda712a728ea0df3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Mon, 11 Sep 2023 15:19:55 +0200 Subject: [PATCH] feat: make nix lsp install optional --- modules/languages/nix.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/languages/nix.nix b/modules/languages/nix.nix index 5ee616c..81f96c5 100644 --- a/modules/languages/nix.nix +++ b/modules/languages/nix.nix @@ -12,6 +12,10 @@ with builtins; let noFormat = "on_attach = attach_keymaps"; defaultServer = "nil"; + packageToCmd = package: defaultCmd: + if isList package + then lib.nvim.lua.expToLua package + else ''{"${package}/bin/${defaultCmd}"}''; servers = { rnix = { package = pkgs.rnix-lsp; @@ -24,7 +28,7 @@ with builtins; let then useFormat else noFormat }, - cmd = {"${cfg.lsp.package}/bin/rnix-lsp"}, + cmd = ${packageToCmd cfg.lsp.package "rnix-lsp"}, } ''; }; @@ -40,7 +44,7 @@ with builtins; let then useFormat else noFormat }, - cmd = {"${cfg.lsp.package}/bin/nil"}, + cmd = ${packageToCmd cfg.lsp.package "nil"}, ${optionalString cfg.format.enable '' settings = { ["nil"] = { @@ -131,7 +135,7 @@ in { }; package = mkOption { description = "Nix LSP server package"; - type = types.package; + type = with types; either package (listOf str); default = servers.${cfg.lsp.server}.package; }; };