Commit9014adb1Recorded17 Apr 2026Repositorysigil-docs

lsp,docs: definition uses .sgl source path; hover falls back to runtime spec

Message

(sigil docs lookup) json->module-details was storing the .json doc path in module-details-file, so textDocument/definition resolved to non-existent files and always returned null. The compiler-emitted JSON carries a "source" field with the real .sgl path; use it and fall back to the doc path only when missing.

(sigil lsp hover) now consults runtime procedure metadata for the defining module when the sidecar description is empty. Procedure docstrings aren't stored at runtime today (both CPS paths treat %set-docstring! as a no-op — cps-convert.c:3604,3634), so this at least surfaces (spec ...) signatures on hover cards. Filling the description field will require either wiring doc text into doccollectionadd_export at compile time or making %set-docstring! actually stash strings somewhere reachable at runtime; both are separate follow-ups.

Changed
 src/sigil/docs/lookup.sgl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Diff
src/sigil/docs/lookup.sglmodified
@@ -136,10 +136,16 @@
136
(let* ((exports-array (dict-ref json-doc exports: #f))
137
(exports (if exports-array
138
(array->list exports-array)
139
'())))
+139
'()))
+140
;; Prefer the absolute source path emitted by the compiler
+141
;; (the "source" field); fall back to the doc path if missing.
+142
(source-file (let ((s (dict-ref json-doc source: #f)))
+143
(if (and s (string? s) (not (equal? s 'null)))
+144
s
+145
doc-path))))
146
(module-details
147
name: module-name
142
file: doc-path
+148
file: source-file
149
package: (let ((pkg (dict-ref json-doc package: #f)))
150
(if (and pkg (not (equal? pkg 'null)))
151
pkg