volar-service-prettier 0.0.42 → 0.0.44
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.js +12 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -6,8 +6,9 @@ function create(
|
|
|
6
6
|
/**
|
|
7
7
|
* Prettier instance or getter to use.
|
|
8
8
|
*/
|
|
9
|
-
prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'typescript', 'javascript'], isFormattingEnabled = async (prettier, document) => {
|
|
10
|
-
const
|
|
9
|
+
prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'typescript', 'javascript'], isFormattingEnabled = async (prettier, document, context) => {
|
|
10
|
+
const documentUri = context.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
|
|
11
|
+
const uri = vscode_uri_1.URI.parse(documentUri);
|
|
11
12
|
if (uri.scheme === 'file') {
|
|
12
13
|
const fileInfo = await prettier.getFileInfo(uri.fsPath, { ignorePath: '.prettierignore', resolveConfig: false });
|
|
13
14
|
if (fileInfo.ignored) {
|
|
@@ -16,11 +17,16 @@ prettierInstanceOrGetter, { html, documentSelector = ['html', 'css', 'scss', 'ty
|
|
|
16
17
|
}
|
|
17
18
|
return true;
|
|
18
19
|
}, getFormattingOptions = async (prettier, document, formatOptions, context) => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const documentUri = context.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
|
|
21
|
+
const uri = vscode_uri_1.URI.parse(documentUri);
|
|
22
|
+
const configOptions = uri.scheme === 'file'
|
|
23
|
+
? await prettier.resolveConfig(uri.fsPath)
|
|
24
|
+
: null;
|
|
25
|
+
const editorOptions = await context.env.getConfiguration?.('prettier', documentUri);
|
|
22
26
|
return {
|
|
23
|
-
filepath
|
|
27
|
+
filepath: uri.scheme === 'file'
|
|
28
|
+
? uri.fsPath
|
|
29
|
+
: undefined,
|
|
24
30
|
tabWidth: formatOptions.tabSize,
|
|
25
31
|
useTabs: !formatOptions.insertSpaces,
|
|
26
32
|
...editorOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-prettier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
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",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"optional": true
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "c4fa09f8f3858532e806d6b2ec9c65eecb66b1a1"
|
|
47
47
|
}
|