@astrojs/language-server 0.15.0 → 0.16.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/CHANGELOG.md +15 -0
- package/dist/check.js +1 -2
- package/dist/core/documents/DocumentMapper.js +2 -4
- package/dist/core/documents/parseAstro.js +1 -1
- package/dist/core/documents/utils.js +3 -4
- package/dist/plugins/PluginHost.d.ts +2 -1
- package/dist/plugins/PluginHost.js +8 -6
- package/dist/plugins/astro/AstroPlugin.js +1 -1
- package/dist/plugins/astro/features/CompletionsProvider.js +9 -10
- package/dist/plugins/css/CSSPlugin.js +20 -4
- package/dist/plugins/html/features/astro-attributes.js +43 -27
- package/dist/plugins/typescript/LanguageServiceManager.js +1 -1
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +3 -1
- package/dist/plugins/typescript/TypeScriptPlugin.js +9 -1
- package/dist/plugins/typescript/astro-sys.js +3 -5
- package/dist/plugins/typescript/astro2tsx.js +1 -2
- package/dist/plugins/typescript/features/CodeActionsProvider.d.ts +14 -0
- package/dist/plugins/typescript/features/CodeActionsProvider.js +141 -0
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +2 -1
- package/dist/plugins/typescript/features/CompletionsProvider.js +37 -32
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +2 -3
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +3 -4
- package/dist/plugins/typescript/features/SemanticTokenProvider.js +1 -1
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +2 -2
- package/dist/plugins/typescript/features/utils.d.ts +2 -0
- package/dist/plugins/typescript/features/utils.js +19 -3
- package/dist/plugins/typescript/language-service.js +5 -6
- package/dist/plugins/typescript/module-loader.js +1 -1
- package/dist/plugins/typescript/previewer.js +1 -1
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +1 -1
- package/dist/plugins/typescript/snapshots/utils.js +3 -6
- package/dist/plugins/typescript/utils.d.ts +1 -0
- package/dist/plugins/typescript/utils.js +13 -1
- package/dist/server.js +28 -7
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +16 -3
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -36,6 +36,7 @@ const PluginHost_1 = require("./plugins/PluginHost");
|
|
|
36
36
|
const plugins_1 = require("./plugins");
|
|
37
37
|
const utils_1 = require("./utils");
|
|
38
38
|
const utils_2 = require("./plugins/typescript/utils");
|
|
39
|
+
const CodeActionsProvider_1 = require("./plugins/typescript/features/CodeActionsProvider");
|
|
39
40
|
const TagCloseRequest = new vscode.RequestType('html/tag');
|
|
40
41
|
// Start the language server
|
|
41
42
|
function startLanguageServer(connection) {
|
|
@@ -44,8 +45,7 @@ function startLanguageServer(connection) {
|
|
|
44
45
|
const documentManager = new DocumentManager_1.DocumentManager();
|
|
45
46
|
const pluginHost = new PluginHost_1.PluginHost(documentManager);
|
|
46
47
|
connection.onInitialize((params) => {
|
|
47
|
-
|
|
48
|
-
const workspaceUris = (_b = (_a = params.workspaceFolders) === null || _a === void 0 ? void 0 : _a.map((folder) => folder.uri.toString())) !== null && _b !== void 0 ? _b : [(_c = params.rootUri) !== null && _c !== void 0 ? _c : ''];
|
|
48
|
+
const workspaceUris = params.workspaceFolders?.map((folder) => folder.uri.toString()) ?? [params.rootUri ?? ''];
|
|
49
49
|
workspaceUris.forEach((uri) => {
|
|
50
50
|
uri = (0, utils_1.urlToPath)(uri);
|
|
51
51
|
const astroVersion = (0, utils_1.getUserAstroVersion)(uri);
|
|
@@ -63,8 +63,8 @@ function startLanguageServer(connection) {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
pluginHost.initialize({
|
|
66
|
-
filterIncompleteCompletions: !
|
|
67
|
-
definitionLinkSupport: !!
|
|
66
|
+
filterIncompleteCompletions: !params.initializationOptions?.dontFilterIncompleteCompletions,
|
|
67
|
+
definitionLinkSupport: !!params.capabilities.textDocument?.definition?.linkSupport,
|
|
68
68
|
});
|
|
69
69
|
// Register plugins
|
|
70
70
|
pluginHost.registerPlugin(new HTMLPlugin_1.HTMLPlugin(configManager));
|
|
@@ -75,14 +75,34 @@ function startLanguageServer(connection) {
|
|
|
75
75
|
pluginHost.registerPlugin(new plugins_1.TypeScriptPlugin(documentManager, configManager, workspaceUris));
|
|
76
76
|
}
|
|
77
77
|
// Update language-server config with what the user supplied to us at launch
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
let astroConfiguration = params.initializationOptions?.configuration?.astro;
|
|
79
|
+
if (astroConfiguration) {
|
|
80
|
+
configManager.updateConfig(astroConfiguration);
|
|
81
|
+
}
|
|
82
|
+
let emmetConfiguration = params.initializationOptions?.configuration?.emmet;
|
|
83
|
+
if (emmetConfiguration) {
|
|
84
|
+
configManager.updateEmmetConfig(emmetConfiguration);
|
|
85
|
+
}
|
|
80
86
|
return {
|
|
81
87
|
capabilities: {
|
|
82
|
-
textDocumentSync:
|
|
88
|
+
textDocumentSync: {
|
|
89
|
+
openClose: true,
|
|
90
|
+
change: vscode.TextDocumentSyncKind.Incremental,
|
|
91
|
+
save: {
|
|
92
|
+
includeText: true,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
83
95
|
foldingRangeProvider: true,
|
|
84
96
|
definitionProvider: true,
|
|
85
97
|
renameProvider: true,
|
|
98
|
+
codeActionProvider: {
|
|
99
|
+
codeActionKinds: [
|
|
100
|
+
vscode_languageserver_1.CodeActionKind.QuickFix,
|
|
101
|
+
vscode_languageserver_1.CodeActionKind.SourceOrganizeImports,
|
|
102
|
+
// VS Code specific
|
|
103
|
+
CodeActionsProvider_1.sortImportKind,
|
|
104
|
+
],
|
|
105
|
+
},
|
|
86
106
|
completionProvider: {
|
|
87
107
|
resolveProvider: true,
|
|
88
108
|
triggerCharacters: [
|
|
@@ -157,6 +177,7 @@ function startLanguageServer(connection) {
|
|
|
157
177
|
connection.onHover((params) => pluginHost.doHover(params.textDocument, params.position));
|
|
158
178
|
connection.onDefinition((evt) => pluginHost.getDefinitions(evt.textDocument, evt.position));
|
|
159
179
|
connection.onFoldingRanges((evt) => pluginHost.getFoldingRanges(evt.textDocument));
|
|
180
|
+
connection.onCodeAction((evt, cancellationToken) => pluginHost.getCodeActions(evt.textDocument, evt.range, evt.context, cancellationToken));
|
|
160
181
|
connection.onCompletion(async (evt) => {
|
|
161
182
|
const promise = pluginHost.getCompletions(evt.textDocument, evt.position, evt.context);
|
|
162
183
|
return promise;
|
package/dist/utils.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export declare function getLastPartOfPath(path: string): string;
|
|
|
20
20
|
* Transform a string into PascalCase
|
|
21
21
|
*/
|
|
22
22
|
export declare function toPascalCase(string: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Function to modify each line of a text, preserving the line break style (`\n` or `\r\n`)
|
|
25
|
+
*/
|
|
26
|
+
export declare function modifyLines(text: string, replacementFn: (line: string, lineIdx: number) => string): string;
|
|
23
27
|
/**
|
|
24
28
|
* Return true if a specific node could be a component.
|
|
25
29
|
* This is not a 100% sure test as it'll return false for any component that does not match the standard format for a component
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserAstroVersion = exports.debounceThrottle = exports.debounceSameArg = exports.getRegExpMatches = exports.isBeforeOrEqualToPosition = exports.isInRange = exports.isNotNullOrUndefined = exports.clamp = exports.flatten = exports.isPossibleComponent = exports.toPascalCase = exports.getLastPartOfPath = exports.pathToUrl = exports.urlToPath = exports.normalizePath = exports.normalizeUri = void 0;
|
|
3
|
+
exports.getUserAstroVersion = exports.debounceThrottle = exports.debounceSameArg = exports.getRegExpMatches = exports.isBeforeOrEqualToPosition = exports.isInRange = exports.isNotNullOrUndefined = exports.clamp = exports.flatten = exports.isPossibleComponent = exports.modifyLines = exports.toPascalCase = exports.getLastPartOfPath = exports.pathToUrl = exports.urlToPath = exports.normalizePath = exports.normalizeUri = void 0;
|
|
4
4
|
const vscode_uri_1 = require("vscode-uri");
|
|
5
5
|
/** Normalizes a document URI */
|
|
6
6
|
function normalizeUri(uri) {
|
|
@@ -48,13 +48,26 @@ function toPascalCase(string) {
|
|
|
48
48
|
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
|
|
49
49
|
}
|
|
50
50
|
exports.toPascalCase = toPascalCase;
|
|
51
|
+
/**
|
|
52
|
+
* Function to modify each line of a text, preserving the line break style (`\n` or `\r\n`)
|
|
53
|
+
*/
|
|
54
|
+
function modifyLines(text, replacementFn) {
|
|
55
|
+
let idx = 0;
|
|
56
|
+
return text
|
|
57
|
+
.split('\r\n')
|
|
58
|
+
.map((l1) => l1
|
|
59
|
+
.split('\n')
|
|
60
|
+
.map((line) => replacementFn(line, idx++))
|
|
61
|
+
.join('\n'))
|
|
62
|
+
.join('\r\n');
|
|
63
|
+
}
|
|
64
|
+
exports.modifyLines = modifyLines;
|
|
51
65
|
/**
|
|
52
66
|
* Return true if a specific node could be a component.
|
|
53
67
|
* This is not a 100% sure test as it'll return false for any component that does not match the standard format for a component
|
|
54
68
|
*/
|
|
55
69
|
function isPossibleComponent(node) {
|
|
56
|
-
|
|
57
|
-
return !!((_a = node.tag) === null || _a === void 0 ? void 0 : _a[0].match(/[A-Z]/)) || !!((_b = node.tag) === null || _b === void 0 ? void 0 : _b.match(/.+[.][A-Z]/));
|
|
70
|
+
return !!node.tag?.[0].match(/[A-Z]/) || !!node.tag?.match(/.+[.][A-Z]/);
|
|
58
71
|
}
|
|
59
72
|
exports.isPossibleComponent = isPossibleComponent;
|
|
60
73
|
/** Flattens an array */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"test": "cross-env TS_NODE_TRANSPILE_ONLY=true mocha --timeout 20000 --require ts-node/register \"test/**/*.ts\" --exclude \"test/**/*.d.ts\""
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@astrojs/svelte-language-integration": "^0.1.
|
|
22
|
+
"@astrojs/svelte-language-integration": "^0.1.4",
|
|
23
23
|
"@vscode/emmet-helper": "^2.8.4",
|
|
24
24
|
"lodash": "^4.17.21",
|
|
25
25
|
"source-map": "^0.7.3",
|