@astrojs/language-server 0.23.0 → 0.23.1
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/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,7 @@ export declare class ConfigManager {
|
|
|
23
23
|
removeDocument(scopeUri: string): void;
|
|
24
24
|
getConfig<T>(section: string, scopeUri: string): Promise<T | Record<string, any>>;
|
|
25
25
|
getEmmetConfig(document: TextDocument): Promise<VSCodeEmmetConfig>;
|
|
26
|
+
getPrettierVSConfig(document: TextDocument): Promise<Record<string, any>>;
|
|
26
27
|
getTSFormatConfig(document: TextDocument, vscodeOptions?: FormattingOptions): Promise<FormatCodeSettings>;
|
|
27
28
|
getTSPreferences(document: TextDocument): Promise<UserPreferences>;
|
|
28
29
|
getTSInlayHintsPreferences(document: TextDocument): Promise<InlayHintsOptions>;
|
|
@@ -90,6 +90,10 @@ class ConfigManager {
|
|
|
90
90
|
showSuggestionsAsSnippets: emmetConfig.showSuggestionsAsSnippets ?? false,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
async getPrettierVSConfig(document) {
|
|
94
|
+
const prettierVSConfig = (await this.getConfig('prettier', document.uri)) ?? {};
|
|
95
|
+
return prettierVSConfig;
|
|
96
|
+
}
|
|
93
97
|
async getTSFormatConfig(document, vscodeOptions) {
|
|
94
98
|
const formatConfig = (await this.getConfig('typescript.format', document.uri)) ?? {};
|
|
95
99
|
return {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AstroPlugin = void 0;
|
|
4
4
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
5
5
|
const importPackage_1 = require("../../importPackage");
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
6
|
const CompletionsProvider_1 = require("./features/CompletionsProvider");
|
|
8
7
|
class AstroPlugin {
|
|
9
8
|
constructor(configManager, languageServiceManager) {
|
|
@@ -22,14 +21,19 @@ class AstroPlugin {
|
|
|
22
21
|
return [];
|
|
23
22
|
}
|
|
24
23
|
const prettier = (0, importPackage_1.importPrettier)(filePath);
|
|
25
|
-
const prettierConfig = await prettier.resolveConfig(filePath, { editorconfig: true, useCache: false });
|
|
26
|
-
const
|
|
24
|
+
const prettierConfig = (await prettier.resolveConfig(filePath, { editorconfig: true, useCache: false })) ?? {};
|
|
25
|
+
const prettierVSConfig = await this.configManager.getPrettierVSConfig(document);
|
|
26
|
+
const editorFormatConfig = options !== undefined // We need to check for options existing here because some editors might not have it
|
|
27
27
|
? {
|
|
28
|
-
tabWidth:
|
|
29
|
-
useTabs:
|
|
28
|
+
tabWidth: options.tabSize,
|
|
29
|
+
useTabs: !options.insertSpaces,
|
|
30
30
|
}
|
|
31
31
|
: {};
|
|
32
|
-
|
|
32
|
+
// Return a config with the following cascade:
|
|
33
|
+
// - Prettier config file should always win if it exists, if it doesn't:
|
|
34
|
+
// - Prettier config from the VS Code extension is used, if it doesn't exist:
|
|
35
|
+
// - Use the editor's basic configuration settings
|
|
36
|
+
const resultConfig = returnObjectIfHasKeys(prettierConfig) || returnObjectIfHasKeys(prettierVSConfig) || editorFormatConfig;
|
|
33
37
|
const fileInfo = await prettier.getFileInfo(filePath, { ignorePath: '.prettierignore' });
|
|
34
38
|
if (fileInfo.ignored) {
|
|
35
39
|
return [];
|
|
@@ -74,3 +78,8 @@ class AstroPlugin {
|
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
exports.AstroPlugin = AstroPlugin;
|
|
81
|
+
function returnObjectIfHasKeys(obj) {
|
|
82
|
+
if (Object.keys(obj || {}).length > 0) {
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
}
|