volar-service-prettier 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 +4 -4
- package/index.js +8 -5
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { DocumentSelector, FormattingOptions, ProviderResult,
|
|
1
|
+
import type { DocumentSelector, FormattingOptions, ProviderResult, LanguageServiceContext, LanguageServicePlugin, TextDocument } from '@volar/language-service';
|
|
2
2
|
import type { Options } from 'prettier';
|
|
3
3
|
export declare function create(
|
|
4
4
|
/**
|
|
5
5
|
* Prettier instance or getter to use.
|
|
6
6
|
*/
|
|
7
|
-
prettierInstanceOrGetter: typeof import('prettier') | ((context:
|
|
7
|
+
prettierInstanceOrGetter: typeof import('prettier') | ((context: LanguageServiceContext) => ProviderResult<typeof import('prettier') | undefined>), { html, documentSelector, isFormattingEnabled, getFormattingOptions, }?: {
|
|
8
8
|
html?: {
|
|
9
9
|
/**
|
|
10
10
|
* Preprocessing to break "contents" from "HTML tags".
|
|
@@ -20,7 +20,7 @@ prettierInstanceOrGetter: typeof import('prettier') | ((context: ServiceContext)
|
|
|
20
20
|
* ['html', 'css', 'scss', 'typescript', 'javascript']
|
|
21
21
|
*/
|
|
22
22
|
documentSelector?: DocumentSelector;
|
|
23
|
-
isFormattingEnabled?(prettier: typeof import('prettier'), document: TextDocument, context:
|
|
24
|
-
getFormattingOptions?(prettier: typeof import('prettier'), document: TextDocument, formatOptions: FormattingOptions, context:
|
|
23
|
+
isFormattingEnabled?(prettier: typeof import('prettier'), document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>;
|
|
24
|
+
getFormattingOptions?(prettier: typeof import('prettier'), document: TextDocument, formatOptions: FormattingOptions, context: LanguageServiceContext): ProviderResult<Options>;
|
|
25
25
|
}): LanguageServicePlugin;
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -7,8 +7,8 @@ function create(
|
|
|
7
7
|
* Prettier instance or getter to use.
|
|
8
8
|
*/
|
|
9
9
|
prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'typescript', 'javascript'], isFormattingEnabled = async (prettier, document, context) => {
|
|
10
|
-
const
|
|
11
|
-
const uri =
|
|
10
|
+
const parsed = vscode_uri_1.URI.parse(document.uri);
|
|
11
|
+
const uri = context.decodeEmbeddedDocumentUri(parsed)?.[0] ?? parsed;
|
|
12
12
|
if (uri.scheme === 'file') {
|
|
13
13
|
const fileInfo = await prettier.getFileInfo(uri.fsPath, { ignorePath: '.prettierignore', resolveConfig: false });
|
|
14
14
|
if (fileInfo.ignored) {
|
|
@@ -17,12 +17,12 @@ prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'ty
|
|
|
17
17
|
}
|
|
18
18
|
return true;
|
|
19
19
|
}, getFormattingOptions = async (prettier, document, formatOptions, context) => {
|
|
20
|
-
const
|
|
21
|
-
const uri =
|
|
20
|
+
const parsed = vscode_uri_1.URI.parse(document.uri);
|
|
21
|
+
const uri = context.decodeEmbeddedDocumentUri(parsed)?.[0] ?? parsed;
|
|
22
22
|
const configOptions = uri.scheme === 'file'
|
|
23
23
|
? await prettier.resolveConfig(uri.fsPath)
|
|
24
24
|
: null;
|
|
25
|
-
const editorOptions = await context.env.getConfiguration?.('prettier',
|
|
25
|
+
const editorOptions = await context.env.getConfiguration?.('prettier', uri.toString());
|
|
26
26
|
return {
|
|
27
27
|
filepath: uri.scheme === 'file'
|
|
28
28
|
? uri.fsPath
|
|
@@ -35,6 +35,9 @@ prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'ty
|
|
|
35
35
|
}, } = {}) {
|
|
36
36
|
return {
|
|
37
37
|
name: 'prettier',
|
|
38
|
+
capabilities: {
|
|
39
|
+
documentFormattingProvider: true,
|
|
40
|
+
},
|
|
38
41
|
create(context) {
|
|
39
42
|
let prettierInstanceOrPromise;
|
|
40
43
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-prettier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Integrate Prettier into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/prettier",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prettier": "^3.0.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@volar/language-service": "~2.
|
|
35
|
+
"@volar/language-service": "~2.3.0-alpha.0",
|
|
36
36
|
"prettier": "^2.2 || ^3.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"optional": true
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "6a80c92133e154907a79eefa05603f63994214c3"
|
|
47
47
|
}
|