@astrojs/language-server 0.9.0 → 0.9.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/CHANGELOG.md +18 -0
- package/dist/core/config/ConfigManager.d.ts +1 -1
- package/dist/core/documents/utils.d.ts +2 -0
- package/dist/core/documents/utils.js +14 -1
- package/dist/plugins/css/CSSPlugin.js +2 -7
- package/dist/plugins/html/HTMLPlugin.d.ts +0 -1
- package/dist/plugins/html/HTMLPlugin.js +9 -16
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @astrojs/language-server
|
|
2
2
|
|
|
3
|
+
## 0.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c4d43b4: Deploy to OpenVSX
|
|
8
|
+
|
|
9
|
+
## 0.9.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 91404d1: Enable publishing to OpenVSX
|
|
14
|
+
|
|
15
|
+
## 0.9.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 7dc85cc: Add support for Emmet inside components, upgrade Emmet version
|
|
20
|
+
|
|
3
21
|
## 0.9.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -41,6 +41,8 @@ export declare function isInsideExpression(html: string, tagStart: number, posit
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function isInsideFrontmatter(text: string, offset: number): boolean;
|
|
43
43
|
export declare function isInTag(position: Position, tagInfo: TagInformation | null): tagInfo is TagInformation;
|
|
44
|
+
export declare function isComponentTag(node: Node): boolean;
|
|
45
|
+
export declare function isInComponentStartTag(html: HTMLDocument, offset: number): boolean;
|
|
44
46
|
/**
|
|
45
47
|
* Get the line and character based on the offset
|
|
46
48
|
* @param offset The index of the position
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractStyleTag = exports.walk = exports.offsetAt = exports.positionAt = exports.isInTag = exports.isInsideFrontmatter = exports.isInsideExpression = exports.getFirstNonWhitespaceIndex = exports.getWordAt = exports.getWordRangeAt = void 0;
|
|
3
|
+
exports.extractStyleTag = exports.walk = exports.offsetAt = exports.positionAt = exports.isInComponentStartTag = exports.isComponentTag = exports.isInTag = exports.isInsideFrontmatter = exports.isInsideExpression = exports.getFirstNonWhitespaceIndex = exports.getWordAt = exports.getWordRangeAt = void 0;
|
|
4
4
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
5
5
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
@@ -76,6 +76,19 @@ function isInTag(position, tagInfo) {
|
|
|
76
76
|
return !!tagInfo && (0, utils_1.isInRange)(position, vscode_languageserver_1.Range.create(tagInfo.startPos, tagInfo.endPos));
|
|
77
77
|
}
|
|
78
78
|
exports.isInTag = isInTag;
|
|
79
|
+
function isComponentTag(node) {
|
|
80
|
+
if (!node.tag) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const firstChar = node.tag[0];
|
|
84
|
+
return /[A-Z]/.test(firstChar);
|
|
85
|
+
}
|
|
86
|
+
exports.isComponentTag = isComponentTag;
|
|
87
|
+
function isInComponentStartTag(html, offset) {
|
|
88
|
+
const node = html.findNodeAt(offset);
|
|
89
|
+
return (isComponentTag(node) && (!node.startTagEnd || offset < node.startTagEnd));
|
|
90
|
+
}
|
|
91
|
+
exports.isInComponentStartTag = isInComponentStartTag;
|
|
79
92
|
/**
|
|
80
93
|
* Get the line and character based on the offset
|
|
81
94
|
* @param offset The index of the position
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CSSPlugin = void 0;
|
|
4
|
-
const
|
|
4
|
+
const emmet_helper_1 = require("@vscode/emmet-helper");
|
|
5
5
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
6
|
const utils_1 = require("../../core/documents/utils");
|
|
7
7
|
const CSSDocument_1 = require("./CSSDocument");
|
|
@@ -51,7 +51,7 @@ class CSSPlugin {
|
|
|
51
51
|
if (isSASS(cssDocument)) {
|
|
52
52
|
// the css language service does not support sass, still we can use
|
|
53
53
|
// the emmet helper directly to at least get emmet completions
|
|
54
|
-
return (0,
|
|
54
|
+
return (0, emmet_helper_1.doComplete)(document, position, 'sass', this.configManager.getEmmetConfig()) || null;
|
|
55
55
|
}
|
|
56
56
|
const type = extractLanguage(cssDocument);
|
|
57
57
|
const lang = (0, service_1.getLanguageService)(type);
|
|
@@ -59,11 +59,6 @@ class CSSPlugin {
|
|
|
59
59
|
isIncomplete: true,
|
|
60
60
|
items: [],
|
|
61
61
|
};
|
|
62
|
-
if (false /* this.configManager.getConfig().css.completions.emmet */) {
|
|
63
|
-
lang.setCompletionParticipants([
|
|
64
|
-
(0, vscode_emmet_helper_1.getEmmetCompletionParticipants)(cssDocument, cssDocument.getGeneratedPosition(position), (0, service_1.getLanguage)(type), this.configManager.getEmmetConfig(), emmetResults),
|
|
65
|
-
]);
|
|
66
|
-
}
|
|
67
62
|
const results = lang.doComplete(cssDocument, cssDocument.getGeneratedPosition(position), cssDocument.stylesheet);
|
|
68
63
|
return vscode_languageserver_1.CompletionList.create([...(results ? results.items : []), ...emmetResults.items].map((completionItem) => (0, documents_1.mapCompletionItemToOriginal)(cssDocument, completionItem)),
|
|
69
64
|
// Emmet completions change on every keystroke, so they are never complete
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HTMLPlugin = void 0;
|
|
4
|
-
const
|
|
4
|
+
const emmet_helper_1 = require("@vscode/emmet-helper");
|
|
5
5
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
6
6
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
7
7
|
const utils_1 = require("../../core/documents/utils");
|
|
@@ -24,17 +24,17 @@ class HTMLPlugin {
|
|
|
24
24
|
if (this.isInsideFrontmatter(document, position) || this.isInsideExpression(html, document, position)) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const node = html.findNodeAt(offset);
|
|
29
|
-
if (this.isComponentTag(node)) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const emmetResults = {
|
|
27
|
+
let emmetResults = {
|
|
33
28
|
isIncomplete: true,
|
|
34
29
|
items: [],
|
|
35
30
|
};
|
|
36
|
-
this.lang.setCompletionParticipants([
|
|
37
|
-
|
|
31
|
+
this.lang.setCompletionParticipants([
|
|
32
|
+
{
|
|
33
|
+
onHtmlContent: () => (emmetResults = (0, emmet_helper_1.doComplete)(document, position, 'html', this.configManager.getEmmetConfig()) || emmetResults),
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
// For components, we only want Emmet completions inside the component (aka slots) because HTML properties are not necessarily valid for a component
|
|
37
|
+
const results = (0, utils_1.isInComponentStartTag)(html, document.offsetAt(position)) ? vscode_languageserver_1.CompletionList.create([]) : this.lang.doComplete(document, position, html);
|
|
38
38
|
const items = this.toCompletionItems(results.items);
|
|
39
39
|
return vscode_languageserver_1.CompletionList.create([...this.toCompletionItems(items), ...this.getLangCompletions(items), ...emmetResults.items],
|
|
40
40
|
// Emmet completions change on every keystroke, so they are never complete
|
|
@@ -104,12 +104,5 @@ class HTMLPlugin {
|
|
|
104
104
|
isInsideFrontmatter(document, position) {
|
|
105
105
|
return (0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(position));
|
|
106
106
|
}
|
|
107
|
-
isComponentTag(node) {
|
|
108
|
-
if (!node.tag) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
const firstChar = node.tag[0];
|
|
112
|
-
return /[A-Z]/.test(firstChar);
|
|
113
|
-
}
|
|
114
107
|
}
|
|
115
108
|
exports.HTMLPlugin = HTMLPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/language-server",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"author": "withastro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"ts-morph": "^12.0.0",
|
|
26
26
|
"typescript": "^4.5.4",
|
|
27
27
|
"vscode-css-languageservice": "^5.1.1",
|
|
28
|
-
"vscode
|
|
28
|
+
"@vscode/emmet-helper": "^2.8.4",
|
|
29
29
|
"vscode-html-languageservice": "^3.0.3",
|
|
30
30
|
"vscode-languageserver": "6.1.1",
|
|
31
31
|
"vscode-languageserver-protocol": "^3.16.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/lodash": "^4.14.116",
|
|
38
|
-
"astro": "0.23.5",
|
|
38
|
+
"astro": "^0.23.5",
|
|
39
39
|
"astro-scripts": "0.0.1",
|
|
40
40
|
"tap": "^15.0.9"
|
|
41
41
|
}
|