volar-service-html 0.0.2 → 0.0.4
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/out/index.d.ts +8 -11
- package/out/index.js +20 -16
- package/package.json +5 -12
package/out/index.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Service } from '@volar/language-service';
|
|
2
2
|
import * as html from 'vscode-html-languageservice';
|
|
3
|
-
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
-
export
|
|
5
|
-
htmlDocument:
|
|
6
|
-
languageService:
|
|
7
|
-
|
|
8
|
-
export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
|
|
9
|
-
export interface PluginInstance extends ReturnType<Service> {
|
|
10
|
-
getHtmlLs: () => html.LanguageService;
|
|
11
|
-
updateCustomData(extraData: html.IHTMLDataProvider[]): void;
|
|
3
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
|
+
export interface Provide {
|
|
5
|
+
'html/htmlDocument': (document: TextDocument) => html.HTMLDocument | undefined;
|
|
6
|
+
'html/languageService': () => html.LanguageService;
|
|
7
|
+
'html/updateCustomData': (extraData: html.IHTMLDataProvider[]) => void;
|
|
12
8
|
}
|
|
9
|
+
export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
|
|
13
10
|
declare const _default: (options?: {
|
|
14
11
|
validLang?: string;
|
|
15
12
|
disableCustomData?: boolean;
|
|
16
|
-
}) =>
|
|
13
|
+
}) => Service<Provide>;
|
|
17
14
|
export default _default;
|
package/out/index.js
CHANGED
|
@@ -23,17 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getHtmlDocument =
|
|
27
|
-
const language_service_1 = require("@volar/language-service");
|
|
26
|
+
exports.getHtmlDocument = void 0;
|
|
28
27
|
const html = __importStar(require("vscode-html-languageservice"));
|
|
29
|
-
const vscode = __importStar(require("vscode-languageserver-protocol"));
|
|
30
28
|
const path = __importStar(require("path"));
|
|
31
29
|
const parserLs = html.getLanguageService();
|
|
32
30
|
const htmlDocuments = new WeakMap();
|
|
33
|
-
exports.injectionKeys = {
|
|
34
|
-
htmlDocument: 'html/htmlDocument',
|
|
35
|
-
languageService: 'html/languageService',
|
|
36
|
-
};
|
|
37
31
|
function getHtmlDocument(document) {
|
|
38
32
|
const cache = htmlDocuments.get(document);
|
|
39
33
|
if (cache) {
|
|
@@ -62,16 +56,15 @@ exports.default = (options = {}) => (context) => {
|
|
|
62
56
|
});
|
|
63
57
|
return {
|
|
64
58
|
provide: {
|
|
65
|
-
|
|
59
|
+
'html/htmlDocument': (document) => {
|
|
66
60
|
if (document.languageId === (options.validLang ?? 'html')) {
|
|
67
61
|
return getHtmlDocument(document);
|
|
68
62
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
63
|
+
},
|
|
64
|
+
'html/languageService': () => htmlLs,
|
|
65
|
+
'html/updateCustomData': updateExtraCustomData,
|
|
71
66
|
},
|
|
72
67
|
triggerCharacters,
|
|
73
|
-
getHtmlLs: () => htmlLs,
|
|
74
|
-
updateCustomData: updateExtraCustomData,
|
|
75
68
|
async provideCompletionItems(document, position) {
|
|
76
69
|
return worker(document, async (htmlDocument) => {
|
|
77
70
|
const configs = await context.env.getConfiguration?.('html.completion');
|
|
@@ -147,11 +140,14 @@ exports.default = (options = {}) => (context) => {
|
|
|
147
140
|
const content = document.getText();
|
|
148
141
|
if (endPos.character === 0 && endPos.line > 0 && endOffset !== content.length) {
|
|
149
142
|
// if selection ends after a new line, exclude that new line
|
|
150
|
-
const prevLineStart = document.offsetAt(
|
|
143
|
+
const prevLineStart = document.offsetAt({ line: endPos.line - 1, character: 0 });
|
|
151
144
|
while (isEOL(content, endOffset - 1) && endOffset > prevLineStart) {
|
|
152
145
|
endOffset--;
|
|
153
146
|
}
|
|
154
|
-
formatRange =
|
|
147
|
+
formatRange = {
|
|
148
|
+
start: formatRange.start,
|
|
149
|
+
end: document.positionAt(endOffset),
|
|
150
|
+
};
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
return htmlLs.format(document, formatRange, {
|
|
@@ -286,8 +282,16 @@ function isNewlineCharacter(charCode) {
|
|
|
286
282
|
}
|
|
287
283
|
function provideFileSymbolsInternal(document, node, symbols) {
|
|
288
284
|
const name = nodeToName(node);
|
|
289
|
-
const range =
|
|
290
|
-
|
|
285
|
+
const range = {
|
|
286
|
+
start: document.positionAt(node.start),
|
|
287
|
+
end: document.positionAt(node.end),
|
|
288
|
+
};
|
|
289
|
+
const symbol = {
|
|
290
|
+
name,
|
|
291
|
+
kind: 8,
|
|
292
|
+
range,
|
|
293
|
+
selectionRange: range,
|
|
294
|
+
};
|
|
291
295
|
symbols.push(symbol);
|
|
292
296
|
node.children.forEach(child => {
|
|
293
297
|
symbol.children ??= [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,17 +13,10 @@
|
|
|
13
13
|
"directory": "packages/html"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"vscode-html-languageservice": "^5.0.4"
|
|
17
|
-
"vscode-languageserver-protocol": "^3.17.3",
|
|
18
|
-
"vscode-languageserver-textdocument": "^1.0.8"
|
|
19
|
-
},
|
|
20
|
-
"peerDependencies": {
|
|
21
|
-
"@volar/language-service": "*"
|
|
16
|
+
"vscode-html-languageservice": "^5.0.4"
|
|
22
17
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"optional": true
|
|
26
|
-
}
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"vscode-languageserver-textdocument": "^1.0.8"
|
|
27
20
|
},
|
|
28
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "f5d49495d6698761f4df8c9ef2747cc01fc777d6"
|
|
29
22
|
}
|