on main help sign in
feat(lsp): load defaults by either name or command (#1109)

* fix(lsp): load defaults by name or command name Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix(lsp): simplify Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit0da5e6b17d7c3d379784fd4b43ac9d8a790a8ae4 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateTue 23 Sep 2025, 12:12 (1 year ago) parent1f46a69
3 files changed+13−6
crush.json+1−3 internal/config/config.go+1−1 internal/config/load.go+11−2
crush.json+1−3
@@ -1,8 +1,6 @@
11{
22 "$schema": "https://charm.land/crush.json",
33 "lsp": {
4− "Go": {
5− "command": "gopls"
6− }
4+ "gopls": {}
75 }
86}
internal/config/config.go+1−1
@@ -118,7 +118,7 @@ type MCPConfig struct {
118118
119119type LSPConfig struct {
120120 Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"`
121− Command string `json:"command" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"`
121+ Command string `json:"command,omitempty" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"`
122122 Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"`
123123 Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set to the LSP server command"`
124124 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"`
internal/config/load.go+11−2
@@ -351,10 +351,13 @@ func (c *Config) applyLSPDefaults() {
351351
352352 // Apply defaults to each LSP configuration
353353 for name, cfg := range c.LSP {
354− // Try to get defaults from powernap based on command name
354+ // Try to get defaults from powernap based on name or command name.
355355 base, ok := configManager.GetServer(name)
356356 if !ok {
357− continue
357+ base, ok = configManager.GetServer(cfg.Command)
358+ if !ok {
359+ continue
360+ }
358361 }
359362 if cfg.Options == nil {
360363 cfg.Options = base.Settings
@@ -368,6 +371,12 @@ func (c *Config) applyLSPDefaults() {
368371 if len(cfg.RootMarkers) == 0 {
369372 cfg.RootMarkers = base.RootMarkers
370373 }
374+ if len(cfg.Args) == 0 {
375+ cfg.Args = base.Args
376+ }
377+ if len(cfg.Env) == 0 {
378+ cfg.Env = base.Environment
379+ }
371380 // Update the config in the map
372381 c.LSP[name] = cfg
373382 }