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

Allow to query whether a path is ignored/When using rustfmt via stdin allow passing a path #5137

Open
Veykril opened this issue Dec 14, 2021 · 4 comments

Comments

@Veykril
Copy link
Member

Veykril commented Dec 14, 2021

In rust-analyzer we use rustfmt to format single files by passing the file content to it then writing the diff from that back to the file. This has the downside of us effectively ignoring the excluded paths from the rustfmt.toml.

Now we do not want to parse rustfmt.toml ourselves as this is basically duplicating work, hence the question arised whether it would be possible for rustfmt to either offer some way to ask for whether a path is excluded from it or even better to pass an optional path of a file as an argument when formatting via stdin input to have it basically do nothing if the path is ignored.

See rust-lang/rust-analyzer#10826

@calebcartwright
Copy link
Member

Still thinking on this.

I can't really rationalize modifying the CLI surface to accept a list of ignore files for the stdin formatting mode; it just doesn't make sense. I'd probably be open to an enhancement/augmentation to our existing config-print functionality that just dumps the resolved ignore list for a provided directory, though as was shared on your linked thread there's some bug fixes to that behavior that are still pending a backport.

@Veykril
Copy link
Member Author

Veykril commented Dec 21, 2021

Ye I can understand that this kind of option seems weird, I mainly proposed it as an idea(albeit an odd one maybe). Just having a way to query for the (resolved) ignored paths would probably be good enough for us in that case, since we do have the file path, we just do not want to look for and parse the rustfmt config ourselves.

@ytmimi
Copy link
Contributor

ytmimi commented Mar 15, 2022

Hey @Veykril just wanted to let you know that I worked on an implementation for this in #5266, to allow providing rustfmt with a hint about what's being passed via stdin.

@ytmimi ytmimi added the p-low label Jul 27, 2022
@calebcartwright
Copy link
Member

Cross referencing #5792 as it has some useful info imo to consider relative to implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants