@mdsvex/language-server 0.1.0-next.1 → 0.1.0-next.3
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.
- package/dist/clean_hover.d.ts +7 -0
- package/dist/command.d.ts +4 -0
- package/dist/compile_diagnostics.d.ts +3 -0
- package/dist/completions.d.ts +4 -0
- package/dist/definitions.d.ts +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +443 -0
- package/dist/root_code.d.ts +7 -0
- package/dist/server.cjs +40164 -18438
- package/package.json +13 -6
- package/CHANGELOG.md +0 -32
- package/bin/pfm-language-server.js +0 -3
- package/src/clean_hover.ts +0 -106
- package/src/compile_diagnostics.ts +0 -36
- package/src/completions.ts +0 -163
- package/src/definitions.ts +0 -31
- package/src/index.ts +0 -249
- package/src/root_code.ts +0 -16
- package/test/clean_hover.spec.ts +0 -130
- package/test/compile_diagnostics.spec.ts +0 -60
- package/test/definitions.spec.ts +0 -34
- package/test/integration.spec.ts +0 -222
- package/test/server.spec.ts +0 -250
- package/tsconfig.json +0 -11
- package/vite.config.build.ts +0 -27
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clean up svelte2tsx internal types in hover tooltips.
|
|
3
|
+
*
|
|
4
|
+
* 1. Strips `(alias) type X = SvelteComponent<...> & { $$bindings?: ... }\n`
|
|
5
|
+
* 2. Transforms `const X: __sveltets_2_IsomorphicComponent<{props}, ...>` into `const X<{props}>`
|
|
6
|
+
*/
|
|
7
|
+
export declare function clean_svelte_hover(markdown: string): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** template names, frontmatter keys and values, and directive args, from the props of each component */
|
|
2
|
+
import type { LanguageServicePlugin } from '@volar/language-server';
|
|
3
|
+
import type * as TS from 'typescript';
|
|
4
|
+
export declare function create_completions(ts: typeof TS): LanguageServicePlugin;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Location, LocationLink, Position } from '@volar/language-server';
|
|
2
|
+
/** drops the markdown self definition of a heading when another target exists, so a jump goes straight to its component */
|
|
3
|
+
export declare function without_self<T extends Location | LocationLink>(results: T[] | null | undefined, uri: string, at: Position): T[] | null | undefined;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { createConnection, createServer, loadTsdkByPath, createTypeScriptProject } from "@volar/language-server/node.js";
|
|
2
|
+
import { create } from "volar-service-typescript";
|
|
3
|
+
import { create as create$1 } from "volar-service-css";
|
|
4
|
+
import { create as create$2 } from "volar-service-markdown";
|
|
5
|
+
import { completion_context, template_named, probe_for, props_of, create_config_loader, create_pfm_language_plugin, create_svelte_language_plugin } from "@mdsvex/language-core";
|
|
6
|
+
import { watch } from "node:fs";
|
|
7
|
+
import { URI } from "vscode-uri";
|
|
8
|
+
import { CompletionItemKind } from "@volar/language-server";
|
|
9
|
+
function clean_svelte_hover(markdown) {
|
|
10
|
+
markdown = strip_svelte_component_type(markdown);
|
|
11
|
+
markdown = strip_runes_component_type(markdown);
|
|
12
|
+
markdown = clean_isomorphic_component(markdown);
|
|
13
|
+
return markdown;
|
|
14
|
+
}
|
|
15
|
+
function strip_runes_component_type(md) {
|
|
16
|
+
const re = /^(?:\(alias\) )?type [\w$]+ = \{\n(?:[ \t]+\$(?:on|set)\?\(.*\n)+\}\n/m;
|
|
17
|
+
for (let m = re.exec(md); m !== null; m = re.exec(md))
|
|
18
|
+
md = md.slice(0, m.index) + md.slice(m.index + m[0].length);
|
|
19
|
+
return md;
|
|
20
|
+
}
|
|
21
|
+
function strip_svelte_component_type(md) {
|
|
22
|
+
const marker = "type ";
|
|
23
|
+
let search_from = 0;
|
|
24
|
+
while (true) {
|
|
25
|
+
const type_idx = md.indexOf(marker, search_from);
|
|
26
|
+
if (type_idx === -1) return md;
|
|
27
|
+
const eq_idx = md.indexOf("= SvelteComponent<", type_idx);
|
|
28
|
+
if (eq_idx === -1 || eq_idx - type_idx > 80) {
|
|
29
|
+
search_from = type_idx + 1;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
let line_start = type_idx;
|
|
33
|
+
while (line_start > 0 && md[line_start - 1] !== "\n") line_start--;
|
|
34
|
+
let i = eq_idx + "= SvelteComponent<".length;
|
|
35
|
+
let angle_depth = 1;
|
|
36
|
+
while (i < md.length && angle_depth > 0) {
|
|
37
|
+
if (md[i] === "<") angle_depth++;
|
|
38
|
+
else if (md[i] === ">" && md[i - 1] !== "=") angle_depth--;
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
const after_angle = md.slice(i, i + 10).trimStart();
|
|
42
|
+
if (after_angle.startsWith("& {")) {
|
|
43
|
+
i = md.indexOf("& {", i) + 2;
|
|
44
|
+
let brace_depth = 0;
|
|
45
|
+
while (i < md.length) {
|
|
46
|
+
if (md[i] === "{") brace_depth++;
|
|
47
|
+
else if (md[i] === "}") {
|
|
48
|
+
brace_depth--;
|
|
49
|
+
if (brace_depth === 0) {
|
|
50
|
+
i++;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (i < md.length && md[i] === "\n") i++;
|
|
58
|
+
md = md.slice(0, line_start) + md.slice(i);
|
|
59
|
+
search_from = line_start;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function clean_isomorphic_component(md) {
|
|
63
|
+
const marker = ": __sveltets_2_IsomorphicComponent<";
|
|
64
|
+
const idx = md.indexOf(marker);
|
|
65
|
+
if (idx === -1) return md;
|
|
66
|
+
const args_start = idx + marker.length;
|
|
67
|
+
let depth = 0;
|
|
68
|
+
let first_arg_end = -1;
|
|
69
|
+
for (let i = args_start; i < md.length; i++) {
|
|
70
|
+
const ch = md[i];
|
|
71
|
+
if (ch === "{") depth++;
|
|
72
|
+
else if (ch === "}") depth--;
|
|
73
|
+
else if (ch === "," && depth === 0) {
|
|
74
|
+
first_arg_end = i;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (first_arg_end === -1) return md;
|
|
79
|
+
let angle_depth = 1;
|
|
80
|
+
let full_end = -1;
|
|
81
|
+
for (let i = args_start; i < md.length; i++) {
|
|
82
|
+
if (md[i] === "<") angle_depth++;
|
|
83
|
+
else if (md[i] === ">") {
|
|
84
|
+
if (i > 0 && md[i - 1] === "=") continue;
|
|
85
|
+
angle_depth--;
|
|
86
|
+
if (angle_depth === 0) {
|
|
87
|
+
full_end = i + 1;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (full_end === -1) return md;
|
|
93
|
+
const first_arg = md.slice(args_start, first_arg_end).trim();
|
|
94
|
+
return md.slice(0, idx) + "<" + first_arg + ">" + md.slice(full_end);
|
|
95
|
+
}
|
|
96
|
+
function contains(range, at) {
|
|
97
|
+
const after_start = at.line > range.start.line || at.line === range.start.line && at.character >= range.start.character;
|
|
98
|
+
const before_end = at.line < range.end.line || at.line === range.end.line && at.character <= range.end.character;
|
|
99
|
+
return after_start && before_end;
|
|
100
|
+
}
|
|
101
|
+
function without_self(results, uri, at) {
|
|
102
|
+
if (!Array.isArray(results) || results.length < 2) return results;
|
|
103
|
+
const others = results.filter((r) => {
|
|
104
|
+
const target = "targetUri" in r ? r.targetUri : r.uri;
|
|
105
|
+
const range = "targetUri" in r ? r.targetRange : r.range;
|
|
106
|
+
return target !== uri || !contains(range, at);
|
|
107
|
+
});
|
|
108
|
+
return others.length === 0 ? results : others;
|
|
109
|
+
}
|
|
110
|
+
function root_code(context, document) {
|
|
111
|
+
if (document.languageId !== "pfm") return;
|
|
112
|
+
const decoded = context.decodeEmbeddedDocumentUri(URI.parse(document.uri));
|
|
113
|
+
if (decoded === void 0) return;
|
|
114
|
+
return context.language.scripts.get(decoded[0])?.generated?.root;
|
|
115
|
+
}
|
|
116
|
+
const ERROR = 1;
|
|
117
|
+
const WARNING = 2;
|
|
118
|
+
function create_compile_diagnostics() {
|
|
119
|
+
return {
|
|
120
|
+
name: "mdsvex-compile",
|
|
121
|
+
capabilities: {
|
|
122
|
+
diagnosticProvider: {
|
|
123
|
+
interFileDependencies: false,
|
|
124
|
+
workspaceDiagnostics: false
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
create(context) {
|
|
128
|
+
return {
|
|
129
|
+
provideDiagnostics(document) {
|
|
130
|
+
const root = root_code(context, document);
|
|
131
|
+
if (root?.diagnostics === void 0) return;
|
|
132
|
+
return root.diagnostics.map((d) => ({
|
|
133
|
+
range: {
|
|
134
|
+
start: document.positionAt(d.start),
|
|
135
|
+
end: document.positionAt(d.end)
|
|
136
|
+
},
|
|
137
|
+
message: d.message,
|
|
138
|
+
severity: d.severity === "error" ? ERROR : WARNING,
|
|
139
|
+
source: "mdsvex"
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const SUGGEST = { title: "suggest", command: "editor.action.triggerSuggest" };
|
|
147
|
+
function written(value, plain) {
|
|
148
|
+
return plain.test(value) ? value : JSON.stringify(value);
|
|
149
|
+
}
|
|
150
|
+
function create_completions(ts) {
|
|
151
|
+
return {
|
|
152
|
+
name: "mdsvex-completions",
|
|
153
|
+
capabilities: {
|
|
154
|
+
// a value follows the space after a colon, args follow the paren, a comma or an equals sign
|
|
155
|
+
completionProvider: { triggerCharacters: [" ", "(", ",", "="] }
|
|
156
|
+
},
|
|
157
|
+
create(context) {
|
|
158
|
+
const props = (root, uri, kind, name, template) => {
|
|
159
|
+
if (name === void 0) return [];
|
|
160
|
+
const probe = probe_for(root.probes, kind, name, template);
|
|
161
|
+
const ls = context.inject(
|
|
162
|
+
"typescript/languageService"
|
|
163
|
+
);
|
|
164
|
+
const decoded = context.decodeEmbeddedDocumentUri(URI.parse(uri));
|
|
165
|
+
if (!probe || !ls || !decoded) return [];
|
|
166
|
+
const file = context.inject(
|
|
167
|
+
"typescript/documentFileName",
|
|
168
|
+
decoded[0]
|
|
169
|
+
);
|
|
170
|
+
const program = ls.getProgram();
|
|
171
|
+
if (!program || !file) return [];
|
|
172
|
+
const typed = program;
|
|
173
|
+
return props_of(ts, typed, file, probe.alias) ?? [];
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
provideCompletionItems(document, position) {
|
|
177
|
+
const root = root_code(context, document);
|
|
178
|
+
if (!root) return;
|
|
179
|
+
const source = document.getText();
|
|
180
|
+
const at = completion_context(
|
|
181
|
+
source,
|
|
182
|
+
document.offsetAt(position),
|
|
183
|
+
root.frontmatter
|
|
184
|
+
);
|
|
185
|
+
if (at === null) return;
|
|
186
|
+
const range = {
|
|
187
|
+
start: document.positionAt(at.range.start),
|
|
188
|
+
end: document.positionAt(at.range.end)
|
|
189
|
+
};
|
|
190
|
+
const named = template_named(source, root.frontmatter);
|
|
191
|
+
const template = named === false ? void 0 : named ?? root.template;
|
|
192
|
+
let items = [];
|
|
193
|
+
if (at.kind === "template") {
|
|
194
|
+
items = root.templates.map((t, i) => ({
|
|
195
|
+
label: t.name,
|
|
196
|
+
kind: CompletionItemKind.EnumMember,
|
|
197
|
+
detail: t.file ?? "template",
|
|
198
|
+
sortText: String(i).padStart(4, "0"),
|
|
199
|
+
textEdit: { range, newText: t.name }
|
|
200
|
+
}));
|
|
201
|
+
if (items.length !== 0)
|
|
202
|
+
items.push({
|
|
203
|
+
label: "false",
|
|
204
|
+
kind: CompletionItemKind.Value,
|
|
205
|
+
detail: "no template",
|
|
206
|
+
sortText: "9999",
|
|
207
|
+
textEdit: { range, newText: "false" }
|
|
208
|
+
});
|
|
209
|
+
} else if (at.kind === "frontmatter_key" || at.kind === "arg_key") {
|
|
210
|
+
const list = at.kind === "frontmatter_key" ? props(root, document.uri, "template", template, void 0) : props(
|
|
211
|
+
root,
|
|
212
|
+
document.uri,
|
|
213
|
+
"directive",
|
|
214
|
+
at.directive,
|
|
215
|
+
template
|
|
216
|
+
);
|
|
217
|
+
const reserved = at.kind === "arg_key" && !at.inline ? ["children", "label"] : ["children"];
|
|
218
|
+
const sep = at.kind === "frontmatter_key" ? ": " : "=";
|
|
219
|
+
items = list.filter(
|
|
220
|
+
(p) => !reserved.includes(p.name) && !at.existing.includes(p.name)
|
|
221
|
+
).map((p) => ({
|
|
222
|
+
label: p.name,
|
|
223
|
+
kind: CompletionItemKind.Property,
|
|
224
|
+
detail: p.optional ? `${p.type} (optional)` : p.type,
|
|
225
|
+
documentation: p.documentation || void 0,
|
|
226
|
+
sortText: (p.optional ? "1" : "0") + p.name,
|
|
227
|
+
textEdit: { range, newText: p.name + sep },
|
|
228
|
+
command: p.values.length !== 0 ? SUGGEST : void 0
|
|
229
|
+
}));
|
|
230
|
+
} else {
|
|
231
|
+
const list = at.kind === "frontmatter_value" ? props(root, document.uri, "template", template, void 0) : props(
|
|
232
|
+
root,
|
|
233
|
+
document.uri,
|
|
234
|
+
"directive",
|
|
235
|
+
at.directive,
|
|
236
|
+
template
|
|
237
|
+
);
|
|
238
|
+
const prop = list.find((p) => p.name === at.key);
|
|
239
|
+
const plain = at.kind === "frontmatter_value" ? /^(?![-?:,[\]{}#&*!|>'"%@`]|true$|false$|null$|~$|[-+.\d])[^:#\n]*$/ : /^[^\s,)"']+$/;
|
|
240
|
+
items = (prop?.values ?? []).map((v, i) => {
|
|
241
|
+
const literal = v === "true" || v === "false" || !Number.isNaN(Number(v));
|
|
242
|
+
return {
|
|
243
|
+
label: v,
|
|
244
|
+
kind: CompletionItemKind.EnumMember,
|
|
245
|
+
detail: prop.type,
|
|
246
|
+
sortText: String(i).padStart(4, "0"),
|
|
247
|
+
textEdit: { range, newText: literal ? v : written(v, plain) }
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return items.length === 0 ? void 0 : { isIncomplete: false, items };
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function createPfmLanguagePluginForServer(typescript, config) {
|
|
258
|
+
const inner = create_pfm_language_plugin({ typescript, config });
|
|
259
|
+
return {
|
|
260
|
+
getLanguageId(scriptId) {
|
|
261
|
+
if (scriptId.scheme !== "file" && scriptId.scheme !== "untitled") {
|
|
262
|
+
return void 0;
|
|
263
|
+
}
|
|
264
|
+
return inner.getLanguageId(scriptId.fsPath);
|
|
265
|
+
},
|
|
266
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
267
|
+
if (languageId !== "pfm") return void 0;
|
|
268
|
+
try {
|
|
269
|
+
const result = inner.createVirtualCode(
|
|
270
|
+
scriptId.fsPath,
|
|
271
|
+
languageId,
|
|
272
|
+
snapshot,
|
|
273
|
+
{ getAssociatedScript: () => void 0 }
|
|
274
|
+
);
|
|
275
|
+
return result;
|
|
276
|
+
} catch (e) {
|
|
277
|
+
console.error("[PFM] createVirtualCode error:", e.message);
|
|
278
|
+
return void 0;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
updateVirtualCode(scriptId, virtualCode, newSnapshot) {
|
|
282
|
+
try {
|
|
283
|
+
const result = inner.updateVirtualCode(
|
|
284
|
+
scriptId.fsPath,
|
|
285
|
+
virtualCode,
|
|
286
|
+
newSnapshot,
|
|
287
|
+
{ getAssociatedScript: () => void 0 }
|
|
288
|
+
);
|
|
289
|
+
return result;
|
|
290
|
+
} catch (e) {
|
|
291
|
+
console.error("[PFM] updateVirtualCode error:", e.message);
|
|
292
|
+
return void 0;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
// tells typescript about the document extensions
|
|
296
|
+
typescript: {
|
|
297
|
+
extraFileExtensions: inner.typescript.extraFileExtensions,
|
|
298
|
+
getServiceScript(root) {
|
|
299
|
+
const tsCode = root.embeddedCodes?.find(
|
|
300
|
+
(c) => c.languageId === "typescript"
|
|
301
|
+
);
|
|
302
|
+
if (tsCode) {
|
|
303
|
+
return {
|
|
304
|
+
code: tsCode,
|
|
305
|
+
extension: ".ts",
|
|
306
|
+
scriptKind: 3
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return void 0;
|
|
310
|
+
},
|
|
311
|
+
getExtraServiceScripts() {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function createSvelteLanguagePluginForServer() {
|
|
318
|
+
const inner = create_svelte_language_plugin();
|
|
319
|
+
return {
|
|
320
|
+
getLanguageId(scriptId) {
|
|
321
|
+
if (scriptId.path.endsWith(".svelte")) {
|
|
322
|
+
return "svelte";
|
|
323
|
+
}
|
|
324
|
+
return void 0;
|
|
325
|
+
},
|
|
326
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
327
|
+
if (languageId !== "svelte") return void 0;
|
|
328
|
+
try {
|
|
329
|
+
return inner.createVirtualCode(
|
|
330
|
+
scriptId.fsPath,
|
|
331
|
+
languageId,
|
|
332
|
+
snapshot,
|
|
333
|
+
{ getAssociatedScript: () => void 0 }
|
|
334
|
+
);
|
|
335
|
+
} catch {
|
|
336
|
+
return void 0;
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
updateVirtualCode(scriptId, virtualCode, newSnapshot) {
|
|
340
|
+
try {
|
|
341
|
+
return inner.updateVirtualCode(
|
|
342
|
+
scriptId.fsPath,
|
|
343
|
+
virtualCode,
|
|
344
|
+
newSnapshot,
|
|
345
|
+
{ getAssociatedScript: () => void 0 }
|
|
346
|
+
);
|
|
347
|
+
} catch {
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
typescript: inner.typescript
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function start() {
|
|
355
|
+
const connection = createConnection();
|
|
356
|
+
const _on_hover = connection.onHover.bind(connection);
|
|
357
|
+
connection.onHover = (handler) => {
|
|
358
|
+
_on_hover(async (params, token) => {
|
|
359
|
+
const result = await handler(params, token);
|
|
360
|
+
if (result?.contents?.kind === "markdown" && typeof result.contents.value === "string") {
|
|
361
|
+
result.contents.value = clean_svelte_hover(result.contents.value);
|
|
362
|
+
}
|
|
363
|
+
return result;
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
const _on_definition = connection.onDefinition.bind(connection);
|
|
367
|
+
connection.onDefinition = (handler) => {
|
|
368
|
+
_on_definition(
|
|
369
|
+
async (params, token) => without_self(await handler(params, token), params.textDocument.uri, params.position)
|
|
370
|
+
);
|
|
371
|
+
};
|
|
372
|
+
const server = createServer(connection);
|
|
373
|
+
connection.listen();
|
|
374
|
+
const watched = /* @__PURE__ */ new Set();
|
|
375
|
+
let reload_timer;
|
|
376
|
+
function config_changed() {
|
|
377
|
+
clearTimeout(reload_timer);
|
|
378
|
+
reload_timer = setTimeout(() => {
|
|
379
|
+
server.project.reload();
|
|
380
|
+
server.languageFeatures.requestRefresh(false);
|
|
381
|
+
}, 100);
|
|
382
|
+
}
|
|
383
|
+
function watch_config(file) {
|
|
384
|
+
if (watched.has(file)) return;
|
|
385
|
+
watched.add(file);
|
|
386
|
+
try {
|
|
387
|
+
const watcher = watch(file, () => {
|
|
388
|
+
watcher.close();
|
|
389
|
+
watched.delete(file);
|
|
390
|
+
config_changed();
|
|
391
|
+
});
|
|
392
|
+
watcher.on("error", () => watched.delete(file));
|
|
393
|
+
} catch {
|
|
394
|
+
watched.delete(file);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
connection.onInitialize((params) => {
|
|
398
|
+
const tsdk = loadTsdkByPath(
|
|
399
|
+
params.initializationOptions?.typescript?.tsdk,
|
|
400
|
+
params.locale
|
|
401
|
+
);
|
|
402
|
+
const typescript = tsdk.typescript;
|
|
403
|
+
const config = create_config_loader({ typescript, on_read: watch_config });
|
|
404
|
+
return server.initialize(
|
|
405
|
+
params,
|
|
406
|
+
createTypeScriptProject(
|
|
407
|
+
tsdk.typescript,
|
|
408
|
+
tsdk.diagnosticMessages,
|
|
409
|
+
() => ({
|
|
410
|
+
languagePlugins: [
|
|
411
|
+
createPfmLanguagePluginForServer(typescript, config),
|
|
412
|
+
createSvelteLanguagePluginForServer()
|
|
413
|
+
]
|
|
414
|
+
})
|
|
415
|
+
),
|
|
416
|
+
[
|
|
417
|
+
...create(tsdk.typescript),
|
|
418
|
+
create$1(),
|
|
419
|
+
create$2(),
|
|
420
|
+
create_compile_diagnostics(),
|
|
421
|
+
create_completions(typescript)
|
|
422
|
+
]
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
connection.onInitialized(() => {
|
|
426
|
+
server.initialized();
|
|
427
|
+
server.fileWatcher.watchFiles([
|
|
428
|
+
"**/mdsvex.config.json",
|
|
429
|
+
"**/node_modules/.mdsvex/manifest.json"
|
|
430
|
+
]);
|
|
431
|
+
server.fileWatcher.onDidChangeWatchedFiles(({ changes }) => {
|
|
432
|
+
if (changes.some(
|
|
433
|
+
(c) => c.uri.endsWith("/mdsvex.config.json") || c.uri.endsWith("/.mdsvex/manifest.json")
|
|
434
|
+
)) {
|
|
435
|
+
config_changed();
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
connection.onShutdown(server.shutdown);
|
|
440
|
+
}
|
|
441
|
+
export {
|
|
442
|
+
start
|
|
443
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LanguageServiceContext } from '@volar/language-server';
|
|
2
|
+
import type { PfmVirtualCode } from '@mdsvex/language-core';
|
|
3
|
+
/** the pfm root code of a document, whose offsets are those of the source */
|
|
4
|
+
export declare function root_code(context: LanguageServiceContext, document: {
|
|
5
|
+
uri: string;
|
|
6
|
+
languageId: string;
|
|
7
|
+
}): PfmVirtualCode | undefined;
|