Add Gleam language server support#1357
Add Gleam language server support#1357Koushik-Salammagari wants to merge 9 commits intooraios:mainfrom
Conversation
| from test.solidlsp.conftest import format_symbol_for_assert, has_malformed_name, request_all_symbols | ||
|
|
||
|
|
||
| @pytest.mark.skipif(shutil.which("gleam") is None, reason="Gleam compiler is not available") |
There was a problem hiding this comment.
Thanks for the PR. There is another one open for gleam at the moment in #1334 but that one has no tests at all.
The condition here is insufficient, we need tests running in CI. Pls adjust the pytest workflow to set up gleam (maybe there is a suitable action) and adjust this condition to
| @pytest.mark.skipif(shutil.which("gleam") is None, reason="Gleam compiler is not available") | |
| from test.conftest import is_ci | |
| @pytest.mark.skipif(shutil.which("gleam") is None and not is_ci, reason="Gleam compiler is not available") |
|
@MischaPanch — addressed both points from your review:
Could you take another look when you get a chance? Happy to make any further adjustments. |
|
Pls resolve the conflicts with main so CI can start |
7a9a429 to
af6706e
Compare
|
@MischaPanch — rebased onto the latest |
|
Error: Unable to resolve action leopard-io/setup-gleam, repository not found |
|
Seems like the action is broken :( |
|
@MischaPanch — the Replaced it with a direct binary install that queries the GitHub API for the real latest tag and downloads the appropriate platform binary ( Should unblock CI now — let me know if anything else needs attention! |
c475b38 to
4a9df49
Compare
|
I fixed the failing lean-caching test on main (by removing it). Gleam tests fail here. Pls merge main, I will review once tests pass in CI |
Integrates the Gleam language server (bundled with the Gleam compiler as `gleam lsp`) into Serena. No separate LSP installation is required beyond the `gleam` compiler binary being on PATH. Changes: - src/solidlsp/language_servers/gleam_language_server.py: new server class with gleam deps download before LSP start for stdlib availability - src/solidlsp/ls_config.py: GLEAM enum, FilenameMatcher(*.gleam), get_ls_class - test/resources/repos/gleam/test_repo/: minimal Gleam project with two modules - test/solidlsp/gleam/test_gleam_basic.py: symbol, within-file reference, cross-file reference, and bare-name tests - pyproject.toml: gleam pytest marker - docs/01-about/020_programming-languages.md: Gleam entry - README.md: Gleam added to language list - CHANGELOG.md: Gleam entry Closes oraios#1334
Downloads the latest Gleam release binary directly from GitHub Releases (linux-musl, aarch64/x86_64 macOS, windows-msvc). The gleam-lang/setup-gleam action is broken upstream so a direct download is used instead, matching the pattern already used for ZLS and Verible in this workflow.
Gleam LSP compiles the project in the background after receiving
initialized{}. Requesting textDocument/documentSymbol before this
finishes returns empty arrays. Wait for the first $$/progress end
notification (which Gleam emits when the workspace compile is done)
before returning from _start_server, with a 30 s fallback timeout.
…lysis The previous implementation set _compile_ready on the first $/progress end notification. Gleam LSP emits one begin/end pair per compilation phase and may open multiple phases sequentially; waking up after the first end left subsequent files (e.g. utils.gleam) unanalysed, causing empty document-symbol responses and failing test_find_symbol / test_find_references_across_files. Now all active tokens are tracked in a set. _compile_ready is cleared whenever a new begin arrives and set only when every token has ended. A short 5-second bootstrap wait handles cached builds where no progress notifications are sent. Timeout raised to 60 s to accommodate slower CI runners.
b5ba243 to
d48ee9d
Compare
|
@MischaPanch — rebased onto latest Root cause: The previous implementation called Fix (commit
CI should pass now — let me know if anything else needs attention! |
|
@Koushik-Salammagari you have access to the falling GH actions, right? |
…t symbols When textDocument/didOpen is sent for a Gleam file the LSP may start a recompilation ($/progress begin/end). The documentSymbol request was sent immediately, racing with the compile and returning an empty list. The empty list was then cached in _document_symbols_cache, permanently hiding symbols for subsequent requests within the same session. Two fixes: 1. GleamLanguageServer._request_document_symbols: open the file with didOpen, sleep 200ms to let any $/progress begin arrive, then wait for _compile_ready before forwarding to the base implementation. 2. ls.py request_document_symbols: skip caching empty DocumentSymbols in _document_symbols_cache (mirrors the existing guard in _request_document_symbols for _raw_document_symbols_cache).
|
@MischaPanch — yes I can see the failures. The OCaml test failures are HTTP 504s from GitHub's package servers while fetching dune/merlin/fiber dependencies — not related to my changes. Could you re-run the failed jobs? I don't have rights to trigger a re-run on the upstream repo |
overrides library enforces return type compatibility at runtime. list | None was rejected; must match base class signature exactly: list[SymbolInformation] | list[DocumentSymbol] | None.
|
@Koushik-Salammagari as per CI, gleam tests still fail, and gleam installation on macos fails |
- macOS CI install replaced with `brew install gleam` (binary download was unreliable on GitHub-hosted runners) - Added `_get_symbols_with_retry` helper: retries documentSymbol up to 5 times with 0.5s*attempt backoff when the LSP returns empty results. Gleam LSP does not always emit $/progress for per-file analysis after textDocument/didOpen, so the previous single-shot request could race and return empty children for files not yet analysed (e.g. utils.gleam).
|
@Koushik-Salammagari you are still on this, right? reference-finding tests fail, maybe more waiting would help (we have general mechanisms for that in the base class), or maybe the LS needs to be initialized in a particular way |
Closes #1334
Summary
Adds support for the Gleam programming language by integrating its built-in language server (
gleam lsp). The LSP is bundled with the Gleam compiler — no separate installation is required.Files changed
src/solidlsp/language_servers/gleam_language_server.pyGleamLanguageServerclasssrc/solidlsp/ls_config.pyLanguage.GLEAMenum value,*.gleamfile matcher,get_ls_classregistrationtest/resources/repos/gleam/test_repo/gleam.toml+ two source modulestest/solidlsp/gleam/test_gleam_basic.pypyproject.tomlgleampytest markerdocs/01-about/020_programming-languages.mdREADME.mdImplementation notes
GleamLanguageServerfollows the same pattern asCrystalLanguageServer(requires user-installed binary, no auto-download).["gleam", "lsp"]— the LSP is part of the compiler since Gleam v0.21.is_ignored_dirname(build/,_build/).gleamis not on PATH (shutil.which("gleam") is None).Test repository
CI note
A GitHub Actions step for installing the Gleam compiler will be needed to run these tests in CI (similar to how other language servers are set up in
.github/workflows/pytest.yml). I'm happy to add that in a follow-up or in this PR if preferred — let me know.