-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
extensions: Add Ruff extension #14198
Conversation
Update: This is not required anymore. We'll be shipping a way to pick the formatter out as well so the two LSPs don't collide. |
That's still in progress. Right now there's no way to use a non-primary language server for formatting. It should be possible by our next update on Wednesday. This however did not block releasing the extension itself, as setting up Ruff is independent from how Zed chooses a language server to format your code. |
I didn't know there were such limitations. I currently have my zed config set up as follows to use the ruff format. {
"languages": {
..., // other languages
"Python": {
"format_on_save": {
"external": {
"command": "python",
"arguments": [
"-m",
"ruff",
"format",
"-"
]
}
}
}
}
} I think it can be introduced in the Python guide documents along with the extension. I made a PR for it: #14896 |
Thank you so much! |
Can I use |
Yes, you can;
(Note the lack of |
@osiewicz Ah, thanks. After some restarting it seems to work now. |
…using Ruff extension (#14896) Added documentation for #14198 I also suggest replacing format guides from `black` to `ruff` to unify the tooling in the document. Ruff is now widely used in the Python community, including [fastapi](https://github.com/tiangolo/fastapi/blob/cd6e9db0653eabbf0fb14908c73939a11a131058/pyproject.toml#L213). It's compatible with black but a lot faster. Release Notes: - N/A
Updated my comment from earlier so that people don't disable |
I'm a little confused as to what this extension actually does. The docs still say we need to add the external formatter config to our settings. Does this just install ruff if it isn't present? |
…using Ruff extension (zed-industries#14896) Added documentation for zed-industries#14198 I also suggest replacing format guides from `black` to `ruff` to unify the tooling in the document. Ruff is now widely used in the Python community, including [fastapi](https://github.com/tiangolo/fastapi/blob/cd6e9db0653eabbf0fb14908c73939a11a131058/pyproject.toml#L213). It's compatible with black but a lot faster. Release Notes: - N/A
@Fingel -- I just realized, you probably need to upgrade your version of |
That makes sense! For what it's worth, I installed via Pipx. I am now seeing linting errors (nice!) and can format with the external command. |
Whichever suits you best. System-wide is often the second easiest and safest option, but if you want to keep your system environment clean a per-project virtualenv should be a great option as well. (Or a Nix flake, if you are familiar with them.) The version available in your system package manager may not be as up to date as the other options, though. Letting the zed extension download it is fine if the upstream project publishes prebuilt binaries for your platform on github (and you trust both them and the extension enough to just let the extension blindly download it). Personally I'm not a fan of this approach, but many people greatly appreciate the effortlessness of it, so as long as they understand the risks involved more power to them. |
I'd be fine with the Zed extension handling it all. But to get formatting to work (at least for now) you need to specify an executable. I'm not sure how smart Zed's Python handling is, but ideally it could run binaries from the project's Virtualenv. That doesn't seem to be the case (yet) so it's looking like global installation is the way. |
To install Ruff extension, open command palette (
cmd-shift-p
on mac), search forzed: extensions
and then in the search bar of the extensions view type inRuff
.Release Notes: