-
Notifications
You must be signed in to change notification settings - Fork 46
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
FR: Integrate organizeImport
, fixAll
into formatting
#335
Comments
Thanks! Are you imaging a dedicated code action for this, or a setting to make the format action do "everything"? |
because of the drawbacks of code actions (e.g. no async), I think adding as an opt-in setting to formatting would be preferable? |
I can see how it makes sense to run I don't recommend integrating fix all into formatting. Fixing can create semantic changes. I would rather push for the opposite, considering to integrate |
I mean, making it an opt-in setting, leaving it to the user to decide cannot really hurt?
In my personal opinion, if something can introduce semantic changes, it should not have a fix code action to begin with, as it can easily mislead less experienced users?
In theory it does not make a difference which way to go, but using a code action instead of formatting has some disadvantages, such not being able to run async (see #93 for the problems this can entail). |
I'm interested in a solution here as well. My current workflow has me using a nice keybind for running I don't want to speak for what I think would be best for a certain type of user, but I know I'd love it if it all happened in a single command as someone who just compulsively spans format while refactoring. |
astral-sh/ruff#8232 is relevant here. |
any update on this? |
Right now,
ruff format
/textDocument/formatting
apply formatting, whileorganizeImports
andfixAll
are available independently, e.g. as code actions.I think it would make sense to have the option to run all three (organizeImports, fixAll, formatting) with one command by integrating the former two into the formatting capabilities. Combining import-sorting and formatting is not uncommon, a few formatters like for example stylua already do that.
Currently, doing that in ruff requires a bunch of workarounds (see e.g., #119 or #95), which have some minor hiccups as LSP code actions cannot be run async (#95). Implementing this would thus make ruff more accessible to newcomers who just need to set one toggle instead of finding a workaround in the GitHub issues.
The text was updated successfully, but these errors were encountered: