diff --git a/modules/languages/clang.nix b/modules/languages/clang.nix index 7d201e43..3235c456 100644 --- a/modules/languages/clang.nix +++ b/modules/languages/clang.nix @@ -9,6 +9,10 @@ with builtins; let cfg = config.vim.languages.clang; defaultServer = "ccls"; + packageToCmd = package: defaultCmd: + if isList cfg.lsp.package + then nvim.lua.expToLua cfg.lsp.package + else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }''; servers = { ccls = { package = pkgs.ccls; @@ -16,7 +20,7 @@ with builtins; let lspconfig.ccls.setup{ capabilities = capabilities; on_attach=default_on_attach; - cmd = {"${cfg.lsp.package}/bin/ccls"}; + cmd = ${packageToCmd cfg.lsp.package "ccls"}; ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"} } ''; @@ -30,7 +34,7 @@ with builtins; let lspconfig.clangd.setup{ capabilities = clangd_cap; on_attach=default_on_attach; - cmd = {"${cfg.lsp.package}/bin/clangd"}; + cmd = ${packageToCmd cfg.lsp.package "clangd"}; ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"} } ''; @@ -95,7 +99,7 @@ in { package = mkOption { description = "clang LSP server package"; - type = types.package; + type = with types; either package (listOf str); default = servers.${cfg.lsp.server}.package; };