feat: add Gleam language support via the Gleam compiler's bundled gleam lsp - #1765
Open
weiconghe wants to merge 1 commit into
Open
feat: add Gleam language support via the Gleam compiler's bundled gleam lsp#1765weiconghe wants to merge 1 commit into
gleam lsp#1765weiconghe wants to merge 1 commit into
Conversation
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.
What does this PR do?
Adds Gleam language support to solidlsp, using the language server bundled with the Gleam compiler (
gleam lsp). Closes #1334 (good first issue).Implementation
GleamLanguageServer(src/solidlsp/language_servers/gleam_language_server.py) using theLanguageServerDependencyProviderSinglePathpattern (same as qmlls): discoversgleamon PATH, launches[gleam, "lsp"].LanguageServerId.GLEAMregistered inls_config.py(enum +*.gleammatcher + factory), in the main (non-experimental) section alongside QML.gleam lspemits$/progress(begin/end) for its initial dependency-resolution phase on first start. The server tracks active progress tokens and waits for all phases to end before declaring ready (bounded: 10 s for the firstbegin, 180 s for all to drain). Once dependencies are resolved, symbol / reference / hover / diagnostics queries are served synchronously — no per-request compile-wait or retry is needed (verified directly against gleam 1.17).gleam deps downloadin_start_serverso the LSP's own download phase is short and there is no first-request race on slow CI runners._supports_pull_diagnosticsoverridden to returnFalse:gleam lspdoes not implementtextDocument/diagnostic(nodiagnosticProvidercapability is advertised). Sending a pull request hangs (the server neither responds nor errors), so we opt out and rely ontextDocument/publishDiagnostics(push), which the base class stores via_observe_server_notification.Why not build on #1357?
This PR supersedes two prior attempts that went stale:
Diagnosing why #1357's CI was flaky surfaced two root causes, both fixed here:
Fixture import syntax was wrong.
calculator.gleamusedimport test_repo/utils, which Gleam 1.x rejects withUnknown module. The correct form isimport utils(in-project module paths are relative tosrc/, without the project-name prefix). This is why "reference-finding tests fail" was observed on Add Gleam language server support #1357 — the cross-file reference target was never resolvable, so the cross-file references test could not pass regardless of timing. (Credit to Koushik-Salammagari for the original fixture structure and test coverage; the import line is the fix.)textDocument/diagnostic(pull) hung the diagnostics test. Gleam LSP advertises nodiagnosticProvider; the base class's default_supports_pull_diagnostics → Truesent a pull request the server never answered, timing the test out (240 s). Overriding toFalseroutes throughpublishDiagnostics(push) instead.#1357 was also built against a now-outdated
main: it usedProcessLaunchInfoand the old_get_initialize_params(repository_absolute_path)signature, both superseded by theDependencyProvider+_create_base_initialize_paramsrefactors. This PR is built on currentmainwith the modern patterns (the same ones requested in the QML review of #1635).Notes
gleam deps downloadruns at server start and only needs network access to the Hex package mirror; no Erlang runtime.How did you verify your code works?
test_ls_is_runningtest_document_symbols— assertsadd/subtract/multiply/Calculator/demoare presenttest_find_symbol—request_full_symbol_tree(backing serena'sfind_symboltool) sees symbols from bothcalculator.gleamandutils.gleamtest_find_references_within_file—adddefinition → its call site indemo(same file)test_find_references_across_files—format_outputdefined inutils.gleam→ its call sites incalculator.gleamtest_file_diagnostics—undefined_symbolindiagnostics_sample.gleamis flaggedgleamis installed on theother-langsLinux batch (mirrors the qmlls setup); thegleammarker is added toMARKERS_OTHER_LANGS. Tests skip on Windows/macOS CI and off-CI without the binary via the central conftest guard.ruff check,ruff format, andty checkare all clean.Checklist
CONTRIBUTING.mdregarding the scope of PRs.CHANGELOG.md.