volar-service-css 0.0.3 → 0.0.5
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 +2 -2
- package/out/index.js +45 -13
- package/package.json +5 -3
package/out/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Service } from '@volar/language-service';
|
|
2
2
|
import * as css from 'vscode-css-languageservice';
|
|
3
|
-
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
4
|
export interface Provide {
|
|
5
5
|
'css/stylesheet': (document: TextDocument) => css.Stylesheet | undefined;
|
|
6
6
|
'css/languageService': (languageId: string) => css.LanguageService | undefined;
|
|
7
7
|
}
|
|
8
|
-
declare const _default: () => Service
|
|
8
|
+
declare const _default: () => Service<Provide>;
|
|
9
9
|
export default _default;
|
package/out/index.js
CHANGED
|
@@ -23,9 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const path_1 = require("path");
|
|
26
27
|
const css = __importStar(require("vscode-css-languageservice"));
|
|
27
|
-
const
|
|
28
|
-
const path = __importStar(require("path"));
|
|
28
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
29
29
|
exports.default = () => (context) => {
|
|
30
30
|
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/css-language-features/server/src/cssServer.ts#L97
|
|
31
31
|
const triggerCharacters = ['/', '-', ':'];
|
|
@@ -34,9 +34,41 @@ exports.default = () => (context) => {
|
|
|
34
34
|
}
|
|
35
35
|
let inited = false;
|
|
36
36
|
const stylesheets = new WeakMap();
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const fileSystemProvider = {
|
|
38
|
+
stat: async (uri) => await context.env.fs?.stat(uri) ?? {
|
|
39
|
+
type: css.FileType.Unknown,
|
|
40
|
+
ctime: 0,
|
|
41
|
+
mtime: 0,
|
|
42
|
+
size: 0,
|
|
43
|
+
},
|
|
44
|
+
readDirectory: async (uri) => context.env.fs?.readDirectory(uri) ?? [],
|
|
45
|
+
};
|
|
46
|
+
const documentContext = {
|
|
47
|
+
resolveReference(ref, base) {
|
|
48
|
+
if (ref.match(/^\w[\w\d+.-]*:/)) {
|
|
49
|
+
// starts with a schema
|
|
50
|
+
return ref;
|
|
51
|
+
}
|
|
52
|
+
if (ref[0] === '/') { // resolve absolute path against the current workspace folder
|
|
53
|
+
return base + ref;
|
|
54
|
+
}
|
|
55
|
+
const baseUri = vscode_uri_1.URI.parse(base);
|
|
56
|
+
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri);
|
|
57
|
+
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const cssLs = css.getCSSLanguageService({
|
|
61
|
+
fileSystemProvider,
|
|
62
|
+
clientCapabilities: context.env.clientCapabilities,
|
|
63
|
+
});
|
|
64
|
+
const scssLs = css.getSCSSLanguageService({
|
|
65
|
+
fileSystemProvider,
|
|
66
|
+
clientCapabilities: context.env.clientCapabilities,
|
|
67
|
+
});
|
|
68
|
+
const lessLs = css.getLESSLanguageService({
|
|
69
|
+
fileSystemProvider,
|
|
70
|
+
clientCapabilities: context.env.clientCapabilities,
|
|
71
|
+
});
|
|
40
72
|
const postcssLs = {
|
|
41
73
|
...scssLs,
|
|
42
74
|
doValidation: (document, stylesheet, documentSettings) => {
|
|
@@ -56,9 +88,7 @@ exports.default = () => (context) => {
|
|
|
56
88
|
async provideCompletionItems(document, position) {
|
|
57
89
|
return worker(document, async (stylesheet, cssLs) => {
|
|
58
90
|
const settings = await context.env.getConfiguration?.(document.languageId);
|
|
59
|
-
const cssResult =
|
|
60
|
-
? await cssLs.doComplete2(document, position, stylesheet, context.env.documentContext, settings?.completion)
|
|
61
|
-
: await cssLs.doComplete(document, position, stylesheet, settings?.completion);
|
|
91
|
+
const cssResult = await cssLs.doComplete2(document, position, stylesheet, documentContext, settings?.completion);
|
|
62
92
|
return cssResult;
|
|
63
93
|
});
|
|
64
94
|
},
|
|
@@ -81,7 +111,11 @@ exports.default = () => (context) => {
|
|
|
81
111
|
return worker(document, (stylesheet, cssLs) => {
|
|
82
112
|
const location = cssLs.findDefinition(document, position, stylesheet);
|
|
83
113
|
if (location) {
|
|
84
|
-
return [
|
|
114
|
+
return [{
|
|
115
|
+
targetUri: location.uri,
|
|
116
|
+
targetRange: location.range,
|
|
117
|
+
targetSelectionRange: location.range,
|
|
118
|
+
}];
|
|
85
119
|
}
|
|
86
120
|
});
|
|
87
121
|
},
|
|
@@ -109,9 +143,7 @@ exports.default = () => (context) => {
|
|
|
109
143
|
},
|
|
110
144
|
async provideDocumentLinks(document) {
|
|
111
145
|
return await worker(document, (stylesheet, cssLs) => {
|
|
112
|
-
|
|
113
|
-
return;
|
|
114
|
-
return cssLs.findDocumentLinks2(document, stylesheet, context.env.documentContext);
|
|
146
|
+
return cssLs.findDocumentLinks2(document, stylesheet, documentContext);
|
|
115
147
|
});
|
|
116
148
|
},
|
|
117
149
|
provideDocumentSymbols(document) {
|
|
@@ -172,7 +204,7 @@ exports.default = () => (context) => {
|
|
|
172
204
|
const newData = [];
|
|
173
205
|
for (const customDataPath of customData) {
|
|
174
206
|
try {
|
|
175
|
-
const jsonPath =
|
|
207
|
+
const jsonPath = path_1.posix.resolve(customDataPath);
|
|
176
208
|
newData.push(css.newCSSDataProvider(require(jsonPath)));
|
|
177
209
|
}
|
|
178
210
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"vscode-css-languageservice": "^6.2.3",
|
|
17
|
-
"vscode-
|
|
17
|
+
"vscode-uri": "^3.0.7"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
18
20
|
"vscode-languageserver-textdocument": "^1.0.8"
|
|
19
21
|
},
|
|
20
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "7b58234769e16ccb8eed0e6eb03f58ed24b7df40"
|
|
21
23
|
}
|