Skip to content

Migrate language server startup to JSON configuration #3

Description

@purefunctor

Problem

Compiler PR purefunctor/purescript-iris#496 implements purefunctor's chosen direction for purefunctor/purescript-iris#487: replace --source-command and --diagnostics-on-open/save/change with mutually exclusive --config <JSON> and --config-file <PATH> startup options.

The extension currently constructs ['--source-command', resolvedConfig.sourceCommand] in src/extension.ts. That invocation will be rejected by the updated compiler when a custom source command is configured.

src/configuration.ts and package.json currently expose alexandrite.sourceCommand and the deprecated purescriptAnalyzer.sourceCommand alias. The extension has no diagnostic-trigger settings and relies on compiler defaults.

Compiler contract

The JSON contract already lives in the compiler's shared configuration crate and schema:
https://github.com/purefunctor/purescript-alexandrite/blob/main/compiler-lsp/configuration/configuration.schema.json

Defaults:

{
  "sources": { "kind": "spago" },
  "diagnostics": { "onOpen": true, "onSave": true, "onChange": false }
}

Custom discovery:

{
  "sources": {
    "kind": "command",
    "program": "spago",
    "arguments": ["sources"]
  }
}
  • Missing or null fields retain defaults; {} and top-level null select defaults.
  • Commands supply a nonempty executable and an optional array of individual arguments, without shell parsing.
  • Configuration is read once before startup. Relative --config-file paths resolve from the server process working directory.
  • Unknown fields (including an embedded $schema property), malformed settings, and file-read failures produce stderr errors and exit status 2.
  • This change does not add configuration-file watching or runtime LSP configuration updates; applying changed startup settings still requires a restart.

Requested follow-up

  • Update server argument construction to use the new JSON CLI transport, passing an inline JSON document as a single argument or a configuration file path. Do not emit removed flags for updated compiler versions.
  • Choose and document the extension settings interface, including migration of existing sourceCommand settings and the deprecated alias. Represent executable/argv separately rather than guessing shell quoting by splitting an old command string.
  • Preserve default Spago discovery and diagnostic behavior when settings are absent. Use the shared schema for any exposed diagnostic settings.
  • Define compatibility behavior for older compiler versions explicitly, including actionable migration/error messages.
  • Add tests for generated server arguments, default settings, the selected migration behavior, arguments containing spaces/empty strings, and configuration errors. Update extension settings descriptions and usage documentation.

Compiler implementation thread: https://ampcode.com/threads/T-01a089ad-03d0-70ff-8777-7b90149d0a66

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions