diff --git a/crush.json b/crush.json index ba4dc18bc63381ad4bdbca5470a1527986c74205..f5daef89add28ad4924c2bb87ca70020af005d67 100644 --- a/crush.json +++ b/crush.json @@ -1,8 +1,6 @@ { "$schema": "https://charm.land/crush.json", "lsp": { - "Go": { - "command": "gopls" - } + "gopls": {} } } diff --git a/internal/config/config.go b/internal/config/config.go index 67378e9ff00356358bfedd403aacd655b763cfc6..8e4b8e5437e31af351b14b7330ab1bf4326b4863 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -118,7 +118,7 @@ type MCPConfig struct { type LSPConfig struct { Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"` - Command string `json:"command" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"` + Command string `json:"command,omitempty" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"` Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"` Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set to the LSP server command"` FileTypes []string `json:"filetypes,omitempty" jsonschema:"description=File types this LSP server handles,example=go,example=mod,example=rs,example=c,example=js,example=ts"` diff --git a/internal/config/load.go b/internal/config/load.go index 500fc236834ae6bfd17811ad64692d2341b9f8e1..59cef29e24d94d4d74d6be39953133b2e91efdf0 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -351,10 +351,13 @@ func (c *Config) applyLSPDefaults() { // Apply defaults to each LSP configuration for name, cfg := range c.LSP { - // Try to get defaults from powernap based on command name + // Try to get defaults from powernap based on name or command name. base, ok := configManager.GetServer(name) if !ok { - continue + base, ok = configManager.GetServer(cfg.Command) + if !ok { + continue + } } if cfg.Options == nil { cfg.Options = base.Settings @@ -368,6 +371,12 @@ func (c *Config) applyLSPDefaults() { if len(cfg.RootMarkers) == 0 { cfg.RootMarkers = base.RootMarkers } + if len(cfg.Args) == 0 { + cfg.Args = base.Args + } + if len(cfg.Env) == 0 { + cfg.Env = base.Environment + } // Update the config in the map c.LSP[name] = cfg }