@astrojs/language-server 2.1.3 → 2.1.4
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/dist/importPackage.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import type * as svelte from '@astrojs/svelte/dist/editor.cjs';
|
|
|
2
2
|
import type * as vue from '@astrojs/vue/dist/editor.cjs';
|
|
3
3
|
import type * as prettier from 'prettier';
|
|
4
4
|
export declare function setIsTrusted(_isTrusted: boolean): void;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPackagePath(packageName: string, fromPath: string[], root?: boolean): string | undefined;
|
|
6
9
|
export declare function importSvelteIntegration(fromPath: string): typeof svelte | undefined;
|
|
7
10
|
export declare function importVueIntegration(fromPath: string): typeof vue | undefined;
|
|
8
11
|
export declare function importPrettier(fromPath: string): typeof prettier | undefined;
|
package/dist/importPackage.js
CHANGED
|
@@ -7,13 +7,18 @@ function setIsTrusted(_isTrusted) {
|
|
|
7
7
|
isTrusted = _isTrusted;
|
|
8
8
|
}
|
|
9
9
|
exports.setIsTrusted = setIsTrusted;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Get the path of a package's directory from the paths in `fromPath`, if `root` is set to false, it will return the path of the package's entry point
|
|
12
|
+
*/
|
|
13
|
+
function getPackagePath(packageName, fromPath, root = true) {
|
|
11
14
|
const paths = [];
|
|
12
15
|
if (isTrusted) {
|
|
13
16
|
paths.unshift(...fromPath);
|
|
14
17
|
}
|
|
15
18
|
try {
|
|
16
|
-
return
|
|
19
|
+
return root
|
|
20
|
+
? (0, node_path_1.dirname)(require.resolve(packageName + '/package.json', { paths }))
|
|
21
|
+
: require.resolve(packageName, { paths });
|
|
17
22
|
}
|
|
18
23
|
catch (e) {
|
|
19
24
|
return undefined;
|
|
@@ -51,7 +56,7 @@ function importPrettier(fromPath) {
|
|
|
51
56
|
}
|
|
52
57
|
exports.importPrettier = importPrettier;
|
|
53
58
|
function getPrettierPluginPath(fromPath) {
|
|
54
|
-
const prettierPluginPath = getPackagePath('prettier-plugin-astro', [fromPath, __dirname]);
|
|
59
|
+
const prettierPluginPath = getPackagePath('prettier-plugin-astro', [fromPath, __dirname], false);
|
|
55
60
|
if (!prettierPluginPath) {
|
|
56
61
|
return undefined;
|
|
57
62
|
}
|
|
@@ -68,8 +68,7 @@ const plugin = (initOptions, modules) => ({
|
|
|
68
68
|
languages: ['astro'],
|
|
69
69
|
ignoreIdeOptions: true,
|
|
70
70
|
resolveConfigOptions: {
|
|
71
|
-
//
|
|
72
|
-
// TODO: Upstream a fix for this
|
|
71
|
+
// This seems to be broken since Prettier 3, and it'll always use its cumbersome cache. Hopefully it works one day.
|
|
73
72
|
useCache: false,
|
|
74
73
|
},
|
|
75
74
|
additionalOptions: async (resolvedConfig) => {
|
|
@@ -77,7 +76,8 @@ const plugin = (initOptions, modules) => ({
|
|
|
77
76
|
if (!prettier || !prettierPluginPath) {
|
|
78
77
|
return [];
|
|
79
78
|
}
|
|
80
|
-
const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro')
|
|
79
|
+
const hasPluginLoadedAlready = (await prettier.getSupportInfo()).languages.some((l) => l.name === 'astro') ||
|
|
80
|
+
resolvedConfig.plugins?.includes('prettier-plugin-astro'); // getSupportInfo doesn't seems to work very well in Prettier 3 for plugins
|
|
81
81
|
return hasPluginLoadedAlready ? [] : [prettierPluginPath];
|
|
82
82
|
}
|
|
83
83
|
const plugins = [
|