mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 01:05:01 +03:00
Fix prettier plugins does not seem to be picked up (#9193)
This fixed the issue that prettier plugins were not picked up. The old code would always send an empty array to the prettier plugin that happens inside the `prettier_server.js`. **Before** The `options.plugins` key is an empty array, which is not correct. ```log stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":[],"parser":"typescript","path":"/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx"} ``` https://github.com/zed-industries/zed/assets/62463826/52f2aad0-2f96-43a9-81ec-9d4630c495b2 **After** The `options.plugins` contains the `prettier-plugin-organize-imports` plugin as expected. ```log stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"],"parser":"typescript","path":"/Users/remcosmits/Documents/code/prettier-test/src/app/page.tsx"} ``` https://github.com/zed-industries/zed/assets/62463826/9045028d-aeca-4df1-819c-01905d83216c Release Notes: - Fixed send plugins correctly to the prettier plugin ([#8841](https://github.com/zed-industries/zed/issues/8841)).
This commit is contained in:
parent
98cf494057
commit
e5bd9f184b
@ -173,12 +173,16 @@ async function handleMessage(message, prettier) {
|
|||||||
if (params.options.filepath !== undefined) {
|
if (params.options.filepath !== undefined) {
|
||||||
resolvedConfig = (await prettier.prettier.resolveConfig(params.options.filepath)) || {};
|
resolvedConfig = (await prettier.prettier.resolveConfig(params.options.filepath)) || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const plugins = Array.isArray(resolvedConfig?.plugins) && resolvedConfig.plugins.length > 0 ?
|
||||||
|
resolvedConfig.plugins :
|
||||||
|
params.options.plugins;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
...(params.options.prettierOptions || prettier.config),
|
...(params.options.prettierOptions || prettier.config),
|
||||||
...resolvedConfig,
|
...resolvedConfig,
|
||||||
|
plugins,
|
||||||
parser: params.options.parser,
|
parser: params.options.parser,
|
||||||
plugins: params.options.plugins,
|
|
||||||
path: params.options.filepath,
|
path: params.options.filepath,
|
||||||
};
|
};
|
||||||
process.stderr.write(
|
process.stderr.write(
|
||||||
|
Loading…
Reference in New Issue
Block a user