zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.38k stars 2.88k forks source link

Extend prettier formatting support to modern yarn (≥v2) #4372

Open acusti opened 11 months ago

acusti commented 11 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

clone any git repo using a PnP version of yarn (v2+) and make a formatting change to a file that prettier supports (with "formatting": "auto" in the zed settings.json). auto-prettier formatting will not work. here’s a repo that reproduces the issue: https://github.com/acusti/uikit/

relevant logs attached below.

this issue is a follow-up to zed-industries/zed#5612, based on this comment:

Thank you, it's a yarn project and modern versions do not populate node_modules at all, which we currently rely on when searching for prettier, instead, there's only .yarn/cache/prettier-npm-2.8.0-746e3df53e-72004ce0cc.zip artifacts in the project. The problem is, we do not use a real node runtime when searching for prettier and neither we do invoke it through project's set-up, so that needs more work to understand how to get it running..

I would recommend to create a separate issue about yarn projects, since it seems that the fix won't be that easy and straightforward.

_Originally posted by @SomeoneToIgnore in https://github.com/zed-industries/zed/issues/5612

Environment

Zed: v0.110.2 (stable) OS: macOS 13.6.0 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.

2023-11-05T17:44:47 [INFO] Opening main db 2023-11-05T17:44:47 [INFO] starting language server "typescript-language-server", path: "/Users/andrew/Projects/uikit", id: 1 2023-11-05T17:44:47 [INFO] starting language server "eslint", path: "/Users/andrew/Projects/uikit", id: 2 2023-11-05T17:44:47 [INFO] starting language server "tailwindcss-language-server", path: "/Users/andrew/Projects/uikit", id: 3 2023-11-05T17:44:47 [INFO] Node runtime install_if_needed 2023-11-05T17:44:47 [INFO] Node runtime install_if_needed 2023-11-05T17:44:47 [INFO] Node runtime install_if_needed 2023-11-05T17:44:47 [INFO] Node runtime install_if_needed 2023-11-05T17:44:47 [INFO] Node runtime install_if_needed 2023-11-05T17:44:48 [INFO] 2 unhandled notification window/logMessage: { "type": 3, "message": "ESLint server running in node v18.15.0" } 2023-11-05T17:44:48 [INFO] 2 unhandled notification eslint/noLibrary: { "source": { "uri": "file:///Users/andrew/Projects/uikit/packages/date-picker/src/MonthCalendar.tsx" } } 2023-11-05T17:44:48 [INFO] Fetching default prettier and plugins: [("prettier-plugin-tailwindcss", "0.5.6"), ("prettier", "3.0.3")] 2023-11-05T17:44:48 [INFO] Node runtime install_if_needed 2023-11-05T17:44:48 [INFO] Node runtime install_if_needed 2023-11-05T17:44:48 [INFO] Node runtime install_if_needed 2023-11-05T17:44:48 [INFO] 3 unhandled notification window/logMessage: { "type": 4, "message": "[Global] Creating projects: []" } 2023-11-05T17:44:49 [INFO] Found prettier in "/Users/andrew/Projects/uikit", starting. 2023-11-05T17:44:49 [INFO] Node runtime install_if_needed 2023-11-05T17:44:49 [INFO] Node runtime install_if_needed 2023-11-05T17:44:49 [ERROR] invalid LSP message header "" 2023-11-05T17:44:49 [ERROR] server shut down 2023-11-05T17:44:49 [ERROR] Failed to create prettier instance for buffer during autoformatting: prettier start: prettier server initialization: oneshot canceled 2023-11-05T17:44:49 [INFO] 1 unhandled notification window/logMessage: { "type": 2, "message": "[lspserver] Typescript specified through user setting ignored due to invalid path \"/Users/andrew/Projects/uikit/lib/tsserver.js\"" } 2023-11-05T17:44:49 [INFO] 1 unhandled notification window/logMessage: { "type": 3, "message": "Using Typescript version (bundled) 5.0.4 from path \"/Users/andrew/Library/Application Support/Zed/languages/typescript-language-server/node_modules/typescript/lib/tsserver.js\"" } 2023-11-05T17:44:49 [INFO] 1 unhandled notification $/typescriptVersion: { "version": "5.0.4", "source": "bundled" }

github-actions[bot] commented 2 weeks ago

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. Are you able to reproduce this issue in the latest version of Zed? If so, please let us know by commenting on this issue and we will keep it open; otherwise, we'll close it in a week. Feel free to open a new issue if you're seeing this message after the issue has been closed. Thanks for your help!

acusti commented 2 weeks ago

this is still reproducible using the latest version of Zed (Zed 0.153.6)