@astrojs/language-server 0.23.2 → 0.24.1
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/CHANGELOG.md +23 -0
- package/dist/browser.js +8 -1
- package/dist/check.d.ts +2 -1
- package/dist/check.js +8 -2
- package/dist/core/DiagnosticsManager.d.ts +2 -2
- package/dist/core/config/ConfigManager.d.ts +5 -6
- package/dist/core/config/ConfigManager.js +2 -9
- package/dist/core/documents/AstroDocument.d.ts +1 -1
- package/dist/core/documents/AstroDocument.js +1 -1
- package/dist/core/documents/DocumentBase.d.ts +2 -2
- package/dist/core/documents/DocumentManager.d.ts +1 -1
- package/dist/core/documents/DocumentManager.js +1 -1
- package/dist/core/documents/DocumentMapper.d.ts +2 -2
- package/dist/core/documents/parseHtml.d.ts +3 -2
- package/dist/core/documents/parseHtml.js +12 -5
- package/dist/core/documents/utils.d.ts +3 -3
- package/dist/core/documents/utils.js +1 -2
- package/dist/node.js +15 -1
- package/dist/plugins/PluginHost.d.ts +2 -2
- package/dist/plugins/PluginHost.js +1 -1
- package/dist/plugins/astro/AstroPlugin.d.ts +6 -5
- package/dist/plugins/astro/AstroPlugin.js +1 -0
- package/dist/plugins/astro/features/CompletionsProvider.d.ts +4 -3
- package/dist/plugins/astro/features/CompletionsProvider.js +12 -15
- package/dist/plugins/css/CSSDocument.d.ts +2 -2
- package/dist/plugins/css/CSSDocument.js +1 -1
- package/dist/plugins/css/CSSPlugin.d.ts +1 -1
- package/dist/plugins/css/CSSPlugin.js +3 -3
- package/dist/plugins/css/StyleAttributeDocument.d.ts +2 -2
- package/dist/plugins/css/StyleAttributeDocument.js +1 -1
- package/dist/plugins/css/features/astro-selectors.d.ts +1 -1
- package/dist/plugins/css/features/getIdClassCompletions.d.ts +2 -2
- package/dist/plugins/html/HTMLPlugin.d.ts +3 -3
- package/dist/plugins/html/HTMLPlugin.js +1 -1
- package/dist/plugins/html/utils.d.ts +1 -1
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/index.js +4 -4
- package/dist/plugins/interfaces.d.ts +2 -2
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +8 -9
- package/dist/plugins/typescript/LanguageServiceManager.js +5 -3
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +7 -6
- package/dist/plugins/typescript/TypeScriptPlugin.js +15 -15
- package/dist/plugins/typescript/astro-sys.d.ts +2 -3
- package/dist/plugins/typescript/astro-sys.js +7 -11
- package/dist/plugins/typescript/astro2tsx.js +3 -4
- package/dist/plugins/typescript/features/CodeActionsProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/CodeActionsProvider.js +6 -9
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +9 -7
- package/dist/plugins/typescript/features/CompletionsProvider.js +56 -80
- package/dist/plugins/typescript/features/DefinitionsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +6 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +29 -19
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +3 -2
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +3 -4
- package/dist/plugins/typescript/features/FoldingRangesProvider.d.ts +7 -4
- package/dist/plugins/typescript/features/FoldingRangesProvider.js +12 -15
- package/dist/plugins/typescript/features/HoverProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/HoverProvider.js +3 -6
- package/dist/plugins/typescript/features/InlayHintsProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/InlayHintsProvider.js +5 -8
- package/dist/plugins/typescript/features/SemanticTokenProvider.d.ts +3 -2
- package/dist/plugins/typescript/features/SemanticTokenProvider.js +4 -7
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +7 -10
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.d.ts +3 -3
- package/dist/plugins/typescript/features/utils.d.ts +3 -3
- package/dist/plugins/typescript/language-service.d.ts +7 -6
- package/dist/plugins/typescript/language-service.js +29 -30
- package/dist/plugins/typescript/module-loader.d.ts +2 -2
- package/dist/plugins/typescript/module-loader.js +12 -16
- package/dist/plugins/typescript/previewer.d.ts +3 -7
- package/dist/plugins/typescript/previewer.js +13 -17
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +4 -5
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +2 -7
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +5 -2
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +15 -17
- package/dist/plugins/typescript/snapshots/utils.d.ts +7 -7
- package/dist/plugins/typescript/snapshots/utils.js +28 -29
- package/dist/plugins/typescript/utils.d.ts +8 -10
- package/dist/plugins/typescript/utils.js +90 -107
- package/dist/server.d.ts +5 -1
- package/dist/server.js +27 -17
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -4
package/dist/server.js
CHANGED
|
@@ -27,20 +27,20 @@ exports.startLanguageServer = void 0;
|
|
|
27
27
|
const vscode = __importStar(require("vscode-languageserver"));
|
|
28
28
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
29
29
|
const ConfigManager_1 = require("./core/config/ConfigManager");
|
|
30
|
-
const DocumentManager_1 = require("./core/documents/DocumentManager");
|
|
31
30
|
const DiagnosticsManager_1 = require("./core/DiagnosticsManager");
|
|
31
|
+
const DocumentManager_1 = require("./core/documents/DocumentManager");
|
|
32
|
+
const plugins_1 = require("./plugins");
|
|
32
33
|
const AstroPlugin_1 = require("./plugins/astro/AstroPlugin");
|
|
33
34
|
const CSSPlugin_1 = require("./plugins/css/CSSPlugin");
|
|
34
35
|
const HTMLPlugin_1 = require("./plugins/html/HTMLPlugin");
|
|
35
36
|
const PluginHost_1 = require("./plugins/PluginHost");
|
|
36
|
-
const plugins_1 = require("./plugins");
|
|
37
|
-
const utils_1 = require("./utils");
|
|
38
|
-
const utils_2 = require("./plugins/typescript/utils");
|
|
39
37
|
const CodeActionsProvider_1 = require("./plugins/typescript/features/CodeActionsProvider");
|
|
40
38
|
const LanguageServiceManager_1 = require("./plugins/typescript/LanguageServiceManager");
|
|
39
|
+
const utils_1 = require("./plugins/typescript/utils");
|
|
40
|
+
const utils_2 = require("./utils");
|
|
41
41
|
const TagCloseRequest = new vscode.RequestType('html/tag');
|
|
42
42
|
// Start the language server
|
|
43
|
-
function startLanguageServer(connection) {
|
|
43
|
+
function startLanguageServer(connection, env) {
|
|
44
44
|
// Create our managers
|
|
45
45
|
const documentManager = new DocumentManager_1.DocumentManager();
|
|
46
46
|
const pluginHost = new PluginHost_1.PluginHost(documentManager);
|
|
@@ -51,13 +51,13 @@ function startLanguageServer(connection) {
|
|
|
51
51
|
const environment = params.initializationOptions?.environment ?? 'node';
|
|
52
52
|
const workspaceUris = params.workspaceFolders?.map((folder) => folder.uri.toString()) ?? [params.rootUri ?? ''];
|
|
53
53
|
workspaceUris.forEach((uri) => {
|
|
54
|
-
uri = (0,
|
|
54
|
+
uri = (0, utils_2.urlToPath)(uri);
|
|
55
55
|
// If the workspace is not an Astro project, we shouldn't warn about not finding Astro
|
|
56
56
|
// Unless the extension enabled itself in an untitled workspace, in which case the warning is valid
|
|
57
|
-
if (!(0,
|
|
57
|
+
if (!(0, utils_2.isAstroWorkspace)(uri) && uri !== '/' && uri !== '') {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
const astroInstall = (0,
|
|
60
|
+
const astroInstall = (0, utils_2.getAstroInstall)([uri]);
|
|
61
61
|
if (!astroInstall) {
|
|
62
62
|
connection.sendNotification(vscode_languageserver_1.ShowMessageNotification.type, {
|
|
63
63
|
message: `Couldn't find Astro in workspace "${uri}". Experience might be degraded. For the best experience, please make sure Astro is installed and then restart the language server`,
|
|
@@ -76,10 +76,20 @@ function startLanguageServer(connection) {
|
|
|
76
76
|
pluginHost.registerPlugin(new CSSPlugin_1.CSSPlugin(configManager));
|
|
77
77
|
// We don't currently support running the TypeScript and Astro plugin in the browser
|
|
78
78
|
if (environment === 'node') {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const ts = env.loadTypescript(params.initializationOptions);
|
|
80
|
+
if (ts) {
|
|
81
|
+
const tsLocalized = env.loadTypescriptLocalized(params.initializationOptions);
|
|
82
|
+
const languageServiceManager = new LanguageServiceManager_1.LanguageServiceManager(documentManager, workspaceUris.map(utils_2.normalizeUri), configManager, ts, tsLocalized);
|
|
83
|
+
typescriptPlugin = new plugins_1.TypeScriptPlugin(configManager, languageServiceManager);
|
|
84
|
+
pluginHost.registerPlugin(new AstroPlugin_1.AstroPlugin(configManager, languageServiceManager));
|
|
85
|
+
pluginHost.registerPlugin(typescriptPlugin);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
connection.sendNotification(vscode_languageserver_1.ShowMessageNotification.type, {
|
|
89
|
+
message: `Astro: Couldn't load TypeScript from path ${params?.initializationOptions?.typescript?.serverPath}. Only HTML and CSS features will be enabled`,
|
|
90
|
+
type: vscode_languageserver_1.MessageType.Warning,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
return {
|
|
85
95
|
capabilities: {
|
|
@@ -137,7 +147,7 @@ function startLanguageServer(connection) {
|
|
|
137
147
|
documentSymbolProvider: true,
|
|
138
148
|
linkedEditingRangeProvider: true,
|
|
139
149
|
semanticTokensProvider: {
|
|
140
|
-
legend: (0,
|
|
150
|
+
legend: (0, utils_1.getSemanticTokenLegend)(),
|
|
141
151
|
range: true,
|
|
142
152
|
full: true,
|
|
143
153
|
},
|
|
@@ -173,11 +183,11 @@ function startLanguageServer(connection) {
|
|
|
173
183
|
documentManager.updateDocument(params.textDocument, params.contentChanges);
|
|
174
184
|
});
|
|
175
185
|
const diagnosticsManager = new DiagnosticsManager_1.DiagnosticsManager(connection.sendDiagnostics, documentManager, pluginHost.getDiagnostics.bind(pluginHost));
|
|
176
|
-
const updateAllDiagnostics = (0,
|
|
186
|
+
const updateAllDiagnostics = (0, utils_2.debounceThrottle)(() => diagnosticsManager.updateAll(), 1000);
|
|
177
187
|
connection.onDidChangeWatchedFiles((evt) => {
|
|
178
188
|
const params = evt.changes
|
|
179
189
|
.map((change) => ({
|
|
180
|
-
fileName: (0,
|
|
190
|
+
fileName: (0, utils_2.urlToPath)(change.uri),
|
|
181
191
|
changeType: change.type,
|
|
182
192
|
}))
|
|
183
193
|
.filter((change) => !!change.fileName);
|
|
@@ -214,7 +224,7 @@ function startLanguageServer(connection) {
|
|
|
214
224
|
connection.onRenameRequest((evt) => pluginHost.rename(evt.textDocument, evt.position, evt.newName));
|
|
215
225
|
connection.onDidSaveTextDocument(updateAllDiagnostics);
|
|
216
226
|
connection.onNotification('$/onDidChangeNonAstroFile', async (e) => {
|
|
217
|
-
const path = (0,
|
|
227
|
+
const path = (0, utils_2.urlToPath)(e.uri);
|
|
218
228
|
if (path) {
|
|
219
229
|
pluginHost.updateNonAstroFile(path, e.changes);
|
|
220
230
|
}
|
|
@@ -230,7 +240,7 @@ function startLanguageServer(connection) {
|
|
|
230
240
|
return tsxOutput.code;
|
|
231
241
|
}
|
|
232
242
|
});
|
|
233
|
-
documentManager.on('documentChange', (0,
|
|
243
|
+
documentManager.on('documentChange', (0, utils_2.debounceThrottle)(async (document) => diagnosticsManager.update(document), 1000));
|
|
234
244
|
documentManager.on('documentClose', (document) => {
|
|
235
245
|
diagnosticsManager.removeDiagnostics(document);
|
|
236
246
|
configManager.removeDocument(document.uri);
|
package/dist/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@vscode/emmet-helper": "^2.8.4",
|
|
23
|
+
"events": "^3.3.0",
|
|
23
24
|
"prettier": "^2.7.1",
|
|
24
25
|
"prettier-plugin-astro": "^0.5.3",
|
|
25
26
|
"source-map": "^0.7.3",
|
|
26
|
-
"typescript": "~4.6.4",
|
|
27
27
|
"vscode-css-languageservice": "^6.0.1",
|
|
28
28
|
"vscode-html-languageservice": "^5.0.0",
|
|
29
29
|
"vscode-languageserver": "^8.0.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/mocha": "^9.1.0",
|
|
40
40
|
"@types/prettier": "^2.7.0",
|
|
41
41
|
"@types/sinon": "^10.0.11",
|
|
42
|
-
"astro": "^1.
|
|
42
|
+
"astro": "^1.1.3",
|
|
43
43
|
"astro-scripts": "0.0.1",
|
|
44
44
|
"chai": "^4.3.6",
|
|
45
45
|
"cross-env": "^7.0.3",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"sinon": "^13.0.1",
|
|
48
48
|
"svelte": "^3.49.0",
|
|
49
49
|
"ts-node": "^10.7.0",
|
|
50
|
-
"vue": "^3.2.37"
|
|
50
|
+
"vue": "^3.2.37",
|
|
51
|
+
"typescript": "~4.8.2"
|
|
51
52
|
}
|
|
52
53
|
}
|