Skip to content

Conversation

@LoicRiegel
Copy link
Contributor

@LoicRiegel LoicRiegel commented Oct 17, 2025

Summary

Updated Ruff installation instructions for Zed editor.

Details

Ruff support is now built in and does not require installing an extension anymore. zed-industries/zed#37804

Also FYI this open issue is related: zed-industries/zed#40266.

But I've just tried the last code snippet from the docs on a fresh Zed install on Windows and it worked well without installing any extension.

Updated Ruff installation instructions for Zed editor.

Ruff support is now built in and does not require installing an extension anymore. zed-industries/zed#37804

Also FWI this open issue is related: zed-industries/zed#40266.

But I've just tried the last code snippet from the docs on a fresh Zed install on Windows and it worked well without installing any extension.
@MichaReiser
Copy link
Member

Thank you. There's probably more that we can remove, now that ruff is used as the default formatter and linter (it's enabled by default) as mentioned here https://zed.dev/docs/languages/python#code-formatting--linting

@LoicRiegel
Copy link
Contributor Author

I can have a look

@injust
Copy link
Contributor

injust commented Oct 20, 2025

Zed comes with formatting and linting out-of-the-box now.

If you want Ruff to organize imports:

{
    "languages": {
        "Python": {
            "code_actions_on_format": { "source.organizeImports.ruff": true }
        }
    }
}

If you want Ruff to apply fixes (which includes organizing imports):

{
    "languages": {
        "Python": {
            "code_actions_on_format": { "source.fixAll.ruff": true }
        }
    }
}

@LoicRiegel
Copy link
Contributor Author

I'll do a commit tonight.

Strange that Zed's documentation does not mention the code_actions_on_format anywhere in their python docs. But they have a nice tool to automatically update settings.json settings.
They also mention that the ruff configuration can be read from ruff.toml, but .ruff.toml and pyproject.toml also work (just tested, I wanted to be sure).
Maybe I'll make a small PR on their side too.

BTW do we want do add this in ty's documentation, or is this section https://docs.astral.sh/ty/editors/#other-editors enough?:

{
  "languages": {
    "Python": {
      "language_servers": [
        // Disable basedpyright and enable Ty, and otherwise
        // use the default configuration.
        "ty",
        "!basedpyright",
        "..."
      ]
    }
  }
}

@injust
Copy link
Contributor

injust commented Oct 23, 2025

Strange that Zed's documentation does not mention the code_actions_on_format anywhere in their python docs. But they have a nice tool to automatically update settings.json settings.

code_actions_on_format was slated to be removed from Zed (in favour of code_action), but it broke some uses cases, so it was added back. That might be why.

@MichaReiser
Copy link
Member

BTW do we want do add this in ty's documentation, or is this section docs.astral.sh/ty/editors#other-editors enough?:

Adding Zed to other editors makes sense to me, considering that we have a dedicated tab for Zed on the editor settings page.

I'll do a commit tonight.

Thank you!

@LoicRiegel
Copy link
Contributor Author

Okay tell me what you think. I put back "code_actions_on_format" since this is what has to be used at the moment apparently

@MichaReiser MichaReiser added the documentation Improvements or additions to documentation label Oct 27, 2025
@MichaReiser
Copy link
Member

MichaReiser commented Nov 4, 2025

Sorry for the late review

Okay tell me what you think. I put back "code_actions_on_format" since this is what has to be used at the moment apparently

Do you have a reference for this. Our recommendation is to run code actions (fixes and organize imports) before format but code_actions_on_format (at least according to the inline documentation), runs after formatting.

That's why I'd prefer to keep our existing recommended configuration, unless there are issues with it that we aren't aware of.

@MichaReiser MichaReiser requested review from MichaReiser and removed request for dhruvmanila November 4, 2025 20:39
@injust
Copy link
Contributor

injust commented Nov 4, 2025

Do you have a reference for this. Our recommendation is to run code actions (fixes and organize imports) before format but code_actions_on_format (at least according to the inline documentation), runs after formatting.

See zed-industries/zed#40409. Zed removed code_actions_on_format, then added it back and included a migrator that will convert this:

{
    "languages": {
        "Python": {
            "formatter": [{ "code_action": "source.fixAll.ruff" }]
        }
    }
}

to this:

{
    "languages": {
        "Python": {
            "code_actions_on_format": { "source.fixAll.ruff": true }
        }
    }
}

@injust
Copy link
Contributor

injust commented Nov 4, 2025

cc @probably-neb if you have more insight on the code_action -> code_actions_on_format migrator causing side effects for code action ordering before/after formatting.

@probably-neb
Copy link

Thanks for the ping @injust

Do you have a reference for this. Our recommendation is to run code actions (fixes and organize imports) before format but code_actions_on_format (at least according to the inline documentation), runs after formatting.

Where are you seeing this documentation @MichaReiser? I'd love to fix it. I wrote the code that runs code_actions_on_format before the format steps specified in the "formatter" setting.

@MichaReiser
Copy link
Member

MichaReiser commented Nov 4, 2025

Where are you seeing this documentation @MichaReiser? I'd love to fix it. I wrote the code that runs code_actions_on_format before the format steps specified in the "formatter" setting.

Oh great! That's exactly what we need. The description is from Zed's on hover tooltip

Screenshot 2025-11-04 at 16 57 32

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@MichaReiser MichaReiser merged commit c6573b1 into astral-sh:main Nov 6, 2025
35 checks passed
@LoicRiegel LoicRiegel deleted the docs/update-zed-editor-support-instructions branch November 6, 2025 07:24
carljm added a commit to MatthewMckee4/ruff that referenced this pull request Nov 6, 2025
* main: (188 commits)
  [ty] Discover site-packages from the environment that ty is installed in (astral-sh#21286)
  [ty] Make special cases for `UnionType` slightly narrower (astral-sh#21276)
  Require ignore 0.4.24 in `Cargo.toml` (astral-sh#21292)
  [ty] Favour imported symbols over builtin symbols (astral-sh#21285)
  docs: revise Ruff setup instructions for Zed editor (astral-sh#20935)
  [ty] Update salsa (astral-sh#21281)
  [syntax-error]: no binding for nonlocal  PLE0117 as a semantic syntax error (astral-sh#21032)
  [ty] Constraining a typevar with itself (possibly via union or intersection) (astral-sh#21273)
  [`ruff`] Fix false positives on starred arguments (`RUF057`) (astral-sh#21256)
  [ty] Simplify unions containing multiple type variables during inference (astral-sh#21275)
  [ty] Add `ty_server::Db` trait (astral-sh#21241)
  [ty] Refactor `Range` to/from `TextRange` conversion as prep for notebook support (astral-sh#21230)
  [ty] Fix playground crash when file name includes path separator (astral-sh#21151)
  [`refurb`] Fix false negative for underscores before sign in `Decimal` constructor (`FURB157`) (astral-sh#21190)
  [ty] Allow values of type `None` in type expressions (astral-sh#21263)
  Run codspeed benchmarks with `profiling` profile (astral-sh#21261)
  [ty] Update expected diagnostic count in benchmarks (astral-sh#21269)
  Avoid extra parentheses for long `match` patterns with `as` captures (astral-sh#21176)
  [ty] Update salsa (astral-sh#21265)
  [ty] `dict` is not assignable to `TypedDict` (astral-sh#21238)
  ...
@probably-neb
Copy link

probably-neb commented Nov 6, 2025

Docs are fixed in zed-industries/zed#42128. Thanks all!

dcreager added a commit that referenced this pull request Nov 7, 2025
* origin/main:
  Remove duplicate preview tests for `FURB101` and `FURB103` (#21303)
  [ty] Add support for `Literal`s in implicit type aliases (#21296)
  [ty] Add missing `heap_size` to `variance_of` queries (#21318)
  [`pyupgrade`] Fix false positive on relative imports from local `.builtins` module (`UP029`) (#21309)
  [ty] Make range/position conversions fallible (#21297)
  Bump 0.14.4 (#21306)
  Fix main by using `infer_expression` (#21299)
  [ty] Understand legacy and PEP 695 `ParamSpec` (#21139)
  [ty] Discover site-packages from the environment that ty is installed in (#21286)
  [ty] Make special cases for `UnionType` slightly narrower (#21276)
  Require ignore 0.4.24 in `Cargo.toml` (#21292)
  [ty] Favour imported symbols over builtin symbols (#21285)
  docs: revise Ruff setup instructions for Zed editor (#20935)
  [ty] Update salsa (#21281)
  [syntax-error]: no binding for nonlocal  PLE0117 as a semantic syntax error (#21032)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants