@astrojs/language-server 2.6.2 → 2.7.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.
- package/dist/check.d.ts +1 -2
- package/dist/check.js +10 -20
- package/dist/core/astro2tsx.d.ts +17 -9
- package/dist/core/astro2tsx.js +27 -41
- package/dist/core/index.d.ts +11 -13
- package/dist/core/index.js +102 -75
- package/dist/core/parseAstro.js +6 -1
- package/dist/core/parseCSS.d.ts +3 -3
- package/dist/core/parseCSS.js +35 -54
- package/dist/core/parseHTML.d.ts +4 -4
- package/dist/core/parseHTML.js +17 -16
- package/dist/core/parseJS.d.ts +3 -3
- package/dist/core/parseJS.js +34 -61
- package/dist/core/svelte.d.ts +10 -12
- package/dist/core/svelte.js +39 -16
- package/dist/core/utils.d.ts +3 -3
- package/dist/core/utils.js +21 -40
- package/dist/core/vue.d.ts +10 -12
- package/dist/core/vue.js +39 -16
- package/dist/languageServerPlugin.d.ts +3 -2
- package/dist/languageServerPlugin.js +103 -90
- package/dist/nodeServer.js +9 -1
- package/dist/plugins/astro.d.ts +2 -2
- package/dist/plugins/astro.js +63 -60
- package/dist/plugins/html-data.js +11 -1
- package/dist/plugins/html.d.ts +2 -2
- package/dist/plugins/html.js +37 -37
- package/dist/plugins/typescript/codeActions.js +5 -5
- package/dist/plugins/typescript/completions.js +5 -5
- package/dist/plugins/typescript/index.d.ts +2 -2
- package/dist/plugins/typescript/index.js +49 -53
- package/dist/plugins/typescript-addons/index.d.ts +2 -2
- package/dist/plugins/typescript-addons/index.js +32 -28
- package/dist/utils.d.ts +1 -1
- package/package.json +14 -15
|
@@ -1,64 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.create = void 0;
|
|
7
|
-
const volar_service_typescript_1 =
|
|
4
|
+
const volar_service_typescript_1 = require("volar-service-typescript");
|
|
8
5
|
const index_js_1 = require("../../core/index.js");
|
|
9
6
|
const codeActions_js_1 = require("./codeActions.js");
|
|
10
7
|
const completions_js_1 = require("./completions.js");
|
|
11
8
|
const diagnostics_js_1 = require("./diagnostics.js");
|
|
12
|
-
const create = () =>
|
|
13
|
-
const
|
|
14
|
-
if (!context) {
|
|
15
|
-
return {
|
|
16
|
-
triggerCharacters: typeScriptPlugin.triggerCharacters,
|
|
17
|
-
signatureHelpTriggerCharacters: typeScriptPlugin.signatureHelpTriggerCharacters,
|
|
18
|
-
signatureHelpRetriggerCharacters: typeScriptPlugin.signatureHelpRetriggerCharacters,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
9
|
+
const create = (ts) => {
|
|
10
|
+
const tsServicePlugin = (0, volar_service_typescript_1.create)(ts);
|
|
21
11
|
return {
|
|
22
|
-
...
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
12
|
+
...tsServicePlugin,
|
|
13
|
+
create(context) {
|
|
14
|
+
const typeScriptPlugin = tsServicePlugin.create(context);
|
|
15
|
+
return {
|
|
16
|
+
...typeScriptPlugin,
|
|
17
|
+
async provideCompletionItems(document, position, completionContext, token) {
|
|
18
|
+
const originalCompletions = await typeScriptPlugin.provideCompletionItems(document, position, completionContext, token);
|
|
19
|
+
if (!originalCompletions)
|
|
20
|
+
return null;
|
|
21
|
+
return (0, completions_js_1.enhancedProvideCompletionItems)(originalCompletions);
|
|
22
|
+
},
|
|
23
|
+
async resolveCompletionItem(item, token) {
|
|
24
|
+
const resolvedCompletionItem = await typeScriptPlugin.resolveCompletionItem(item, token);
|
|
25
|
+
if (!resolvedCompletionItem)
|
|
26
|
+
return item;
|
|
27
|
+
return (0, completions_js_1.enhancedResolveCompletionItem)(resolvedCompletionItem, context);
|
|
28
|
+
},
|
|
29
|
+
async provideCodeActions(document, range, codeActionContext, token) {
|
|
30
|
+
const originalCodeActions = await typeScriptPlugin.provideCodeActions(document, range, codeActionContext, token);
|
|
31
|
+
if (!originalCodeActions)
|
|
32
|
+
return null;
|
|
33
|
+
return (0, codeActions_js_1.enhancedProvideCodeActions)(originalCodeActions, context);
|
|
34
|
+
},
|
|
35
|
+
async resolveCodeAction(codeAction, token) {
|
|
36
|
+
const resolvedCodeAction = await typeScriptPlugin.resolveCodeAction(codeAction, token);
|
|
37
|
+
if (!resolvedCodeAction)
|
|
38
|
+
return codeAction;
|
|
39
|
+
return (0, codeActions_js_1.enhancedResolveCodeAction)(resolvedCodeAction, context);
|
|
40
|
+
},
|
|
41
|
+
async provideSemanticDiagnostics(document, token) {
|
|
42
|
+
const [_, source] = context.documents.getVirtualCodeByUri(document.uri);
|
|
43
|
+
const code = source?.generated?.code;
|
|
44
|
+
let tsxLineCount = undefined;
|
|
45
|
+
if (code instanceof index_js_1.AstroVirtualCode) {
|
|
46
|
+
// If we have compiler errors, our TSX isn't valid so don't bother showing TS errors
|
|
47
|
+
if (code.hasCompilationErrors)
|
|
48
|
+
return null;
|
|
49
|
+
// We'll use this to filter out diagnostics that are outside the mapped range of the TSX
|
|
50
|
+
tsxLineCount = code.astroMeta.tsxRanges.body.end.line;
|
|
51
|
+
}
|
|
52
|
+
const diagnostics = await typeScriptPlugin.provideSemanticDiagnostics(document, token);
|
|
53
|
+
if (!diagnostics)
|
|
54
|
+
return null;
|
|
55
|
+
return (0, diagnostics_js_1.enhancedProvideSemanticDiagnostics)(diagnostics, tsxLineCount);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
62
58
|
},
|
|
63
59
|
};
|
|
64
60
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const create: () =>
|
|
1
|
+
import type { ServicePlugin } from '@volar/language-server';
|
|
2
|
+
export declare const create: () => ServicePlugin;
|
|
@@ -4,36 +4,40 @@ exports.create = void 0;
|
|
|
4
4
|
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const snippets_js_1 = require("./snippets.js");
|
|
7
|
-
const create = () =>
|
|
7
|
+
const create = () => {
|
|
8
8
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
create(context) {
|
|
10
|
+
return {
|
|
11
|
+
isAdditionalCompletion: true,
|
|
12
|
+
// Q: Why the empty transform and resolve functions?
|
|
13
|
+
// A: Volar will skip mapping the completion items if those functions are defined, as such we can return the snippets
|
|
14
|
+
// completions as-is, this is notably useful for snippets that insert to the frontmatter, since we don't need to map anything.
|
|
15
|
+
transformCompletionItem(item) {
|
|
16
|
+
return item;
|
|
17
|
+
},
|
|
18
|
+
provideCompletionItems(document, position, completionContext, token) {
|
|
19
|
+
if (!context ||
|
|
20
|
+
!utils_js_1.isJSDocument ||
|
|
21
|
+
token.isCancellationRequested ||
|
|
22
|
+
completionContext.triggerKind === 2)
|
|
23
|
+
return null;
|
|
24
|
+
const [_, source] = context.documents.getVirtualCodeByUri(document.uri);
|
|
25
|
+
const code = source?.generated?.code;
|
|
26
|
+
if (!(code instanceof index_js_1.AstroVirtualCode))
|
|
27
|
+
return undefined;
|
|
28
|
+
if (!(0, utils_js_1.isInsideFrontmatter)(document.offsetAt(position), code.astroMeta.frontmatter))
|
|
29
|
+
return null;
|
|
30
|
+
const completionList = {
|
|
31
|
+
items: [],
|
|
32
|
+
isIncomplete: false,
|
|
33
|
+
};
|
|
34
|
+
completionList.items.push(...(0, snippets_js_1.getSnippetCompletions)(code.astroMeta.frontmatter));
|
|
35
|
+
return completionList;
|
|
36
|
+
},
|
|
37
|
+
resolveCompletionItem(item) {
|
|
38
|
+
return item;
|
|
39
|
+
},
|
|
31
40
|
};
|
|
32
|
-
completionList.items.push(...(0, snippets_js_1.getSnippetCompletions)(file.astroMeta.frontmatter));
|
|
33
|
-
return completionList;
|
|
34
|
-
},
|
|
35
|
-
resolveCompletionItem(item) {
|
|
36
|
-
return item;
|
|
37
41
|
},
|
|
38
42
|
};
|
|
39
43
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export interface AstroInstall {
|
|
|
10
10
|
export declare function getLanguageServerTypesDir(ts: typeof import('typescript')): string;
|
|
11
11
|
export declare function getAstroInstall(basePaths: string[], checkForAstro?: {
|
|
12
12
|
nearestPackageJson: string | undefined;
|
|
13
|
-
readDirectory: typeof import('typescript
|
|
13
|
+
readDirectory: typeof import('typescript').sys.readDirectory;
|
|
14
14
|
}): AstroInstall | 'not-an-astro-project' | 'not-found';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,21 +22,19 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@astrojs/compiler": "^2.4.0",
|
|
24
24
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
|
25
|
-
"@volar/kit": "~
|
|
26
|
-
"@volar/language-core": "~
|
|
27
|
-
"@volar/language-server": "~
|
|
28
|
-
"@volar/language-service": "~
|
|
29
|
-
"@volar/
|
|
30
|
-
"@volar/typescript": "~1.11.1",
|
|
25
|
+
"@volar/kit": "~2.0.2",
|
|
26
|
+
"@volar/language-core": "~2.0.2",
|
|
27
|
+
"@volar/language-server": "~2.0.2",
|
|
28
|
+
"@volar/language-service": "~2.0.2",
|
|
29
|
+
"@volar/typescript": "~2.0.2",
|
|
31
30
|
"fast-glob": "^3.2.12",
|
|
32
|
-
"
|
|
33
|
-
"volar-service-
|
|
34
|
-
"volar-service-
|
|
35
|
-
"volar-service-
|
|
36
|
-
"volar-service-
|
|
37
|
-
"volar-service-typescript": "0.0.
|
|
38
|
-
"
|
|
39
|
-
"vscode-html-languageservice": "^5.1.0",
|
|
31
|
+
"volar-service-css": "0.0.28",
|
|
32
|
+
"volar-service-emmet": "0.0.28",
|
|
33
|
+
"volar-service-html": "0.0.28",
|
|
34
|
+
"volar-service-prettier": "0.0.28",
|
|
35
|
+
"volar-service-typescript": "0.0.28",
|
|
36
|
+
"volar-service-typescript-twoslash-queries": "0.0.28",
|
|
37
|
+
"vscode-html-languageservice": "^5.1.1",
|
|
40
38
|
"vscode-uri": "^3.0.8"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
@@ -45,6 +43,7 @@
|
|
|
45
43
|
"@types/chai": "^4.3.5",
|
|
46
44
|
"@types/mocha": "^10.0.1",
|
|
47
45
|
"@types/node": "^18.17.8",
|
|
46
|
+
"@volar/test-utils": "~2.0.2",
|
|
48
47
|
"astro": "^4.1.0",
|
|
49
48
|
"chai": "^4.3.7",
|
|
50
49
|
"mocha": "^10.2.0",
|