Commitee1c88ceRecorded7 Aug 2026Repositorysigil-lsp

Migrate LSP help consumer

Changed
 README.md                      |  4 ++--
 package.sgl                    |  2 +-
 sigil.lock                     |  5 -----
 src/sigil/lsp/code-actions.sgl |  4 ++--
 src/sigil/lsp/completion.sgl   |  2 +-
 src/sigil/lsp/definition.sgl   |  6 +++---
 src/sigil/lsp/hover.sgl        |  8 ++++----
 src/sigil/lsp/lint.sgl         |  2 +-
 src/sigil/lsp/server.sgl       |  4 ++--
 test/gate-h2-help-migration.sh | 22 ++++++++++++++++++++++
 test/h2-redirects.sgl.in       | 10 ++++++++++
 test/test-help-integration.sgl | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 118 insertions(+), 21 deletions(-)
Diff
README.mdmodified
@@ -18,8 +18,8 @@ subcommand of sigil-cli).
18
| `(sigil lsp documents)` | In-memory document cache keyed by URI |
19
| `(sigil lsp positions)` | 0-based line/character helpers |
20
| `(sigil lsp diagnostics)` | Parse errors + lint warnings as LSP diagnostics |
−21
| `(sigil lsp hover)` | Hover provider via `(sigil docs)` |
−22
| `(sigil lsp completion)` | Completion provider via `(sigil docs)` |
+21
| `(sigil lsp hover)` | Hover provider via `(sigil help)` |
+22
| `(sigil lsp completion)` | Completion provider via `(sigil help)` |
23
| `(sigil lsp definition)` | Go-to-definition via module resolution |
24
| `(sigil lsp formatting)` | Document and range formatting via `(sigil format)` |
25
| `(sigil lsp code-actions)` | Quick-fix code actions (import, unused import) |
package.sglmodified
@@ -18,4 +18,4 @@
18
(from-git url: "codeberg:sigil/sigil-log" version: "^0.16.0")
19
(from-git url: "codeberg:sigil/sigil-args" version: "^0.16.0")
20
(from-git url: "codeberg:sigil/sigil-format" version: "^0.16.0")
−21
(from-git url: "codeberg:sigil/sigil-docs" version: "^0.16.0")))
+21
(from-git url: "codeberg:sigil/sigil-help" version: "^0.16.0")))
sigil.lockmodified
@@ -26,11 +26,6 @@
26
ref: "^0.16.0"
27
sha: "4b9c40c4ef7bcbe2b76867593a23b81f6f916071"
28
version: "0.16.1")
−29
(package name: "sigil-docs"
−30
url: "codeberg:sigil/sigil-docs"
−31
ref: "^0.16.0"
−32
sha: "105327cf559c31945fa3239b770460ca323ea8ed"
−33
version: "0.16.1")
29
(package name: "sigil-ansi"
30
url: "codeberg:sigil/sigil-ansi"
31
ref: "^0.16.0"
src/sigil/lsp/code-actions.sglmodified
@@ -2,7 +2,7 @@
2
;;;
3
;;; Provides two quick-fixes in v1:
4
;;; 1. "Import <module>" for unbound identifiers, driven by
−5
;;; (sigil docs search).
+5
;;; (sigil help search).
6
;;; 2. "Remove unused import" for unused-imports lint warnings,
7
;;; driven by the `data` payload on those diagnostics.
8
@@ -11,7 +11,7 @@
11
(sigil string)
12
(sigil io)
13
(sigil dict)
−14
(sigil docs search)
+14
(sigil help search)
15
(sigil lsp positions)
16
(sigil lsp documents))
17
(export compute-code-actions)
src/sigil/lsp/completion.sglmodified
@@ -5,7 +5,7 @@
5
(define-library (sigil lsp completion)
6
(import (sigil core)
7
(sigil string)
−8
(sigil docs search)
+8
(sigil help search)
9
(sigil lsp positions)
10
(sigil lsp documents))
11
(export completion-at)
src/sigil/lsp/definition.sglmodified
@@ -9,9 +9,9 @@
9
(sigil string)
10
(sigil io)
11
(sigil fs)
−12
(sigil docs search)
−13
(sigil docs lookup)
−14
(sigil docs types)
+12
(sigil help search)
+13
(sigil help lookup)
+14
(sigil help types)
15
(sigil lsp positions)
16
(sigil lsp documents))
17
(export definition-at)
src/sigil/lsp/hover.sglmodified
@@ -1,6 +1,6 @@
1
;;; (sigil lsp hover) - textDocument/hover provider.
2
;;;
−3
;;; Uses (sigil docs search) + (sigil docs lookup) to produce
+3
;;; Uses (sigil help search) + (sigil help lookup) to produce
4
;;; a Markdown hover card for the identifier under the cursor.
5
6
(define-library (sigil lsp hover)
@@ -9,9 +9,9 @@
9
(sigil io)
10
(sigil inspect)
11
(sigil spec)
−12
(sigil docs search)
−13
(sigil docs lookup)
−14
(sigil docs types)
+12
(sigil help search)
+13
(sigil help lookup)
+14
(sigil help types)
15
(sigil lsp positions)
16
(sigil lsp documents))
17
(export hover-at)
src/sigil/lsp/lint.sglmodified
@@ -8,7 +8,7 @@
8
(sigil string)
9
(sigil io)
10
(sigil struct)
−11
(sigil docs search))
+11
(sigil help search))
12
(export lint-code
13
lint-warning
14
lint-warning?
src/sigil/lsp/server.sglmodified
@@ -14,7 +14,7 @@
14
(sigil log)
15
(sigil time)
16
(sigil math)
−17
(sigil docs search)
+17
(sigil help search)
18
(sigil lsp protocol)
19
(sigil lsp documents)
20
(sigil lsp diagnostics)
@@ -91,7 +91,7 @@
91
;; Dispatch
92
;; ============================================================
93
−94
;; Force the (sigil docs search) index cache to populate by running
+94
;; Force the (sigil help search) index cache to populate by running
95
;; one search. Logged at info so it shows up in normal run logs.
96
(define (warm-docs-index!)
97
(let ((t0 (current-jiffy)))
test/gate-h2-help-migration.shadded
@@ -0,0 +1,22 @@
+1
#!/usr/bin/env bash
+2
set -euo pipefail
+3
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+4
cd "$repo_root"
+5
help_source=${SIGIL_HELP_SOURCE:?set SIGIL_HELP_SOURCE to reviewed H1 checkout}
+6
[[ $(git -C "$help_source" rev-parse HEAD) == 57c0bf1ce234abaf6dbf4da41018caf149aee471 ]] || {
+7
printf 'FAIL: SIGIL_HELP_SOURCE is not reviewed H1\n' >&2; exit 1; }
+8
[[ $(readlink -f .sigil/deps/sigil-help) == $(readlink -f "$help_source") ]] || {
+9
printf 'FAIL: sigil-help dependency is not reviewed H1 checkout\n' >&2; exit 1; }
+10
rg -q -F 'codeberg:sigil/sigil-help' package.sgl
+11
if rg -n -F 'name: "sigil-help"' sigil.lock; then
+12
printf 'FAIL: redirect-satisfied sigil-help must not have a fabricated lock entry\n' >&2; exit 1
+13
fi
+14
rg -q -F '(search-docs "_sigil_lsp_warmup_")' src/sigil/lsp/server.sgl || {
+15
printf 'FAIL: LSP initialized notification no longer warms the help index\n' >&2; exit 1; }
+16
if rg -n '\(sigil docs([[:space:]]|\))|sigil-docs' src test README.md package.sgl sigil.lock \
+17
-g '!gate-h2-help-migration.sh' -g '!**/transcripts/**'; then
+18
printf 'FAIL: active LSP consumer still names old help package/namespace\n' >&2; exit 1
+19
fi
+20
sigil build --no-cache
+21
sigil test --report
+22
printf 'PASS: LSP hover/completion/definition resolve reviewed sigil-help metadata\n'
test/h2-redirects.sgl.inadded
@@ -0,0 +1,10 @@
+1
(redirects
+2
repos: (list
+3
(for-repo url: "codeberg:sigil/sigil"
+4
use: (from-path dir: "/home/daviwil/Projects/Code/sigil/sigil"))
+5
(for-repo url: "codeberg:sigil/sigil-json"
+6
use: (from-path dir: "/home/daviwil/Projects/Code/sigil/sigil-json"))
+7
(for-repo url: "codeberg:sigil/sigil-log"
+8
use: (from-path dir: "/home/daviwil/Projects/Code/sigil/sigil-log"))
+9
(for-repo url: "codeberg:sigil/sigil-help"
+10
use: (from-path dir: "@SIGIL_HELP_SOURCE@"))))
test/test-help-integration.sgladded
@@ -0,0 +1,70 @@
+1
(import (sigil test)
+2
(sigil fs)
+3
(sigil string)
+4
(sigil help lookup)
+5
(sigil help search)
+6
(sigil lsp protocol)
+7
(sigil lsp documents)
+8
(sigil lsp server))
+9
+10
(define uri "file:///tmp/h2-help-consumer.sgl")
+11
(define store (doc-store))
+12
(doc-store-open! store uri "sigil" 1 "completion-at")
+13
(define server (lsp-server docs: store initialized: #t))
+14
+15
(define (params character)
+16
`((textDocument . ((uri . ,uri)))
+17
(position . ((line . 0) (character . ,character)))))
+18
+19
(define (request method character id)
+20
(handle-message server
+21
(lsp-request id: id method: method params: (params character))))
+22
+23
(define fixture-json "build/dev/lib/sigil/lsp/completion.json")
+24
(define held-json "build/dev/lib/sigil/lsp/completion.json.h2-held")
+25
+26
;; Warm the production cache, remove its compiler-generated source metadata,
+27
;; and only then issue real protocol requests. The cached answers must survive.
+28
(clear-search-cache)
+29
(handle-message server (make-notification "initialized"))
+30
(rename-file fixture-json held-json)
+31
(define hover-response (request "textDocument/hover" 5 1))
+32
(define completion-response (request "textDocument/completion" 13 2))
+33
(define definition-response (request "textDocument/definition" 5 3))
+34
(rename-file held-json fixture-json)
+35
+36
(test "LSP imports real reviewed sigil-help metadata"
+37
(let ((details (load-module-details '(sigil help lookup))))
+38
(assert-true (module-details? details))
+39
(assert-true (string-find (module-details-file details)
+40
"task-sigil-help-migration/src/sigil/help/lookup.sgl"))))
+41
+42
(test "LSP hover request uses warmed compiler metadata"
+43
(let* ((response hover-response)
+44
(result (lsp-response-result response))
+45
(contents (cdr (assq 'contents result)))
+46
(value (cdr (assq 'value contents))))
+47
(assert-true (string-find value "completion-at"))
+48
(assert-true (string-find value "Return a CompletionList"))
+49
(assert-true (string-find value "(sigil lsp completion)"))))
+50
+51
(test "LSP completion request includes warmed compiler metadata"
+52
(let* ((response completion-response)
+53
(result (lsp-response-result response))
+54
(items (cdr (assq 'items result)))
+55
(item (find (lambda (entry)
+56
(string=? (cdr (assq 'label entry))
+57
"completion-at"))
+58
items)))
+59
(assert-true item)
+60
(assert-equal "(sigil lsp completion)" (cdr (assq 'detail item)))))
+61
+62
(test "LSP definition request uses warmed compiler metadata"
+63
(let* ((response definition-response)
+64
(result (lsp-response-result response))
+65
(location (car result))
+66
(definition-uri (cdr (assq 'uri location))))
+67
(assert-true (string-find definition-uri
+68
"src/sigil/lsp/completion.sgl"))))
+69
+70
(run-tests)