rust-lang / rust-lang/rust-analyzer

Request: format sniffer => format_on_save = auto

Open
#10,728 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

We could set format on save based on if the currently loaded project is rust formatted.

We could format a few files with rustfmt and see if there's any difference. If so we conclude that it's not a formatted project and have format on save off by default.

For people flipping between projects this would be really nice. At the moment the nearest in vscode is an extension called "Format toggle" which allows us to manually flip it.

But it would be really cool if we could sniff and do the right thing. One negative .rs file would be enough to know format shouldn't be used on this project. Trialing the first .rs file you come across is probably enough for this feature to work pretty well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing format-on-save setting and the rustfmt integration for a loaded project. Investigate how to inspect an initial .rs file, compare its formatting, and handle projects with mixed files. Done means the default format-on-save behavior is selected per project without requiring a manual toggle.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.