Skip to content

RenderTOMLForScope silently drops [lsp] / [lsp.servers] config section on Save #3464

@dreanzy

Description

@dreanzy

Problem

RenderTOMLForScope in internal/config/render.go omits the [lsp] and [lsp.servers.<lang>] sections when serialising the config to TOML. Any user-defined LSP server overrides are silently discarded on every SaveTo() / Save() call.

Scope

Every write path hits this:

  • reasonix setup interactive wizard (cli.go:610 -> SaveTo)
  • Desktop settings panel saving any change (multiple mutators in edit.go -> SaveTo)
  • MCP server add/remove (edit.go:450-456 -> SaveTo)
  • Any settings change (permissions, theme, etc.) that triggers a save

A user may change an unrelated setting (e.g. the theme) and unwittingly lose custom [lsp.servers.lua] entries without noticing.

Root cause

File: internal/config/render.go

RenderTOMLForScope (line 30) renders these sections: [ui], [desktop], [notifications], [network] + [network.proxy], [agent], [[providers]], [tools], [codegraph], [skills], [permissions], [sandbox], [statusline], [[plugins]].

The [lsp] section is completely absent from the render output -- the struct field Config.LSP (config.go:58) is loaded correctly but never serialised back.

The relevant types (config.go:173-195):

type LSPConfig struct {
    Enabled bool                 `toml:"enabled"`
    Servers map[string]LSPServer `toml:"servers"`
}
type LSPServer struct {
    Command     string            `toml:"command"`
    Args        []string          `toml:"args"`
    Env         map[string]string `toml:"env"`
    LanguageID  string            `toml:"language_id"`
    Extensions  []string          `toml:"extensions"`
    InstallHint string            `toml:"install_hint"`
}

render_test.go also has no round-trip test covering the LSP section.

Suggested fix

  1. internal/config/render.go: Add [lsp] section rendering in RenderTOMLForScope (suggest inserting between [codegraph] and [skills], or another natural position). Follow the same annotated-comment style as the existing [codegraph] block (lines 259-267). The output should cover:

    • [lsp] header with the enabled field
    • Iterate c.LSP.Servers to emit each [lsp.servers.<lang>] sub-table
  2. internal/config/render_test.go: Add a round-trip test that verifies a TOML with [lsp.servers] content survives Load -> RenderTOML -> Load unchanged.

Workaround

LSP server config placed in a project-local reasonix.toml is still loaded and honoured correctly (the Load() path is unaffected). However, avoid any SaveTo()-triggering operation (reasonix setup, desktop settings panel) until the fix lands -- otherwise the project config's LSP section will also be dropped by RenderTOMLForScope.

Reproduction

  1. Add to ~/.config/reasonix/config.toml:
[lsp]
enabled = true

[lsp.servers.lua]
extensions = [".lua", ".script", ".gui_script"]
  1. Run reasonix setup (or any operation calling SaveTo)
  2. Inspect the file -- the [lsp] section is gone
  3. Verify that LSP tools fall back to built-in defaults

Environment

  • Version: latest (main)
  • Platform: all
  • Config version: 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    configConfiguration & setup (internal/config)data-lossData loss (sessions, config, history)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions