@astrojs/language-server 2.15.5 → 2.16.1-alpha.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.js +2 -2
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +8 -8
- package/dist/core/utils.js +1 -1
- package/dist/languageServerPlugin.d.ts +2 -2
- package/dist/languageServerPlugin.js +13 -11
- package/dist/nodeServer.js +1 -1
- package/dist/plugins/astro.d.ts +1 -1
- package/dist/plugins/astro.js +1 -51
- package/dist/plugins/typescript/diagnostics.d.ts +1 -1
- package/dist/plugins/typescript/index.d.ts +3 -1
- package/dist/plugins/typescript/index.js +4 -2
- package/dist/plugins/yaml.js +1 -0
- package/package.json +15 -23
package/dist/check.js
CHANGED
|
@@ -50,9 +50,9 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
50
50
|
const index_js_1 = require("./core/index.js");
|
|
51
51
|
const svelte_js_1 = require("./core/svelte.js");
|
|
52
52
|
const vue_js_1 = require("./core/vue.js");
|
|
53
|
-
const utils_js_1 = require("./utils.js");
|
|
54
53
|
const astro_js_1 = require("./plugins/astro.js");
|
|
55
54
|
const index_js_2 = require("./plugins/typescript/index.js");
|
|
55
|
+
const utils_js_1 = require("./utils.js");
|
|
56
56
|
class AstroCheck {
|
|
57
57
|
constructor(workspacePath, typescriptPath, tsconfigPath) {
|
|
58
58
|
this.workspacePath = workspacePath;
|
|
@@ -128,7 +128,7 @@ class AstroCheck {
|
|
|
128
128
|
(0, svelte_js_1.getSvelteLanguagePlugin)(),
|
|
129
129
|
(0, vue_js_1.getVueLanguagePlugin)(),
|
|
130
130
|
];
|
|
131
|
-
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)(
|
|
131
|
+
const services = [...(0, index_js_2.create)(this.ts), (0, astro_js_1.create)()];
|
|
132
132
|
if (tsconfigPath) {
|
|
133
133
|
const includeProjectReference = false; // #920
|
|
134
134
|
this.linter = kit.createTypeScriptChecker(languagePlugins, services, tsconfigPath, includeProjectReference, ({ project }) => {
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type ts from 'typescript';
|
|
|
4
4
|
import type { HTMLDocument } from 'vscode-html-languageservice';
|
|
5
5
|
import type { URI } from 'vscode-uri';
|
|
6
6
|
import type { PackageInfo } from '../importPackage.js';
|
|
7
|
-
import type { AstroMetadata } from './parseAstro';
|
|
7
|
+
import type { AstroMetadata } from './parseAstro.js';
|
|
8
8
|
export declare function addAstroTypes(astroInstall: PackageInfo | undefined, ts: typeof import('typescript'), host: ts.LanguageServiceHost): void;
|
|
9
9
|
export declare function getAstroLanguagePlugin(): LanguagePlugin<URI, AstroVirtualCode>;
|
|
10
10
|
export declare class AstroVirtualCode implements VirtualCode {
|
package/dist/core/index.js
CHANGED
|
@@ -39,10 +39,10 @@ exports.getAstroLanguagePlugin = getAstroLanguagePlugin;
|
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const language_core_1 = require("@volar/language-core");
|
|
41
41
|
const utils_js_1 = require("../utils.js");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
42
|
+
const astro2tsx_js_1 = require("./astro2tsx.js");
|
|
43
|
+
const parseAstro_js_1 = require("./parseAstro.js");
|
|
44
|
+
const parseCSS_js_1 = require("./parseCSS.js");
|
|
45
|
+
const parseHTML_js_1 = require("./parseHTML.js");
|
|
46
46
|
const parseJS_js_1 = require("./parseJS.js");
|
|
47
47
|
const decoratedHosts = new WeakSet();
|
|
48
48
|
function addAstroTypes(astroInstall, ts, host) {
|
|
@@ -160,14 +160,14 @@ class AstroVirtualCode {
|
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
162
|
];
|
|
163
|
-
const tsx = (0,
|
|
164
|
-
const astroMetadata = (0,
|
|
165
|
-
const { htmlDocument, virtualCode: htmlVirtualCode } = (0,
|
|
163
|
+
const tsx = (0, astro2tsx_js_1.astro2tsx)(this.snapshot.getText(0, this.snapshot.getLength()), this.fileName);
|
|
164
|
+
const astroMetadata = (0, parseAstro_js_1.getAstroMetadata)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()));
|
|
165
|
+
const { htmlDocument, virtualCode: htmlVirtualCode } = (0, parseHTML_js_1.parseHTML)(this.snapshot, astroMetadata.frontmatter.status === 'closed'
|
|
166
166
|
? astroMetadata.frontmatter.position.end.offset
|
|
167
167
|
: 0);
|
|
168
168
|
this.htmlDocument = htmlDocument;
|
|
169
169
|
htmlVirtualCode.embeddedCodes = [
|
|
170
|
-
...(0,
|
|
170
|
+
...(0, parseCSS_js_1.extractStylesheets)(tsx.ranges.styles),
|
|
171
171
|
...(0, parseJS_js_1.extractScriptTags)(tsx.ranges.scripts),
|
|
172
172
|
];
|
|
173
173
|
this.astroMeta = { ...astroMetadata, tsxRanges: tsx.ranges };
|
package/dist/core/utils.js
CHANGED
|
@@ -35,7 +35,7 @@ function toPascalCase(string) {
|
|
|
35
35
|
return `${string}`
|
|
36
36
|
.replace(new RegExp(/[-_]+/, 'g'), ' ')
|
|
37
37
|
.replace(new RegExp(/[^\w\s]/, 'g'), '')
|
|
38
|
-
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (
|
|
38
|
+
.replace(new RegExp(/\s+(.)(\w*)/, 'g'), (_, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`)
|
|
39
39
|
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
40
40
|
}
|
|
41
41
|
function classNameFromFilename(filename) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Connection, type LanguagePlugin } from '@volar/language-server/node';
|
|
1
|
+
import { type Connection, type InitializeParams, type LanguagePlugin } from '@volar/language-server/node';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
3
|
import { type CollectionConfig } from './core/frontmatterHolders.js';
|
|
4
4
|
export declare function getLanguagePlugins(collectionConfig: CollectionConfig): LanguagePlugin<URI, import("@volar/language-server/node").VirtualCode>[];
|
|
5
|
-
export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript'), collectionConfig: CollectionConfig): import("@volar/language-server/node").LanguageServicePlugin<any>[];
|
|
5
|
+
export declare function getLanguageServicePlugins(connection: Connection, ts: typeof import('typescript'), collectionConfig: CollectionConfig, initializeParams?: InitializeParams): import("@volar/language-server/node").LanguageServicePlugin<any>[];
|
|
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLanguagePlugins = getLanguagePlugins;
|
|
4
4
|
exports.getLanguageServicePlugins = getLanguageServicePlugins;
|
|
5
5
|
const node_1 = require("@volar/language-server/node");
|
|
6
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
7
|
-
const core_1 = require("./core");
|
|
8
|
-
const svelte_js_1 = require("./core/svelte.js");
|
|
9
|
-
const vue_js_1 = require("./core/vue.js");
|
|
10
|
-
const importPackage_js_1 = require("./importPackage.js");
|
|
11
6
|
// Services
|
|
12
7
|
const volar_service_css_1 = require("volar-service-css");
|
|
13
8
|
const volar_service_emmet_1 = require("volar-service-emmet");
|
|
14
9
|
const volar_service_prettier_1 = require("volar-service-prettier");
|
|
15
10
|
const volar_service_typescript_twoslash_queries_1 = require("volar-service-typescript-twoslash-queries");
|
|
11
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
12
|
+
const core_1 = require("./core");
|
|
16
13
|
const frontmatterHolders_js_1 = require("./core/frontmatterHolders.js");
|
|
14
|
+
const svelte_js_1 = require("./core/svelte.js");
|
|
15
|
+
const vue_js_1 = require("./core/vue.js");
|
|
16
|
+
const importPackage_js_1 = require("./importPackage.js");
|
|
17
17
|
const astro_js_1 = require("./plugins/astro.js");
|
|
18
18
|
const html_js_1 = require("./plugins/html.js");
|
|
19
|
-
const index_js_1 = require("./plugins/typescript
|
|
20
|
-
const index_js_2 = require("./plugins/typescript/index.js");
|
|
19
|
+
const index_js_1 = require("./plugins/typescript/index.js");
|
|
20
|
+
const index_js_2 = require("./plugins/typescript-addons/index.js");
|
|
21
21
|
const yaml_js_1 = require("./plugins/yaml.js");
|
|
22
22
|
function getLanguagePlugins(collectionConfig) {
|
|
23
23
|
const languagePlugins = [
|
|
@@ -28,15 +28,17 @@ function getLanguagePlugins(collectionConfig) {
|
|
|
28
28
|
];
|
|
29
29
|
return languagePlugins;
|
|
30
30
|
}
|
|
31
|
-
function getLanguageServicePlugins(connection, ts, collectionConfig) {
|
|
31
|
+
function getLanguageServicePlugins(connection, ts, collectionConfig, initializeParams) {
|
|
32
32
|
const LanguageServicePlugins = [
|
|
33
33
|
(0, html_js_1.create)(),
|
|
34
34
|
(0, volar_service_css_1.create)(),
|
|
35
35
|
(0, volar_service_emmet_1.create)(),
|
|
36
|
-
...(0,
|
|
36
|
+
...(0, index_js_1.create)(ts, {
|
|
37
|
+
disableAutoImportCache: initializeParams?.initializationOptions?.disableAutoImportCache,
|
|
38
|
+
}),
|
|
37
39
|
(0, volar_service_typescript_twoslash_queries_1.create)(ts),
|
|
38
|
-
(0,
|
|
39
|
-
(0, astro_js_1.create)(
|
|
40
|
+
(0, index_js_2.create)(),
|
|
41
|
+
(0, astro_js_1.create)(),
|
|
40
42
|
getPrettierService(),
|
|
41
43
|
(0, yaml_js_1.create)(collectionConfig),
|
|
42
44
|
];
|
package/dist/nodeServer.js
CHANGED
|
@@ -70,7 +70,7 @@ connection.onInitialize((params) => {
|
|
|
70
70
|
(0, index_js_1.addAstroTypes)(typeof astroInstall === 'string' ? undefined : astroInstall, typescript, languageServiceHost);
|
|
71
71
|
},
|
|
72
72
|
};
|
|
73
|
-
}), (0, languageServerPlugin_js_1.getLanguageServicePlugins)(connection, typescript, collectionConfig));
|
|
73
|
+
}), (0, languageServerPlugin_js_1.getLanguageServicePlugins)(connection, typescript, collectionConfig, params));
|
|
74
74
|
});
|
|
75
75
|
connection.onInitialized(() => {
|
|
76
76
|
server.initialized();
|
package/dist/plugins/astro.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-server';
|
|
2
|
-
export declare const create: (
|
|
2
|
+
export declare const create: () => LanguageServicePlugin;
|
package/dist/plugins/astro.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
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 node_path_1 = require("node:path");
|
|
8
4
|
const language_server_1 = require("@volar/language-server");
|
|
9
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
11
6
|
const index_js_1 = require("../core/index.js");
|
|
12
|
-
const
|
|
13
|
-
const create = (ts) => {
|
|
7
|
+
const create = () => {
|
|
14
8
|
return {
|
|
15
9
|
capabilities: {
|
|
16
10
|
completionProvider: {
|
|
@@ -20,7 +14,6 @@ const create = (ts) => {
|
|
|
20
14
|
interFileDependencies: false,
|
|
21
15
|
workspaceDiagnostics: false,
|
|
22
16
|
},
|
|
23
|
-
codeLensProvider: {},
|
|
24
17
|
},
|
|
25
18
|
create(context) {
|
|
26
19
|
return {
|
|
@@ -64,54 +57,11 @@ const create = (ts) => {
|
|
|
64
57
|
};
|
|
65
58
|
}
|
|
66
59
|
},
|
|
67
|
-
provideCodeLenses(document, token) {
|
|
68
|
-
if (token.isCancellationRequested)
|
|
69
|
-
return;
|
|
70
|
-
if (!(0, utils_js_1.isJSDocument)(document.languageId))
|
|
71
|
-
return;
|
|
72
|
-
if (!context.project.typescript)
|
|
73
|
-
return;
|
|
74
|
-
const { uriConverter } = context.project.typescript;
|
|
75
|
-
const languageService = context.inject('typescript/languageService');
|
|
76
|
-
if (!languageService)
|
|
77
|
-
return;
|
|
78
|
-
const tsProgram = languageService.getProgram();
|
|
79
|
-
if (!tsProgram)
|
|
80
|
-
return;
|
|
81
|
-
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
|
82
|
-
if (!decoded)
|
|
83
|
-
return;
|
|
84
|
-
const globcodeLens = [];
|
|
85
|
-
const sourceFile = tsProgram.getSourceFile(decoded[0].fsPath);
|
|
86
|
-
function walk() {
|
|
87
|
-
return ts.forEachChild(sourceFile, function cb(node) {
|
|
88
|
-
if (ts.isCallExpression(node) && node.expression.getText() === 'Astro.glob') {
|
|
89
|
-
const globArgument = node.arguments.at(0);
|
|
90
|
-
if (globArgument && decoded) {
|
|
91
|
-
globcodeLens.push(getGlobResultAsCodeLens(globArgument.getText().slice(1, -1), (0, node_path_1.dirname)(uriConverter.asFileName(decoded[0])), document.positionAt(node.arguments.pos)));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return ts.forEachChild(node, cb);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
walk();
|
|
98
|
-
return globcodeLens;
|
|
99
|
-
},
|
|
100
60
|
};
|
|
101
61
|
},
|
|
102
62
|
};
|
|
103
63
|
};
|
|
104
64
|
exports.create = create;
|
|
105
|
-
function getGlobResultAsCodeLens(globText, dir, position) {
|
|
106
|
-
const globResult = fast_glob_1.default.sync(globText, {
|
|
107
|
-
cwd: dir,
|
|
108
|
-
onlyFiles: true,
|
|
109
|
-
});
|
|
110
|
-
return {
|
|
111
|
-
range: language_server_1.Range.create(position, position),
|
|
112
|
-
command: { title: `Matches ${globResult.length} files`, command: '' },
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
65
|
function getFrontmatterCompletion(file, document, position) {
|
|
116
66
|
const base = {
|
|
117
67
|
kind: language_server_1.CompletionItemKind.Snippet,
|
|
@@ -9,4 +9,4 @@ export declare enum DiagnosticCodes {
|
|
|
9
9
|
JSX_NO_CLOSING_TAG = 17008,// JSX element '{0}' has no corresponding closing tag.
|
|
10
10
|
JSX_ELEMENT_NO_CALL = 2604
|
|
11
11
|
}
|
|
12
|
-
export declare function enhancedProvideSemanticDiagnostics(originalDiagnostics: Diagnostic[], tsxLineCount?: number
|
|
12
|
+
export declare function enhancedProvideSemanticDiagnostics(originalDiagnostics: Diagnostic[], tsxLineCount?: number): Diagnostic[];
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { LanguageServicePlugin } from '@volar/language-server';
|
|
2
|
-
export declare const create: (ts: typeof import("typescript")
|
|
2
|
+
export declare const create: (ts: typeof import("typescript"), options?: {
|
|
3
|
+
disableAutoImportCache: boolean | undefined;
|
|
4
|
+
}) => LanguageServicePlugin[];
|
|
@@ -7,8 +7,10 @@ const index_js_1 = require("../../core/index.js");
|
|
|
7
7
|
const codeActions_js_1 = require("./codeActions.js");
|
|
8
8
|
const completions_js_1 = require("./completions.js");
|
|
9
9
|
const diagnostics_js_1 = require("./diagnostics.js");
|
|
10
|
-
const create = (ts) => {
|
|
11
|
-
const tsServicePlugins = (0, volar_service_typescript_1.create)(ts, {
|
|
10
|
+
const create = (ts, options) => {
|
|
11
|
+
const tsServicePlugins = (0, volar_service_typescript_1.create)(ts, {
|
|
12
|
+
disableAutoImportCache: options?.disableAutoImportCache,
|
|
13
|
+
});
|
|
12
14
|
return tsServicePlugins.map((plugin) => {
|
|
13
15
|
if (plugin.name === 'typescript-semantic') {
|
|
14
16
|
return {
|
package/dist/plugins/yaml.js
CHANGED
|
@@ -100,6 +100,7 @@ const create = (collectionConfig) => {
|
|
|
100
100
|
// Remove last line that contains the source schema, it's not useful to users since they're generated
|
|
101
101
|
originalHover.contents.value = originalHover.contents.value
|
|
102
102
|
.replace(/\nSource:.*$/, '')
|
|
103
|
+
.replace(/\n\nsource$/, '')
|
|
103
104
|
.trim();
|
|
104
105
|
}
|
|
105
106
|
return originalHover;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.1-alpha.0",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/withastro/
|
|
9
|
-
"directory": "packages/language-server"
|
|
8
|
+
"url": "https://github.com/withastro/astro.git",
|
|
9
|
+
"directory": "packages/language-tools/language-server"
|
|
10
10
|
},
|
|
11
11
|
"type": "commonjs",
|
|
12
12
|
"main": "dist/index.js",
|
|
@@ -29,32 +29,25 @@
|
|
|
29
29
|
"@volar/language-service": "~2.4.23",
|
|
30
30
|
"fast-glob": "^3.2.12",
|
|
31
31
|
"muggle-string": "^0.4.1",
|
|
32
|
-
"volar-service-css": "0.0.
|
|
33
|
-
"volar-service-emmet": "0.0.
|
|
34
|
-
"volar-service-html": "0.0.
|
|
35
|
-
"volar-service-prettier": "0.0.
|
|
36
|
-
"volar-service-typescript": "0.0.
|
|
37
|
-
"volar-service-typescript-twoslash-queries": "0.0.
|
|
38
|
-
"volar-service-yaml": "0.0.
|
|
32
|
+
"volar-service-css": "0.0.66",
|
|
33
|
+
"volar-service-emmet": "0.0.66",
|
|
34
|
+
"volar-service-html": "0.0.66",
|
|
35
|
+
"volar-service-prettier": "0.0.66",
|
|
36
|
+
"volar-service-typescript": "0.0.66",
|
|
37
|
+
"volar-service-typescript-twoslash-queries": "0.0.66",
|
|
38
|
+
"volar-service-yaml": "0.0.66",
|
|
39
39
|
"vscode-html-languageservice": "^5.5.2",
|
|
40
40
|
"vscode-uri": "^3.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@astrojs/svelte": "^5.0.3",
|
|
44
|
-
"@astrojs/vue": "^4.0.8",
|
|
45
|
-
"@types/chai": "^4.3.5",
|
|
46
|
-
"@types/mocha": "^10.0.1",
|
|
47
43
|
"@types/node": "^20.9.0",
|
|
48
44
|
"@volar/test-utils": "~2.4.23",
|
|
49
45
|
"@volar/typescript": "~2.4.23",
|
|
50
|
-
"
|
|
51
|
-
"chai": "^4.3.7",
|
|
52
|
-
"mocha": "^10.2.0",
|
|
53
|
-
"svelte": "^4.2.10",
|
|
54
|
-
"tsx": "^3.12.7",
|
|
46
|
+
"tsx": "^4.20.6",
|
|
55
47
|
"typescript": "^5.9.3",
|
|
56
48
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
57
|
-
"vscode-languageserver-textdocument": "^1.0.11"
|
|
49
|
+
"vscode-languageserver-textdocument": "^1.0.11",
|
|
50
|
+
"astro-scripts": "0.0.14"
|
|
58
51
|
},
|
|
59
52
|
"peerDependencies": {
|
|
60
53
|
"prettier": "^3.0.0",
|
|
@@ -71,8 +64,7 @@
|
|
|
71
64
|
"scripts": {
|
|
72
65
|
"build": "tsc",
|
|
73
66
|
"dev": "tsc --watch",
|
|
74
|
-
"
|
|
75
|
-
"test": "pnpm run
|
|
76
|
-
"test:match": "pnpm run test -g"
|
|
67
|
+
"test": "astro-scripts test \"**/*.test.ts\" --teardown-test ./test/misc/teardown.ts --tsx true --setup ./test/setup.js",
|
|
68
|
+
"test:match": "pnpm run test --match"
|
|
77
69
|
}
|
|
78
70
|
}
|