Skip to content

LSP: offer every lib/ module in import completion (#692)#702

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix-lsp-import-completion-692
Jul 25, 2026
Merged

LSP: offer every lib/ module in import completion (#692)#702
InauguralPhysicist merged 1 commit into
mainfrom
fix-lsp-import-completion-692

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

The import completion list was a hand-maintained array in src/eigenlsp.c holding 34 names while lib/ has 75 modules. 41 were invisible in the editor — every ui_w_* widget module, the entire science set (physics, chemistry, biology, calculus, linalg, numerics, optimize, probability, geometry, earth_science, engineering), plus audio, utf8, sync, pkg and others.

The fix deletes the fossil rather than updating it

#590 (merged last week) already added tools/gen_lsp_stdlib_index.sh, which scrapes lib/ at build time into lsp_stdlib_index.h for symbol completion + hover. The hardcoded array was sitting directly next to its own replacement. The generator now also emits stdlib_modules[], and completion iterates that — so the list is structurally incapable of drifting from lib/ again.

Why the module list is NOT derived from stdlib_docs

This is the one real design decision here. stdlib_docs only holds public defines, and five modules have none:

module why it has no docs rows
ui_layout all four defines are _-prefixed (private)
text_builder declares no top-level define
ui_dnd, ui_focus, ui_registry same shape

All five are importable regardless — and ui_layout was in the old hardcoded 34. So the obvious one-line implementation (walk stdlib_docs, collect distinct module names) would have shipped 70 modules and silently dropped one that previously worked. stdlib_modules[] is therefore generated from the lib/ 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.py asserts the completion set against the live lib/*.eigs listing 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.

check result
tests/test_lsp.py 82 passed, 0 failed (2 new)
same test on the old code FAIL, naming all 41 missing modules
release suite 3185/3185
make lsp + build.sh lsp both regenerate the index; no new warnings

(Both build paths were checked deliberately — build.sh drifting from the Makefile has bitten before. build.sh lsp caught a -Wcomment warning I'd introduced by writing a glob inside a block comment; fixed. The remaining lint.c warnings are pre-existing.)

Closes #692

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 25, 2026 03:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to also emit stdlib_modules[] derived from the lib/ file set (not from stdlib_docs rows).
  • Update src/eigenlsp.c to iterate stdlib_modules[] for module-name completion after import .
  • Add a regression test in tests/test_lsp.py that asserts the completion set matches the live lib/*.eigs file listing; document the fix in CHANGELOG.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
@InauguralPhysicist
InauguralPhysicist merged commit c3039c0 into main Jul 25, 2026
19 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the fix-lsp-import-completion-692 branch July 25, 2026 03:28
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: 'import ' completion offers a hardcoded 34-module list, underselling 41 of the 75 lib modules

2 participants