Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier not honoring plugins #8841

Closed
1 task done
affanshahid opened this issue Mar 4, 2024 · 4 comments
Closed
1 task done

Prettier not honoring plugins #8841

affanshahid opened this issue Mar 4, 2024 · 4 comments
Assignees
Labels
defect [core label] prettier Prettier tooling support tooling An umbrella label for language tools, linters, formatters, etc

Comments

@affanshahid
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Using Zed with a project that uses Prettier with some plugins. It seems to ignore the plugins when formatting files.
The prettier config:

{
  "singleQuote": true,
  "trailingComma": "all",
  "plugins": ["prettier-plugin-organize-imports"]
}

Prettier LSP logs:

stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":[],"parser":"typescript","path":"/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx"}
stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":[],"parser":"typescript","path":"/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx"}
stderr: Resolved config: {"singleQuote":true,"trailingComma":"all","plugins":["prettier-plugin-organize-imports"]}, will format file '/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx' with options: {"singleQuote":true,"trailingComma":"all","plugins":[],"parser":"typescript","path":"/Users/affan/Development/fhs-website/app/(portal)/resident/payments/page.tsx"}

Environment

Zed: v0.125.1 (Zed Preview)
OS: macOS 14.2.1
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

Zed.log

@affanshahid affanshahid added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels Mar 4, 2024
@Moshyfawn Moshyfawn added prettier Prettier tooling support and removed triage Maintainer needs to classify the issue labels Mar 5, 2024
@JosephTLyons JosephTLyons added tooling An umbrella label for language tools, linters, formatters, etc and removed admin read Pending admin review labels Mar 5, 2024
@mrnugget
Copy link
Member

I'm 99% sure this was fixed by 9c6a0d9 which ended up in 0.126.0. Can you try that version and see if the problem still shows up?

@timcole
Copy link

timcole commented Mar 11, 2024

Hey @mrnugget, I'm on Zed Preview 0.126.1 and @trivago/prettier-plugin-sort-imports plugin still doesn't work.

stderr: Resolved config: {"semi":true,"trailingComma":"all","singleQuote":true,"printWidth":80,"tabWidth":2,"importOrder":["^@type/(.*)$","^@generated/(.*)$","^@lib/(.*)$","^react-use/(.*)$","^@hooks/(.*)$","^@components/(.*)$","^@email/(.*)$","^@(server|trpc)/(.*)$","^[./]","^simple-icons$","^@/icons/(.*)$"],"importOrderSeparation":true,"plugins":["@trivago/prettier-plugin-sort-imports"]}, will format file '/Users/tim/projects/socialblade/socialblade.com/server/routers/admin/index.ts' with options: {"semi":true,"trailingComma":"all","singleQuote":true,"printWidth":80,"tabWidth":2,"importOrder":["^@type/(.*)$","^@generated/(.*)$","^@lib/(.*)$","^react-use/(.*)$","^@hooks/(.*)$","^@components/(.*)$","^@email/(.*)$","^@(server|trpc)/(.*)$","^[./]","^simple-icons$","^@/icons/(.*)$"],"importOrderSeparation":true,"plugins":[],"parser":"typescript","path":"/Users/tim/projects/socialblade/socialblade.com/server/routers/admin/index.ts"}

@RemcoSmitsDev
Copy link
Contributor

@timcole I have created a pull request to fix this issue, so sit tight😀.

mrnugget pushed a commit that referenced this issue Mar 12, 2024
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](#8841)).
@mrnugget
Copy link
Member

This was fixed by #9193 which will go out in the next preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect [core label] prettier Prettier tooling support tooling An umbrella label for language tools, linters, formatters, etc
Projects
None yet
Development

No branches or pull requests

6 participants