claude-code: add lsp servers support
This commit is contained in:
parent
f0e123a7e2
commit
a455ac1bb3
5 changed files with 86 additions and 3 deletions
|
|
@ -364,6 +364,33 @@ in
|
|||
example = lib.literalExpression "./skills";
|
||||
};
|
||||
|
||||
lspServers = lib.mkOption {
|
||||
type = lib.types.attrsOf jsonFormat.type;
|
||||
default = { };
|
||||
description = ''
|
||||
LSP (Language Server Protocol) servers configuration.
|
||||
'';
|
||||
example = {
|
||||
go = {
|
||||
command = "gopls";
|
||||
args = [ "serve" ];
|
||||
extensionToLanguage = {
|
||||
".go" = "go";
|
||||
};
|
||||
};
|
||||
typescript = {
|
||||
command = "typescript-language-server";
|
||||
args = [ "--stdio" ];
|
||||
extensionToLanguage = {
|
||||
".ts" = "typescript";
|
||||
".tsx" = "typescriptreact";
|
||||
".js" = "javascript";
|
||||
".jsx" = "javascriptreact";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mcpServers = lib.mkOption {
|
||||
type = lib.types.attrsOf jsonFormat.type;
|
||||
default = { };
|
||||
|
|
@ -408,8 +435,10 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = (cfg.mcpServers == { } && !cfg.enableMcpIntegration) || cfg.package != null;
|
||||
message = "`programs.claude-code.package` cannot be null when `mcpServers` or `enableMcpIntegration` is configured";
|
||||
assertion =
|
||||
(cfg.mcpServers == { } && cfg.lspServers == { } && !cfg.enableMcpIntegration)
|
||||
|| cfg.package != null;
|
||||
message = "`programs.claude-code.package` cannot be null when `mcpServers`, `lspServers`, or `enableMcpIntegration` is configured";
|
||||
}
|
||||
{
|
||||
assertion = !(cfg.memory.text != null && cfg.memory.source != null);
|
||||
|
|
@ -448,6 +477,19 @@ in
|
|||
jsonFormat.generate "claude-code-mcp-config.json" { mcpServers = mergedMcpServers; }
|
||||
}"
|
||||
])
|
||||
(lib.optional (cfg.lspServers != { }) [
|
||||
"--append-flags"
|
||||
"--plugin-dir ${
|
||||
pkgs.runCommand "claude-code-lsp-plugin" { } ''
|
||||
install -Dm644 ${
|
||||
jsonFormat.generate "claude-code-lsp-plugin.json" {
|
||||
name = "claude-code-lsp";
|
||||
lspServers = cfg.lspServers;
|
||||
}
|
||||
} $out/.claude-plugin/plugin.json
|
||||
''
|
||||
}"
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue