LSP: offer every lib/ module in import completion (#692)#702
Merged
Conversation
The `import ` completion list was a hand-maintained array in eigenlsp.c holding 34 names while lib/ has 75 modules — so 41 were invisible in the editor, including every ui_w_* widget module, the whole science set (physics, chemistry, biology, calculus, linalg, numerics, optimize, probability, geometry, earth_science, engineering), audio, utf8, sync and pkg. #590 already added tools/gen_lsp_stdlib_index.sh, which scrapes lib/ at build time for symbol completion + hover. That generator now also emits stdlib_modules[], and the import completion iterates it, so the list cannot drift from lib/ again. stdlib_modules[] is built from the lib/ FILE SET, deliberately not derived from the stdlib_docs rows. stdlib_docs only holds PUBLIC defines, and five modules have none — ui_layout's four defines are all underscore-private, text_builder declares none at top level, plus ui_dnd/ui_focus/ui_registry. They are importable all the same, and ui_layout was in the old hardcoded list, so deriving the module list from the docs rows would have quietly dropped a module that used to work. tests/test_lsp.py asserts the completion set against the real lib/*.eigs listing rather than a hardcoded count, so adding a module can never silently fall out of completion. Verified red-then-green: on the old code the new assertion fails naming exactly the 41 missing modules. tests/test_lsp.py 82 passed, 0 failed release suite 3185/3185 both build paths make lsp + build.sh lsp, no new warnings Closes #692 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes EigenLSP’s import -context completion so it offers every lib/*.eigs module, by deleting the previously hand-maintained module-name array and instead using a build-generated stdlib_modules[] list emitted alongside the existing stdlib_docs index.
Changes:
- Extend
tools/gen_lsp_stdlib_index.shto also emitstdlib_modules[]derived from thelib/file set (not fromstdlib_docsrows). - Update
src/eigenlsp.cto iteratestdlib_modules[]for module-name completion afterimport. - Add a regression test in
tests/test_lsp.pythat asserts the completion set matches the livelib/*.eigsfile listing; document the fix inCHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/gen_lsp_stdlib_index.sh | Generator now emits stdlib_modules[] (module list sourced from lib/ file set). |
| src/eigenlsp.c | import completion now comes from generated stdlib_modules[] instead of a hardcoded list. |
| tests/test_lsp.py | Regression test asserts import-module completion matches actual lib/*.eigs modules (including modules with no public defines). |
| CHANGELOG.md | Adds release-note entry describing the completion-list drift and the generated-list fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| print " * detail is the define shape. Regenerated by the Makefile lsp target /" > OUT | ||
| print " * build.sh lsp; not committed. Columns: module, name, params, detail. */" > OUT | ||
| print " * build.sh lsp; not committed. Columns: module, name, params, detail." > OUT | ||
| print " * Also emits stdlib_modules[]: EVERY lib/*.eigs basename, which is what" > OUT |
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.
The
importcompletion list was a hand-maintained array insrc/eigenlsp.cholding 34 names whilelib/has 75 modules. 41 were invisible in the editor — everyui_w_*widget module, the entire science set (physics,chemistry,biology,calculus,linalg,numerics,optimize,probability,geometry,earth_science,engineering), plusaudio,utf8,sync,pkgand others.The fix deletes the fossil rather than updating it
#590 (merged last week) already added
tools/gen_lsp_stdlib_index.sh, which scrapeslib/at build time intolsp_stdlib_index.hfor symbol completion + hover. The hardcoded array was sitting directly next to its own replacement. The generator now also emitsstdlib_modules[], and completion iterates that — so the list is structurally incapable of drifting fromlib/again.Why the module list is NOT derived from
stdlib_docsThis is the one real design decision here.
stdlib_docsonly holds public defines, and five modules have none:ui_layout_-prefixed (private)text_builderdefineui_dnd,ui_focus,ui_registryAll five are importable regardless — and
ui_layoutwas in the old hardcoded 34. So the obvious one-line implementation (walkstdlib_docs, collect distinct module names) would have shipped 70 modules and silently dropped one that previously worked.stdlib_modules[]is therefore generated from thelib/file set, which is the thing "what can I import" actually means. Both the generator header comment and the test spell this out so nobody later "simplifies" it back.Validation
tests/test_lsp.pyasserts the completion set against the livelib/*.eigslisting rather than a hardcoded number — adding a module can never silently fall out of completion again.Verified red-then-green: with the fix reverted, the new assertion fails and prints exactly the 41 missing modules, corroborating the issue's headline number independently.
tests/test_lsp.pymake lsp+build.sh lsp(Both build paths were checked deliberately —
build.shdrifting from theMakefilehas bitten before.build.sh lspcaught a-Wcommentwarning I'd introduced by writing a glob inside a block comment; fixed. The remaininglint.cwarnings are pre-existing.)Closes #692
🤖 Generated with Claude Code