Skip to content

LSP server (gmat_script/lsp/, pygls)#53

Merged
djankov merged 3 commits into
mainfrom
issue-22-lsp-server-pygls
Jun 8, 2026
Merged

LSP server (gmat_script/lsp/, pygls)#53
djankov merged 3 commits into
mainfrom
issue-22-lsp-server-pygls

Conversation

@djankov

@djankov djankov commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A pygls language server (gmat_script/lsp/, the gmat-script-lsp console entry) exposing the parser, linter, field catalogue, and tree-sitter queries over LSP — the editor-agnostic backend for VS Code, Neovim, Emacs, and other clients.
  • Features: live debounced publishDiagnostics (linter + parser syntax errors), hover and completion from the catalogue, definition/references/documentSymbol from the locals/tags queries, and formatting/rangeFormatting from the canonical formatter. A malformed buffer never crashes the server.
  • pygls is an optional lsp extra, so pip install gmat-script stays at its single tree-sitter runtime dependency; the build hook vendors the .scm queries into the wheel so the server can load them from an installed package.

Design notes

  • Pure, unit-testable feature functions (analysis.py) wrap the existing layers; server.py is a thin pygls shell. Positions convert between the library's 1-indexed byte positions and LSP's 0-indexed UTF-16 positions (conversions.py).
  • Per the frozen kickoff decisions: D3 node taxonomy, D7 error model (best-effort on a broken parse), D8 positions (LSP is 0-indexed).

Test plan

  • uv run pytest -m "not corpus" (incl. an stdio integration smoke test driving the server over a subprocess)
  • uv run mypy (strict)
  • uv run ruff check / uv run ruff format --check
  • lsp/ coverage ≥ 90% (currently 100%, stdio entry shim excluded)
  • CI green across the OS/Python matrix, incl. the minimal-install job verifying the vendored queries ship in the wheel

Closes #22.

djankov added 3 commits June 8, 2026 17:41
Add an optional `lsp` extra (pygls) so `pip install gmat-script` stays at
its single tree-sitter runtime dependency, and register the
`gmat-script-lsp` console entry. The build hook now vendors the grammar's
`.scm` queries into the wheel (mirroring the compiled binding) so the
language server can load locals/tags at runtime from an installed package;
the minimal-install CI job verifies they ship and still compile. CI's
`uv sync` gains `--all-extras` so the server is exercised under test, mypy,
and ruff; `__main__` is omitted from coverage as a stdio entry shim.

Part of #22.
A pygls language server exposing the parser, linter, catalogue, and queries
over LSP — the editor-agnostic backend for any client. Pure, unit-testable
feature functions (analysis.py) wrap the existing layers; a thin pygls shell
(server.py) marshals them and never crashes on a malformed buffer:

- publishDiagnostics from the linter (and parser syntax errors), debounced
  on change;
- hover and completion from the field catalogue (field docs, valid fields,
  enum values, object-reference candidates);
- definition, references, and documentSymbol from the locals/tags queries;
- formatting and rangeFormatting from the canonical formatter.

Positions convert between the library's 1-indexed byte positions and LSP's
0-indexed UTF-16 positions (conversions.py). An integration smoke test drives
the server over stdio; unit tests cover the feature core and handlers.

Closes #22.
Add docs/lsp.md (install via the lsp extra, feature table, editor setup for
Neovim/Emacs/VS Code, and how it reuses the library layers) and a nav entry.

Part of #22.
@djankov djankov marked this pull request as ready for review June 8, 2026 22:42
@djankov djankov merged commit 94aaaab into main Jun 8, 2026
25 checks passed
@djankov djankov deleted the issue-22-lsp-server-pygls branch June 8, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP server (gmat_script/lsp/, pygls)

1 participant