volar-service-html 0.0.4 → 0.0.6
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 +1 -0
- package/out/index.js +31 -10
- package/package.json +4 -3
package/out/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
|
4
4
|
export interface Provide {
|
|
5
5
|
'html/htmlDocument': (document: TextDocument) => html.HTMLDocument | undefined;
|
|
6
6
|
'html/languageService': () => html.LanguageService;
|
|
7
|
+
'html/documentContext': () => html.DocumentContext;
|
|
7
8
|
'html/updateCustomData': (extraData: html.IHTMLDataProvider[]) => void;
|
|
8
9
|
}
|
|
9
10
|
export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
|
package/out/index.js
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.getHtmlDocument = void 0;
|
|
27
27
|
const html = __importStar(require("vscode-html-languageservice"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
29
30
|
const parserLs = html.getLanguageService();
|
|
30
31
|
const htmlDocuments = new WeakMap();
|
|
31
32
|
function getHtmlDocument(document) {
|
|
@@ -50,7 +51,33 @@ exports.default = (options = {}) => (context) => {
|
|
|
50
51
|
let shouldUpdateCustomData = true;
|
|
51
52
|
let customData = [];
|
|
52
53
|
let extraData = [];
|
|
53
|
-
const
|
|
54
|
+
const fileSystemProvider = {
|
|
55
|
+
stat: async (uri) => await context.env.fs?.stat(uri) ?? {
|
|
56
|
+
type: html.FileType.Unknown,
|
|
57
|
+
ctime: 0,
|
|
58
|
+
mtime: 0,
|
|
59
|
+
size: 0,
|
|
60
|
+
},
|
|
61
|
+
readDirectory: async (uri) => context.env.fs?.readDirectory(uri) ?? [],
|
|
62
|
+
};
|
|
63
|
+
const documentContext = {
|
|
64
|
+
resolveReference(ref, base) {
|
|
65
|
+
if (ref.match(/^\w[\w\d+.-]*:/)) {
|
|
66
|
+
// starts with a schema
|
|
67
|
+
return ref;
|
|
68
|
+
}
|
|
69
|
+
if (ref[0] === '/') { // resolve absolute path against the current workspace folder
|
|
70
|
+
return base + ref;
|
|
71
|
+
}
|
|
72
|
+
const baseUri = vscode_uri_1.URI.parse(base);
|
|
73
|
+
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri);
|
|
74
|
+
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const htmlLs = html.getLanguageService({
|
|
78
|
+
fileSystemProvider,
|
|
79
|
+
clientCapabilities: context.env.clientCapabilities,
|
|
80
|
+
});
|
|
54
81
|
context.env.onDidChangeConfiguration?.(() => {
|
|
55
82
|
shouldUpdateCustomData = true;
|
|
56
83
|
});
|
|
@@ -62,18 +89,14 @@ exports.default = (options = {}) => (context) => {
|
|
|
62
89
|
}
|
|
63
90
|
},
|
|
64
91
|
'html/languageService': () => htmlLs,
|
|
92
|
+
'html/documentContext': () => documentContext,
|
|
65
93
|
'html/updateCustomData': updateExtraCustomData,
|
|
66
94
|
},
|
|
67
95
|
triggerCharacters,
|
|
68
96
|
async provideCompletionItems(document, position) {
|
|
69
97
|
return worker(document, async (htmlDocument) => {
|
|
70
98
|
const configs = await context.env.getConfiguration?.('html.completion');
|
|
71
|
-
|
|
72
|
-
return htmlLs.doComplete2(document, position, htmlDocument, context.env.documentContext, configs);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return htmlLs.doComplete(document, position, htmlDocument, configs);
|
|
76
|
-
}
|
|
99
|
+
return htmlLs.doComplete2(document, position, htmlDocument, documentContext, configs);
|
|
77
100
|
});
|
|
78
101
|
},
|
|
79
102
|
provideRenameRange(document, position) {
|
|
@@ -103,9 +126,7 @@ exports.default = (options = {}) => (context) => {
|
|
|
103
126
|
},
|
|
104
127
|
provideDocumentLinks(document) {
|
|
105
128
|
return worker(document, () => {
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
return htmlLs.findDocumentLinks(document, context.env.documentContext);
|
|
129
|
+
return htmlLs.findDocumentLinks(document, documentContext);
|
|
109
130
|
});
|
|
110
131
|
},
|
|
111
132
|
provideDocumentSymbols(document) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
"directory": "packages/html"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"vscode-html-languageservice": "^5.0.4"
|
|
16
|
+
"vscode-html-languageservice": "^5.0.4",
|
|
17
|
+
"vscode-uri": "^3.0.7"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"vscode-languageserver-textdocument": "^1.0.8"
|
|
20
21
|
},
|
|
21
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "a4ee5d50ec7d4c37c7b24e019ee0ee2d701bb8bb"
|
|
22
23
|
}
|