@astrojs/language-server 2.3.1 → 2.3.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/check.d.ts +2 -1
- package/dist/check.js +21 -10
- package/dist/languageServerPlugin.js +17 -19
- package/dist/plugins/astro.d.ts +1 -2
- package/dist/plugins/astro.js +3 -1
- package/dist/plugins/html.d.ts +1 -2
- package/dist/plugins/html.js +3 -1
- package/dist/plugins/typescript/index.d.ts +1 -2
- package/dist/plugins/typescript/index.js +3 -1
- package/dist/plugins/typescript-addons/index.d.ts +1 -1
- package/dist/plugins/typescript-addons/index.js +3 -3
- package/package.json +7 -7
package/dist/check.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as kit from '@volar/kit';
|
|
2
2
|
import { Diagnostic, DiagnosticSeverity } from '@volar/language-server';
|
|
3
|
-
export {
|
|
3
|
+
export { Diagnostic, DiagnosticSeverity };
|
|
4
4
|
export interface CheckResult {
|
|
5
5
|
status: 'completed' | 'cancelled' | undefined;
|
|
6
6
|
fileChecked: number;
|
|
@@ -11,6 +11,7 @@ export interface CheckResult {
|
|
|
11
11
|
errors: kit.Diagnostic[];
|
|
12
12
|
fileUrl: URL;
|
|
13
13
|
fileContent: string;
|
|
14
|
+
text: string;
|
|
14
15
|
}[];
|
|
15
16
|
}
|
|
16
17
|
export declare class AstroCheck {
|
package/dist/check.js
CHANGED
|
@@ -26,19 +26,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.AstroCheck = exports.
|
|
29
|
+
exports.AstroCheck = exports.DiagnosticSeverity = exports.Diagnostic = void 0;
|
|
30
30
|
const kit = __importStar(require("@volar/kit"));
|
|
31
31
|
const language_server_1 = require("@volar/language-server");
|
|
32
32
|
Object.defineProperty(exports, "Diagnostic", { enumerable: true, get: function () { return language_server_1.Diagnostic; } });
|
|
33
33
|
Object.defineProperty(exports, "DiagnosticSeverity", { enumerable: true, get: function () { return language_server_1.DiagnosticSeverity; } });
|
|
34
34
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
35
|
+
const node_fs_1 = require("node:fs");
|
|
35
36
|
const node_url_1 = require("node:url");
|
|
36
37
|
const index_js_1 = require("./core/index.js");
|
|
37
38
|
const svelte_js_1 = require("./core/svelte.js");
|
|
38
39
|
const vue_js_1 = require("./core/vue.js");
|
|
39
|
-
const astro_js_1 = __importDefault(require("./plugins/astro.js"));
|
|
40
|
-
const index_js_2 = __importDefault(require("./plugins/typescript/index.js"));
|
|
41
40
|
const utils_js_1 = require("./utils.js");
|
|
41
|
+
const astro_js_1 = require("./plugins/astro.js");
|
|
42
|
+
const index_js_2 = require("./plugins/typescript/index.js");
|
|
42
43
|
class AstroCheck {
|
|
43
44
|
constructor(workspacePath, typescriptPath, tsconfigPath) {
|
|
44
45
|
this.workspacePath = workspacePath;
|
|
@@ -67,7 +68,9 @@ class AstroCheck {
|
|
|
67
68
|
result.status = 'cancelled';
|
|
68
69
|
return result;
|
|
69
70
|
}
|
|
70
|
-
const fileDiagnostics =
|
|
71
|
+
const fileDiagnostics = await this.linter.check(file);
|
|
72
|
+
// Filter diagnostics based on the logErrors level
|
|
73
|
+
const fileDiagnosticsToPrint = fileDiagnostics.filter((diag) => {
|
|
71
74
|
const severity = diag.severity ?? language_server_1.DiagnosticSeverity.Error;
|
|
72
75
|
switch (logErrors?.level ?? 'error') {
|
|
73
76
|
case 'error':
|
|
@@ -78,16 +81,18 @@ class AstroCheck {
|
|
|
78
81
|
return severity <= language_server_1.DiagnosticSeverity.Hint;
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
|
-
if (logErrors) {
|
|
82
|
-
this.linter.logErrors(file, fileDiagnostics);
|
|
83
|
-
}
|
|
84
84
|
if (fileDiagnostics.length > 0) {
|
|
85
|
+
const errorText = this.linter.printErrors(file, fileDiagnosticsToPrint);
|
|
86
|
+
if (logErrors !== undefined && errorText) {
|
|
87
|
+
console.info(errorText);
|
|
88
|
+
}
|
|
85
89
|
const fileSnapshot = this.project.languageHost.getScriptSnapshot(file);
|
|
86
90
|
const fileContent = fileSnapshot?.getText(0, fileSnapshot.getLength());
|
|
87
91
|
result.fileResult.push({
|
|
88
92
|
errors: fileDiagnostics,
|
|
89
93
|
fileContent: fileContent ?? '',
|
|
90
94
|
fileUrl: (0, node_url_1.pathToFileURL)(file),
|
|
95
|
+
text: errorText,
|
|
91
96
|
});
|
|
92
97
|
result.errors += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Error).length;
|
|
93
98
|
result.warnings += fileDiagnostics.filter((diag) => diag.severity === language_server_1.DiagnosticSeverity.Warning).length;
|
|
@@ -108,8 +113,8 @@ class AstroCheck {
|
|
|
108
113
|
vue: (0, vue_js_1.getVueLanguageModule)(),
|
|
109
114
|
},
|
|
110
115
|
services: {
|
|
111
|
-
typescript: (0, index_js_2.
|
|
112
|
-
astro: (0, astro_js_1.
|
|
116
|
+
typescript: (0, index_js_2.create)(),
|
|
117
|
+
astro: (0, astro_js_1.create)(),
|
|
113
118
|
},
|
|
114
119
|
};
|
|
115
120
|
if (tsconfigPath) {
|
|
@@ -131,7 +136,13 @@ class AstroCheck {
|
|
|
131
136
|
this.linter = kit.createLinter(config, this.project.languageHost);
|
|
132
137
|
}
|
|
133
138
|
getTsconfig() {
|
|
134
|
-
|
|
139
|
+
if (this.tsconfigPath) {
|
|
140
|
+
if (!(0, node_fs_1.existsSync)(this.tsconfigPath)) {
|
|
141
|
+
throw new Error(`Specified tsconfig file \`${this.tsconfigPath}\` does not exist.`);
|
|
142
|
+
}
|
|
143
|
+
return this.tsconfigPath;
|
|
144
|
+
}
|
|
145
|
+
const searchPath = this.workspacePath;
|
|
135
146
|
const tsconfig = this.ts.findConfigFile(searchPath, this.ts.sys.fileExists) ||
|
|
136
147
|
this.ts.findConfigFile(searchPath, this.ts.sys.fileExists, 'jsconfig.json');
|
|
137
148
|
return tsconfig;
|
|
@@ -1,23 +1,21 @@
|
|
|
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.plugin = void 0;
|
|
7
4
|
const node_1 = require("@volar/language-server/node");
|
|
8
|
-
const volar_service_css_1 = __importDefault(require("volar-service-css"));
|
|
9
|
-
const volar_service_emmet_1 = __importDefault(require("volar-service-emmet"));
|
|
10
|
-
const volar_service_prettier_1 = __importDefault(require("volar-service-prettier"));
|
|
11
|
-
const volar_service_typescript_twoslash_queries_1 = __importDefault(require("volar-service-typescript-twoslash-queries"));
|
|
12
5
|
const core_1 = require("./core");
|
|
13
6
|
const svelte_js_1 = require("./core/svelte.js");
|
|
14
7
|
const vue_js_1 = require("./core/vue.js");
|
|
15
8
|
const importPackage_js_1 = require("./importPackage.js");
|
|
16
|
-
const astro_js_1 = __importDefault(require("./plugins/astro.js"));
|
|
17
|
-
const html_js_1 = __importDefault(require("./plugins/html.js"));
|
|
18
|
-
const index_js_1 = require("./plugins/typescript-addons/index.js");
|
|
19
|
-
const index_js_2 = __importDefault(require("./plugins/typescript/index.js"));
|
|
20
9
|
const utils_js_1 = require("./utils.js");
|
|
10
|
+
// Services
|
|
11
|
+
const volar_service_css_1 = require("volar-service-css");
|
|
12
|
+
const volar_service_emmet_1 = require("volar-service-emmet");
|
|
13
|
+
const volar_service_prettier_1 = require("volar-service-prettier");
|
|
14
|
+
const volar_service_typescript_twoslash_queries_1 = require("volar-service-typescript-twoslash-queries");
|
|
15
|
+
const astro_js_1 = require("./plugins/astro.js");
|
|
16
|
+
const html_js_1 = require("./plugins/html.js");
|
|
17
|
+
const index_js_1 = require("./plugins/typescript-addons/index.js");
|
|
18
|
+
const index_js_2 = require("./plugins/typescript/index.js");
|
|
21
19
|
const plugin = (initOptions, modules) => ({
|
|
22
20
|
extraFileExtensions: [
|
|
23
21
|
{ extension: 'astro', isMixedContent: true, scriptKind: 7 },
|
|
@@ -53,19 +51,19 @@ const plugin = (initOptions, modules) => ({
|
|
|
53
51
|
config.languages.svelte = (0, svelte_js_1.getSvelteLanguageModule)();
|
|
54
52
|
}
|
|
55
53
|
config.services ??= {};
|
|
56
|
-
config.services.html ??= (0, html_js_1.
|
|
57
|
-
config.services.css ??= (0, volar_service_css_1.
|
|
58
|
-
config.services.emmet ??= (0, volar_service_emmet_1.
|
|
59
|
-
config.services.typescript ??= (0, index_js_2.
|
|
60
|
-
config.services.typescripttwoslash ??= (0, volar_service_typescript_twoslash_queries_1.
|
|
61
|
-
config.services.typescriptaddons ??= (0, index_js_1.
|
|
62
|
-
config.services.astro ??= (0, astro_js_1.
|
|
54
|
+
config.services.html ??= (0, html_js_1.create)();
|
|
55
|
+
config.services.css ??= (0, volar_service_css_1.create)();
|
|
56
|
+
config.services.emmet ??= (0, volar_service_emmet_1.create)();
|
|
57
|
+
config.services.typescript ??= (0, index_js_2.create)();
|
|
58
|
+
config.services.typescripttwoslash ??= (0, volar_service_typescript_twoslash_queries_1.create)();
|
|
59
|
+
config.services.typescriptaddons ??= (0, index_js_1.create)();
|
|
60
|
+
config.services.astro ??= (0, astro_js_1.create)();
|
|
63
61
|
if (ctx) {
|
|
64
62
|
const rootDir = ctx.env.uriToFileName(ctx.project.rootUri.toString());
|
|
65
63
|
const prettier = (0, importPackage_js_1.importPrettier)(rootDir);
|
|
66
64
|
const prettierPluginPath = (0, importPackage_js_1.getPrettierPluginPath)(rootDir);
|
|
67
65
|
if (prettier && prettierPluginPath) {
|
|
68
|
-
config.services.prettier ??= (0, volar_service_prettier_1.
|
|
66
|
+
config.services.prettier ??= (0, volar_service_prettier_1.create)({
|
|
69
67
|
prettier: prettier,
|
|
70
68
|
languages: ['astro'],
|
|
71
69
|
ignoreIdeOptions: true,
|
package/dist/plugins/astro.d.ts
CHANGED
package/dist/plugins/astro.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create = void 0;
|
|
6
7
|
const language_server_1 = require("@volar/language-server");
|
|
7
8
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
9
|
const node_path_1 = require("node:path");
|
|
9
10
|
const index_js_1 = require("../core/index.js");
|
|
10
11
|
const utils_js_1 = require("./utils.js");
|
|
11
|
-
|
|
12
|
+
const create = () => (context, modules) => {
|
|
12
13
|
return {
|
|
13
14
|
triggerCharacters: ['-'],
|
|
14
15
|
provideCompletionItems(document, position, completionContext, token) {
|
|
@@ -75,6 +76,7 @@ exports.default = () => (context, modules) => {
|
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
};
|
|
79
|
+
exports.create = create;
|
|
78
80
|
function getGlobResultAsCodeLens(globText, dir, position) {
|
|
79
81
|
const globResult = fast_glob_1.default.sync(globText, {
|
|
80
82
|
cwd: dir,
|
package/dist/plugins/html.d.ts
CHANGED
package/dist/plugins/html.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create = void 0;
|
|
6
7
|
const language_server_1 = require("@volar/language-server");
|
|
7
8
|
const volar_service_html_1 = __importDefault(require("volar-service-html"));
|
|
8
9
|
const index_js_1 = require("../core/index.js");
|
|
9
10
|
const html_data_js_1 = require("./html-data.js");
|
|
10
11
|
const utils_js_1 = require("./utils.js");
|
|
11
|
-
|
|
12
|
+
const create = () => (context, modules) => {
|
|
12
13
|
const htmlPlugin = (0, volar_service_html_1.default)()(context, modules);
|
|
13
14
|
if (!context) {
|
|
14
15
|
return { triggerCharacters: htmlPlugin.triggerCharacters };
|
|
@@ -45,4 +46,5 @@ exports.default = () => (context, modules) => {
|
|
|
45
46
|
},
|
|
46
47
|
};
|
|
47
48
|
};
|
|
49
|
+
exports.create = create;
|
|
48
50
|
//# sourceMappingURL=html.js.map
|
|
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create = void 0;
|
|
6
7
|
const language_server_1 = require("@volar/language-server");
|
|
7
8
|
const volar_service_typescript_1 = __importDefault(require("volar-service-typescript"));
|
|
8
9
|
const index_js_1 = require("../../core/index.js");
|
|
9
10
|
const utils_js_1 = require("../utils.js");
|
|
10
11
|
const completions_js_1 = require("./completions.js");
|
|
11
12
|
const diagnostics_js_1 = require("./diagnostics.js");
|
|
12
|
-
|
|
13
|
+
const create = () => (context, modules) => {
|
|
13
14
|
const typeScriptPlugin = (0, volar_service_typescript_1.default)()(context, modules);
|
|
14
15
|
if (!context) {
|
|
15
16
|
return {
|
|
@@ -124,4 +125,5 @@ exports.default = () => (context, modules) => {
|
|
|
124
125
|
},
|
|
125
126
|
};
|
|
126
127
|
};
|
|
128
|
+
exports.create = create;
|
|
127
129
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Service } from '@volar/language-server';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const create: () => Service;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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
|
|
7
|
+
const create = () => (context) => {
|
|
8
8
|
return {
|
|
9
9
|
isAdditionalCompletion: true,
|
|
10
10
|
// Q: Why the empty transform and resolve functions?
|
|
@@ -37,5 +37,5 @@ const createTypescriptAddonsService = () => (context) => {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
exports.
|
|
40
|
+
exports.create = create;
|
|
41
41
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"@volar/typescript": "~1.10.0",
|
|
31
31
|
"fast-glob": "^3.2.12",
|
|
32
32
|
"muggle-string": "^0.3.1",
|
|
33
|
-
"volar-service-css": "0.0.
|
|
34
|
-
"volar-service-emmet": "0.0.
|
|
35
|
-
"volar-service-html": "0.0.
|
|
36
|
-
"volar-service-prettier": "0.0.
|
|
37
|
-
"volar-service-typescript": "0.0.
|
|
38
|
-
"volar-service-typescript-twoslash-queries": "0.0.
|
|
33
|
+
"volar-service-css": "0.0.13",
|
|
34
|
+
"volar-service-emmet": "0.0.13",
|
|
35
|
+
"volar-service-html": "0.0.13",
|
|
36
|
+
"volar-service-prettier": "0.0.13",
|
|
37
|
+
"volar-service-typescript": "0.0.13",
|
|
38
|
+
"volar-service-typescript-twoslash-queries": "0.0.13",
|
|
39
39
|
"vscode-html-languageservice": "^5.0.6",
|
|
40
40
|
"vscode-uri": "^3.0.7"
|
|
41
41
|
},
|