volar-service-css 0.0.46 → 0.0.48
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/index.d.ts +7 -7
- package/index.js +40 -18
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Disposable, DocumentSelector, FormattingOptions, ProviderResult,
|
|
1
|
+
import type { Disposable, DocumentSelector, FormattingOptions, ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service';
|
|
2
2
|
import * as css from 'vscode-css-languageservice';
|
|
3
3
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
4
4
|
export interface Provide {
|
|
@@ -10,11 +10,11 @@ export declare function create({ cssDocumentSelector, scssDocumentSelector, less
|
|
|
10
10
|
scssDocumentSelector?: DocumentSelector;
|
|
11
11
|
lessDocumentSelector?: DocumentSelector;
|
|
12
12
|
useDefaultDataProvider?: boolean;
|
|
13
|
-
getDocumentContext?(context:
|
|
14
|
-
isFormattingEnabled?(document: TextDocument, context:
|
|
15
|
-
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context:
|
|
16
|
-
getLanguageSettings?(document: TextDocument, context:
|
|
17
|
-
getCustomData?(context:
|
|
18
|
-
onDidChangeCustomData?(listener: () => void, context:
|
|
13
|
+
getDocumentContext?(context: LanguageServiceContext): css.DocumentContext;
|
|
14
|
+
isFormattingEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
15
|
+
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: LanguageServiceContext): ProviderResult<css.CSSFormatConfiguration>;
|
|
16
|
+
getLanguageSettings?(document: TextDocument, context: LanguageServiceContext): ProviderResult<css.LanguageSettings | undefined>;
|
|
17
|
+
getCustomData?(context: LanguageServiceContext): ProviderResult<css.ICSSDataProvider[]>;
|
|
18
|
+
onDidChangeCustomData?(listener: () => void, context: LanguageServiceContext): Disposable;
|
|
19
19
|
}): LanguageServicePlugin;
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -7,22 +7,22 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
7
7
|
function create({ cssDocumentSelector = ['css'], scssDocumentSelector = ['scss'], lessDocumentSelector = ['less'], useDefaultDataProvider = true, getDocumentContext = context => {
|
|
8
8
|
return {
|
|
9
9
|
resolveReference(ref, base) {
|
|
10
|
-
|
|
10
|
+
let baseUri = vscode_uri_1.URI.parse(base);
|
|
11
|
+
const decoded = context.decodeEmbeddedDocumentUri(baseUri);
|
|
11
12
|
if (decoded) {
|
|
12
|
-
|
|
13
|
+
baseUri = decoded[0];
|
|
13
14
|
}
|
|
14
15
|
if (ref.match(/^\w[\w\d+.-]*:/)) {
|
|
15
16
|
// starts with a schema
|
|
16
17
|
return ref;
|
|
17
18
|
}
|
|
18
|
-
if (ref[0] === '/') { // resolve absolute path against the current workspace folder
|
|
19
|
-
let folderUri = context.env.
|
|
19
|
+
if (ref[0] === '/' && context.env.workspaceFolders.length) { // resolve absolute path against the current workspace folder
|
|
20
|
+
let folderUri = context.env.workspaceFolders[0].toString();
|
|
20
21
|
if (!folderUri.endsWith('/')) {
|
|
21
22
|
folderUri += '/';
|
|
22
23
|
}
|
|
23
24
|
return folderUri + ref.substring(1);
|
|
24
25
|
}
|
|
25
|
-
const baseUri = vscode_uri_1.URI.parse(base);
|
|
26
26
|
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri);
|
|
27
27
|
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true);
|
|
28
28
|
},
|
|
@@ -40,15 +40,18 @@ function create({ cssDocumentSelector = ['css'], scssDocumentSelector = ['scss']
|
|
|
40
40
|
const customData = await context.env.getConfiguration?.('css.customData') ?? [];
|
|
41
41
|
const newData = [];
|
|
42
42
|
for (const customDataPath of customData) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
for (const workspaceFolder of context.env.workspaceFolders) {
|
|
44
|
+
const uri = vscode_uri_1.Utils.resolvePath(workspaceFolder, customDataPath);
|
|
45
|
+
const json = await context.env.fs?.readFile?.(uri);
|
|
46
|
+
if (json) {
|
|
47
|
+
try {
|
|
48
|
+
const data = JSON.parse(json);
|
|
49
|
+
newData.push(css.newCSSDataProvider(data));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -63,14 +66,33 @@ function create({ cssDocumentSelector = ['css'], scssDocumentSelector = ['scss']
|
|
|
63
66
|
}, } = {}) {
|
|
64
67
|
return {
|
|
65
68
|
name: 'css',
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
capabilities: {
|
|
70
|
+
completionProvider: {
|
|
71
|
+
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/css-language-features/server/src/cssServer.ts#L97
|
|
72
|
+
triggerCharacters: ['/', '-', ':'],
|
|
73
|
+
},
|
|
74
|
+
renameProvider: {
|
|
75
|
+
prepareProvider: true,
|
|
76
|
+
},
|
|
77
|
+
codeActionProvider: {},
|
|
78
|
+
definitionProvider: true,
|
|
79
|
+
diagnosticProvider: true,
|
|
80
|
+
hoverProvider: true,
|
|
81
|
+
referencesProvider: true,
|
|
82
|
+
documentHighlightProvider: true,
|
|
83
|
+
documentLinkProvider: {},
|
|
84
|
+
documentSymbolProvider: true,
|
|
85
|
+
colorProvider: true,
|
|
86
|
+
foldingRangeProvider: true,
|
|
87
|
+
selectionRangeProvider: true,
|
|
88
|
+
documentFormattingProvider: true,
|
|
89
|
+
},
|
|
68
90
|
create(context) {
|
|
69
91
|
const stylesheets = new WeakMap();
|
|
70
92
|
const fileSystemProvider = {
|
|
71
|
-
stat: async (uri) => await context.env.fs?.stat(uri)
|
|
93
|
+
stat: async (uri) => await context.env.fs?.stat(vscode_uri_1.URI.parse(uri))
|
|
72
94
|
?? { type: css.FileType.Unknown, ctime: 0, mtime: 0, size: 0 },
|
|
73
|
-
readDirectory: async (uri) => await context.env.fs?.readDirectory(uri) ?? [],
|
|
95
|
+
readDirectory: async (uri) => await context.env.fs?.readDirectory(vscode_uri_1.URI.parse(uri)) ?? [],
|
|
74
96
|
};
|
|
75
97
|
const documentContext = getDocumentContext(context);
|
|
76
98
|
const disposable = onDidChangeCustomData(() => initializing = undefined, context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Integrate vscode-css-languageservice into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/css",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@types/node": "latest"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@volar/language-service": "~2.
|
|
35
|
+
"@volar/language-service": "~2.3.0-alpha.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@volar/language-service": {
|
|
39
39
|
"optional": true
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "6a80c92133e154907a79eefa05603f63994214c3"
|
|
43
43
|
}
|