LSP server (gmat_script/lsp/, pygls)#53
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gmat_script/lsp/, thegmat-script-lspconsole 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.publishDiagnostics(linter + parser syntax errors),hoverandcompletionfrom the catalogue,definition/references/documentSymbolfrom thelocals/tagsqueries, andformatting/rangeFormattingfrom the canonical formatter. A malformed buffer never crashes the server.lspextra, sopip install gmat-scriptstays at its singletree-sitterruntime dependency; the build hook vendors the.scmqueries into the wheel so the server can load them from an installed package.Design notes
analysis.py) wrap the existing layers;server.pyis a thin pygls shell. Positions convert between the library's 1-indexed byte positions and LSP's 0-indexed UTF-16 positions (conversions.py).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 --checklsp/coverage ≥ 90% (currently 100%, stdio entry shim excluded)Closes #22.