@nvl/sveltex-language-server 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +288 -0
  3. package/bin/server.js +10 -0
  4. package/dist/core/config.d.ts +126 -0
  5. package/dist/core/config.js +569 -0
  6. package/dist/core/diagnostics.d.ts +34 -0
  7. package/dist/core/diagnostics.js +67 -0
  8. package/dist/core/frontmatter-data.d.ts +74 -0
  9. package/dist/core/frontmatter-data.js +323 -0
  10. package/dist/core/frontmatter.d.ts +25 -0
  11. package/dist/core/frontmatter.js +348 -0
  12. package/dist/core/lsp-proxy.d.ts +77 -0
  13. package/dist/core/lsp-proxy.js +165 -0
  14. package/dist/core/mapper.d.ts +86 -0
  15. package/dist/core/mapper.js +223 -0
  16. package/dist/core/mapping.d.ts +59 -0
  17. package/dist/core/mapping.js +37 -0
  18. package/dist/core/markdown.d.ts +34 -0
  19. package/dist/core/markdown.js +215 -0
  20. package/dist/core/region-forwarding.d.ts +90 -0
  21. package/dist/core/region-forwarding.js +428 -0
  22. package/dist/core/region-virtual.d.ts +71 -0
  23. package/dist/core/region-virtual.js +131 -0
  24. package/dist/core/regions.d.ts +56 -0
  25. package/dist/core/regions.js +221 -0
  26. package/dist/core/remap.d.ts +84 -0
  27. package/dist/core/remap.js +272 -0
  28. package/dist/core/server-helpers.d.ts +109 -0
  29. package/dist/core/server-helpers.js +182 -0
  30. package/dist/core/server.d.ts +13 -0
  31. package/dist/core/server.js +604 -0
  32. package/dist/core/svelte-proxy.d.ts +100 -0
  33. package/dist/core/svelte-proxy.js +144 -0
  34. package/dist/core/texlab.d.ts +26 -0
  35. package/dist/core/texlab.js +121 -0
  36. package/dist/core/virtual-svelte.d.ts +32 -0
  37. package/dist/core/virtual-svelte.js +67 -0
  38. package/dist/index.d.ts +29 -0
  39. package/dist/index.js +46 -0
  40. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 N. V. Lang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,288 @@
1
+ # `@nvl/sveltex-language-server`
2
+
3
+ > [!WARNING]
4
+ > **This package is in alpha.** It is brand new and under active development.
5
+ > Its API, behaviour, and configuration may change at any time, and breaking
6
+ > changes should be expected before version `1.0.0`.
7
+
8
+ A Language Server Protocol (LSP) implementation for
9
+ [SvelTeX](https://sveltex.dev) — the Svelte preprocessor that lets a `.sveltex`
10
+ file mix Markdown, Svelte, and embedded LaTeX / math / code.
11
+
12
+ A `.sveltex` file is not a single language. The bulk of it is Svelte (markup,
13
+ `<script>`, `<style>`, mustache tags, logic blocks) interleaved with Markdown,
14
+ and punctuated by **verbatim** regions — fenced/inline code, KaTeX/MathJax math,
15
+ LaTeX environments — that must _not_ be interpreted as Svelte. This server gives
16
+ each region the treatment it deserves.
17
+
18
+ ## Architecture
19
+
20
+ ### The problem
21
+
22
+ The real Svelte tooling lives in
23
+ [`svelte-language-server`](https://www.npmjs.com/package/svelte-language-server).
24
+ It is excellent, but two facts shape everything here:
25
+
26
+ 1. **It is not an embeddable library.** Its npm `exports` expose only `.` and
27
+ `./bin/server.js`. The official Svelte VS Code extension spawns
28
+ `svelte-language-server/bin/server.js` as a child process and proxies it over
29
+ JSON-RPC. It is **not** built on [Volar](https://volarjs.dev/).
30
+ 2. **It cannot be hosted inside Volar.** Volar is the dominant framework for
31
+ embedded-language servers (MDX, Astro, and Vue use it), but Volar drives
32
+ TypeScript semantics _itself_. Adopting Volar would mean reimplementing
33
+ Svelte support instead of reusing `svelte-language-server`.
34
+
35
+ SvelTeX's own preprocessor is no help for position mapping either: its `markup`
36
+ step replaces escaped snippets with opaque UUIDs and lets the Markdown processor
37
+ reflow HTML, which destroys source offsets. There is no usable source map to
38
+ piggyback on.
39
+
40
+ ### The approach: a hand-rolled, region-based proxy
41
+
42
+ ```
43
+ .sveltex file
44
+
45
+
46
+ ┌──────────────────────┐
47
+ │ core/regions.ts │ parse into Region[] (reuses SvelTeX's own
48
+ │ │ exported detectors: parseToMdast, getMdastES,
49
+ │ │ getSvelteES, getMathInSpecialDelimsES, ...)
50
+ └──────────┬───────────┘
51
+
52
+ ┌──────────────────────┐
53
+ │ core/virtual-svelte │ build ONE virtual `.svelte` document:
54
+ │ │ • delegated regions copied byte-for-byte
55
+ │ │ • everything else blanked to same-length
56
+ │ │ whitespace (newlines preserved)
57
+ │ │ → emits Mapping[] (offset-triple model)
58
+ └──────────┬───────────┘
59
+
60
+ ┌──────────────────────┐ ┌─────────────────────────────┐
61
+ │ core/svelte-proxy.ts │ ──JSON──▶│ svelte-language-server │
62
+ │ (spawns child) │◀─ RPC ──│ (real Svelte tooling, child │
63
+ └──────────┬───────────┘ │ process) │
64
+ │ └─────────────────────────────┘
65
+
66
+ ┌──────────────────────┐
67
+ │ core/mapper.ts │ SourceMap: bidirectional offset/position/range
68
+ │ │ translation between source and virtual docs
69
+ └──────────────────────┘
70
+ ```
71
+
72
+ - **`core/regions.ts`** — splits the `.sveltex` document into a gap-free
73
+ `Region[]`. It does **not** re-implement SvelTeX's parser; it calls the
74
+ region-detection functions SvelTeX already exports (`parseToMdast`,
75
+ `getMdastES`, `getSvelteES`, `getMathInSpecialDelimsES`, `getColonES`,
76
+ `outermostRanges`), each of which reports precise offsets on the original
77
+ source. Every region is classified as **delegated** (plain Markdown/HTML,
78
+ Svelte markup, mustache tags) or **non-delegated** (verbatim, code, math,
79
+ frontmatter).
80
+ - **`core/virtual-svelte.ts`** — builds a single virtual `.svelte` document.
81
+ Delegated regions are copied verbatim; non-delegated regions are replaced by
82
+ an equal-length run of whitespace (line breaks kept, so line numbers never
83
+ shift). The result is the same length as the source, which keeps mapping
84
+ geometry trivial.
85
+ - **`core/mapping.ts` / `core/mapper.ts`** — the position mapper. The data
86
+ model is a trimmed-down adaptation of Volar's `CodeMapping` offset-triple
87
+ representation (`sourceOffset` / `generatedOffset` / `length` + per-region
88
+ feature flags). `SourceMap` does binary-searched, bidirectional translation of
89
+ offsets, `Position`s and `Range`s. _Volar itself is **not** a dependency_ —
90
+ only its proven data shape is borrowed.
91
+ - **`core/svelte-proxy.ts`** — resolves `svelte-language-server/bin/server.js`
92
+ from `node_modules`, forks it, and speaks LSP with it over a stdio JSON-RPC
93
+ connection.
94
+ - **`core/lsp-proxy.ts`** — a _generic_ child-language-server proxy (the same
95
+ spawn/JSON-RPC pattern as `svelte-proxy.ts`, but server-agnostic). Supports
96
+ both a forked Node module (the bundled math language server) and a spawned
97
+ native executable (the TexLab binary).
98
+ - **`core/region-virtual.ts`** — builds a small, standalone virtual document
99
+ for a single non-delegated region: bare TeX for a math region (delimiters
100
+ stripped), bare LaTeX for a verbatim region (tags stripped), each with a
101
+ `SourceMap` back to the `.sveltex` source.
102
+ - **`core/texlab.ts`** — robust, cross-platform detection of a `texlab` binary
103
+ on `PATH`.
104
+ - **`core/region-forwarding.ts`** — forwards hover/completion that land in a
105
+ math region (to the math language server) or a LaTeX verbatim region (to
106
+ TexLab), spawning those children lazily and mapping results back.
107
+ - **`core/markdown.ts`** — native Markdown features (document symbols, folding
108
+ ranges, selection ranges) computed directly from the mdast. These need no
109
+ position mapping because the mdast carries source offsets.
110
+ - **`core/frontmatter.ts`** — native hover and completion for a frontmatter
111
+ block: the frontmatter keys (`title`, `meta`, `base`, `link`, …) and the
112
+ standard `<meta>` names, resolved against the block the caret sits in.
113
+ - **`core/diagnostics.ts` / `core/remap.ts`** — translate every
114
+ position-bearing message. Requests are mapped source → generated before being
115
+ forwarded; responses (and diagnostics) are mapped generated → source, and
116
+ anything that lands in a non-delegated region is dropped.
117
+ - **`core/server.ts`** — `createServer(connection)`, the orchestrator. It
118
+ routes each request: a delegated region goes to the Svelte proxy, a math or
119
+ LaTeX-verbatim region to `RegionForwarder`, and a frontmatter region to the
120
+ native `core/frontmatter.ts` handler.
121
+
122
+ ### Why one virtual document and not many
123
+
124
+ A `.sveltex` file _is_ essentially a Svelte file with holes. Producing a single
125
+ virtual `.svelte` document (rather than one per embedded language) means the
126
+ embedded `svelte-language-server` sees a coherent Svelte file and its
127
+ TypeScript/HTML/CSS analysis works exactly as it would for a hand-written
128
+ `.svelte` file. The holes (verbatim/code/math) are simply blank to it.
129
+
130
+ ## The core / wrapper split
131
+
132
+ The most important structural rule of this package:
133
+
134
+ > **`createServer(connection)` is transport-agnostic. It never imports
135
+ > `vscode`, never touches `process.stdin`, and never assumes how it is being
136
+ > run.**
137
+
138
+ ```
139
+ src/core/server.ts → createServer(connection: Connection) ← pure core
140
+ src/index.ts → startServer() (stdio convenience wrapper)
141
+ bin/server.js → #!/usr/bin/env node → startServer()
142
+ ```
143
+
144
+ This is what makes the same core reusable across editors:
145
+
146
+ - **VS Code** (`packages/vscode-sveltex`, wired up now): a
147
+ `vscode-languageclient` `LanguageClient` launches `bin/server.js` as a child
148
+ process over Node IPC. `startServer()` creates the LSP connection;
149
+ `createServer()` does the work.
150
+ - **Zed** (`editors/zed`): a thin Zed extension that launches `bin/server.js`
151
+ and talks LSP over **stdio**. Because `createServer()` is transport-agnostic
152
+ and `bin/server.js` already exists, the Zed extension needs no change to this
153
+ package — it is purely a thin launcher on the Zed side.
154
+
155
+ Any future host (Neovim, Emacs `lsp-mode`, Sublime LSP, ...) plugs in the same
156
+ way: run `bin/server.js`, speak LSP.
157
+
158
+ ## Feature coverage
159
+
160
+ **Proxied to `svelte-language-server`, fully position-mapped**, and suppressed
161
+ inside non-delegated regions:
162
+
163
+ - Diagnostics (merged with native ones)
164
+ - Hover
165
+ - Completion (+ completion-item resolve)
166
+ - Go-to-definition
167
+ - Find references
168
+ - Document highlight
169
+ - Code actions
170
+ - Rename (+ prepare-rename)
171
+ - Signature help
172
+ - Document links
173
+
174
+ **Native** (computed directly from the `.sveltex` source, no proxy, no mapping
175
+ needed):
176
+
177
+ - Document symbols (heading outline)
178
+ - Folding ranges
179
+ - Selection ranges
180
+ - Frontmatter hover and completion — the frontmatter keys and standard
181
+ `<meta>` names, each documented with a link to MDN
182
+
183
+ **Forwarded to dedicated child servers** (each non-delegated region becomes its
184
+ own small virtual document; positions and results are mapped back):
185
+
186
+ - **Math regions** (`$…$`, `$$…$$`, `\(…\)`, `\[…\]`) → the bundled
187
+ [`@nvl/sveltex-math-language-server`](../sveltex-math-language-server),
188
+ spawned with `initializationOptions.backend` set from the SvelTeX config's
189
+ `mathBackend`. TeX command completion (on `\`) and rich hover — the
190
+ command's signature, the Unicode symbol it renders, and a description. When
191
+ `mathBackend` is `custom` or `none` — backends with no math server — math
192
+ regions are skipped.
193
+ - **LaTeX verbatim regions** (a `verbatim` environment whose tag is one of the
194
+ configured `latexTags` — `tex` / `latex` / `tikz` by default) → a spawned
195
+ [TexLab](https://github.com/latex-lsp/texlab) process, _if_ a `texlab` binary
196
+ is found on `PATH`. Hover, completion, and TexLab's other LaTeX features. If
197
+ `texlab` is not installed, these regions are skipped silently — no error.
198
+
199
+ **Document sync:** `didOpen` / `didChange` / `didClose` of the source file are
200
+ translated into sync of the virtual `.svelte` document. Each change triggers a
201
+ synchronous full re-parse (full-document sync).
202
+
203
+ **Configuration:** `svelte.config.{js,mjs,cjs,ts,mts,cts}` is loaded on
204
+ `initialize` and live-reloaded on save to pick up verbatim-environment names,
205
+ math delimiters, the math backend, and directive settings. (The user's
206
+ `sveltex.config.*` is loaded indirectly when the Svelte config imports it.)
207
+ The config is evaluated in a child Node process via `--input-type=module
208
+ --eval`, so `.ts` / `.mts` / `.cts` configs run natively on Node 22.6+.
209
+
210
+ ## Known limitations / stubbed for later
211
+
212
+ - **LaTeX / math diagnostics** are not yet produced. Math and LaTeX verbatim
213
+ regions get completion and hover (forwarded, see above), but no _diagnostics_
214
+ are surfaced for them.
215
+ - **Markdown → HTML expansion.** Delegated Markdown is currently passed to the
216
+ Svelte server as-is. A future phase will expand it to the HTML the Svelte
217
+ compiler actually sees; the `Mapping` model already supports the non-identity
218
+ (length-changing) mappings this needs.
219
+ - **Incremental virtual-file updates.** Each edit rebuilds the whole virtual
220
+ document. A future phase can patch incrementally.
221
+ - **Formatting** is not yet proxied.
222
+ - The region detectors are imported via a deep path
223
+ (`@nvl/sveltex/dist/utils/escape.js`) because `@nvl/sveltex` does not yet
224
+ expose a public `getRegions()`. A `TODO` tracks upstreaming one.
225
+
226
+ ## Development
227
+
228
+ ```sh
229
+ pnpm --filter @nvl/sveltex-language-server build # type-check + emit dist/
230
+ pnpm --filter @nvl/sveltex-language-server test # run unit/integration tests
231
+ pnpm --filter @nvl/sveltex-language-server lint # eslint + tsc --noEmit
232
+ ```
233
+
234
+ The `tests/unit/` suite covers the bidirectional mapper (the most error-prone
235
+ component), region computation, virtual-document building, the per-region
236
+ virtual documents, the config snapshot, TexLab detection, math/verbatim
237
+ forwarding, and an end-to-end check that spawns `bin/server.js` and drives it
238
+ over stdio. The TexLab path is tested with TexLab made absent, so the suite
239
+ does not require the `texlab` binary.
240
+
241
+ ## How to try the extension
242
+
243
+ The [`vscode-sveltex`](../vscode-sveltex) extension launches this server. To
244
+ exercise the whole stack inside VS Code:
245
+
246
+ 1. **Build everything** from the monorepo root:
247
+
248
+ ```sh
249
+ pnpm install
250
+ pnpm --filter @nvl/sveltex build
251
+ pnpm --filter @nvl/sveltex-math-language-server build
252
+ pnpm --filter @nvl/sveltex-language-server build
253
+ pnpm --filter sveltex build # the VS Code extension
254
+ ```
255
+
256
+ 2. **Launch the Extension Development Host.** Open `packages/vscode-sveltex/`
257
+ in VS Code and press <kbd>F5</kbd> (Run → Start Debugging). A second VS Code
258
+ window opens with the SvelTeX extension loaded.
259
+
260
+ 3. **Open a project** that has a `.sveltex` file (and, ideally, a
261
+ `sveltex.config.{js,mjs,cjs}` so the math backend is detected — otherwise
262
+ the server defaults to MathJax). The sample showcase project under
263
+ `packages/sveltex/tests/e2e/showcase/` is a good candidate.
264
+
265
+ 4. **Confirm end-to-end behaviour** in a `.sveltex` file:
266
+
267
+ - Inside a `<script lang="ts">` block, write a type error
268
+ (`const n: number = 'x';`) — a Svelte/TypeScript diagnostic appears,
269
+ proving the embedded `svelte-language-server` is being proxied.
270
+ - Inside inline math (`$ … $`), type a backslash and a few letters
271
+ (`\alp`) — TeX command completion offers `\alpha`. Hover a command such as
272
+ `\frac` for a description. The offered commands match the project's
273
+ `mathBackend` (KaTeX vs MathJax).
274
+ - Inside a LaTeX verbatim environment (`<tex> … </tex>`), completion and
275
+ hover work _if_ a `texlab` binary is on `PATH`; if not, the editor simply
276
+ offers nothing there (no error).
277
+ - In the frontmatter block, hover a key such as `title` or `description`,
278
+ and press <kbd>Ctrl</kbd>+<kbd>Space</kbd> while typing a key — both are
279
+ answered natively.
280
+ - A heading outline appears in the Outline view (native Markdown symbols).
281
+
282
+ If the language server fails to start, the extension logs an error but keeps
283
+ syntax highlighting working; check the "SvelTeX Language Server" output channel
284
+ in the Extension Development Host for details.
285
+
286
+ For an automated smoke test, this package's
287
+ `tests/unit/server.test.ts` already spawns `bin/server.js` and drives the same
288
+ requests over stdio — the transport the VS Code client uses.
package/bin/server.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ // Executable entry point for the SvelTeX language server.
3
+ //
4
+ // This file is intentionally tiny and dependency-free: editors (VS Code via
5
+ // `vscode-languageclient`, the future Zed extension over stdio, ...) launch it
6
+ // directly. All real work lives in the compiled core under `../dist`.
7
+
8
+ import { startServer } from '../dist/index.js';
9
+
10
+ startServer();
@@ -0,0 +1,126 @@
1
+ import type { DirectiveEscapeSettings } from '@nvl/sveltex/dist/types/utils/Escape.js';
2
+ /**
3
+ * The math-delimiter settings shape consumed by SvelTeX's region detectors.
4
+ *
5
+ * This mirrors `WithFullDelims['delims']` from `@nvl/sveltex` but is restated
6
+ * here so that the LSP does not depend on a deep `dist/` type path. The detector
7
+ * functions only ever _read_ these fields.
8
+ */
9
+ export interface MathDelimsSnapshot {
10
+ dollars: boolean;
11
+ inline: {
12
+ singleDollar: boolean;
13
+ escapedParentheses: boolean;
14
+ };
15
+ display: {
16
+ escapedSquareBrackets: boolean;
17
+ };
18
+ doubleDollarSignsDisplay: 'always' | 'newline' | 'fenced';
19
+ }
20
+ /**
21
+ * The math backend a SvelTeX project renders its math with.
22
+ *
23
+ * Mirrors `@nvl/sveltex`'s `MathBackend`. Only `mathjax` and `katex` have a
24
+ * corresponding math language server; `custom` and `none` mean no math
25
+ * assistance is offered.
26
+ */
27
+ export type MathBackend = 'mathjax' | 'katex' | 'custom' | 'none';
28
+ /**
29
+ * The `\documentclass` line and preamble that SvelTeX wraps a TeX verbatim
30
+ * environment's content in when it compiles it to a `.tex` file.
31
+ *
32
+ * The LSP mirrors this when building the virtual document it forwards to
33
+ * TexLab, so completion / hover see the project's _actual_ packages and
34
+ * preamble macros (`\usepackage{…}`, `\newcommand{…}`, …) rather than a
35
+ * generic guess.
36
+ */
37
+ export interface TexScaffold {
38
+ /** The full `\documentclass[…]{…}` line. */
39
+ documentClass: string;
40
+ /** Everything between `\documentclass` and `\begin{document}`. */
41
+ preamble: string;
42
+ }
43
+ /**
44
+ * The minimal, immutable view of a resolved `svelte.config.*` that the LSP
45
+ * core needs in order to split a document into {@link Region}s and route
46
+ * region-specific language requests.
47
+ */
48
+ export interface SveltexConfigSnapshot {
49
+ /**
50
+ * Names of configured verbatim environments (`tex`, `verbatim`, ...). Used
51
+ * both to detect verbatim regions and to tell SvelTeX's Markdown parser
52
+ * which elements to treat as opaque.
53
+ */
54
+ verbatimTags: string[];
55
+ /**
56
+ * The subset of {@link verbatimTags} that denote LaTeX / TeX environments
57
+ * (a verbatim entry whose `type` is `'tex'`, plus its aliases). Requests
58
+ * inside one of these are forwarded to TexLab when it is available.
59
+ */
60
+ latexTags: string[];
61
+ /** File extensions handled by SvelTeX (e.g. `['.sveltex']`). */
62
+ extensions: string[];
63
+ /** Math-delimiter settings. */
64
+ mathDelims: MathDelimsSnapshot;
65
+ /**
66
+ * The math backend the project uses. Drives which math language server
67
+ * (if any) math regions are forwarded to.
68
+ */
69
+ mathBackend: MathBackend;
70
+ /** Markdown directive settings. */
71
+ directives: DirectiveEscapeSettings;
72
+ /**
73
+ * Per-tag {@link TexScaffold} for the project's TeX verbatim environments,
74
+ * keyed by lower-cased tag name (every alias of a `type: 'tex'` entry maps
75
+ * to the same scaffold). Empty when no config file declares one — in which
76
+ * case the LSP falls back to a generic built-in scaffold.
77
+ */
78
+ texScaffolds: Record<string, TexScaffold>;
79
+ /**
80
+ * Absolute path of the `svelte.config.*` the snapshot was loaded from, or
81
+ * `undefined` if none was found and the built-in defaults are in use.
82
+ */
83
+ configPath: string | undefined;
84
+ }
85
+ /**
86
+ * Returns a {@link SveltexConfigSnapshot} populated entirely from SvelTeX's
87
+ * built-in defaults. Used as the base that a loaded config is merged onto, and
88
+ * as the fallback when no config file exists or loading fails.
89
+ */
90
+ export declare function defaultConfigSnapshot(): SveltexConfigSnapshot;
91
+ /**
92
+ * Searches `workspaceRoot` for a `svelte.config.*` file.
93
+ *
94
+ * @returns The absolute path of the first one found, or `undefined`.
95
+ */
96
+ export declare function findSvelteConfigFile(workspaceRoot: string): string | undefined;
97
+ /**
98
+ * Loads the SvelTeX configuration for a workspace and distills it into a
99
+ * {@link SveltexConfigSnapshot}.
100
+ *
101
+ * The configuration is read from the project's `svelte.config.*`: SvelTeX has
102
+ * to be registered there as a preprocessor to be active at all, so the
103
+ * resolved `Sveltex` instance — and thus the project's real verbatim tags,
104
+ * TeX preamble, math backend, … — is reachable from it. A dedicated
105
+ * `sveltex.config.*` file, if the project keeps one, is necessarily imported
106
+ * into `svelte.config.*`, so reading the latter captures it either way.
107
+ *
108
+ * @param workspaceRoot - Absolute path of the workspace folder to search.
109
+ * @param log - Optional sink for a one-line, human-readable account of the
110
+ * load outcome (config located and loaded, located but unloadable — with the
111
+ * reason —, or absent). Wired by the host to the editor's output channel so a
112
+ * misconfigured project is diagnosable rather than a silent fall-back.
113
+ * @returns The resolved snapshot. Loading never throws: a missing,
114
+ * syntactically broken, or otherwise unloadable config falls back to the
115
+ * built-in {@link defaultConfigSnapshot} — the LSP must never fail to start
116
+ * just because the configuration is unreadable.
117
+ *
118
+ * @remarks
119
+ * The config is imported in a short-lived child process ({@link
120
+ * loadConfigViaChild}), so each call — and thus each live reload — re-reads
121
+ * the config and everything it imports. A `.ts` config relies on the child
122
+ * Node's type-stripping support; the child reuses this server's own Node
123
+ * binary, so it strips types exactly where the server's runtime would, and on
124
+ * a Node too old for it the child errors and the defaults are used.
125
+ */
126
+ export declare function loadConfigSnapshot(workspaceRoot: string, log?: (message: string) => void): Promise<SveltexConfigSnapshot>;