-
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
ruff - formatter in neovim - how to FixAll? [question] #409
Comments
Not directly for none-ls but from conform.nvim (ruff installed via mason), but maybe it helps to solve this similarly to call ruff with the needed arguments: conform.setup({
formatters_by_ft = {
...
python = {
'ruff_fix', -- To fix lint errors. (ruff with argument --fix)
'ruff_format', -- To run the formatter. (ruff with argument format)
},
...
},
}) |
Hey, thanks for providing all the details. It helps in understanding the question :) I think there's a confusion here between the formatter and what Since you're using |
I understand difference between Do you think it would be an acceptable addition to I believe there are other LSPs that support that ( |
+1 to be able to invoke fixAll on save! |
I'm not familiar with neovim but Ruff-lsp supports format on save, but this is an action that needs to be triggered by the editor on save. I don't think there's even a way for us to implement |
I feel like the ask is more like a setting that makes the behavior happening during "format on save" to instead be the equivalent of the "fixAll" action. And/or format + organize imports. |
Do you mean to add a
Can you expand on what
This should be possible by requesting the code action to the server and applying the edit. The following can possibly be run on vim.lsp.buf.code_action {
context = {
only = { 'source.fixAll.ruff' },
},
apply = true,
} Refer to |
|
I have a keybinding to format:
and one for the Code Actions:
But I have to select manually to sort the imports or fix all. Is there a direct command I can call to only sort the imports instead? |
@steakhutzeee I've replied to your query over at #387 (comment) |
I wanted to be able to run vim.api.nvim_create_user_command(
'Ruff',
function()
vim.lsp.buf.code_action {
context = {
only = { 'source.fixAll.ruff' }
},
apply = true,
}
vim.lsp.buf.format { async = true }
end,
{ desc = "Reformat python with ruff" }
) |
Hello good people,
I am kinda new to ruff and neovim, so I could use some guidance how can i make sure that formatting is fixing all just like calling fixAll in ruff-lsp?
what in ruff formatter I have to set to fixAll by default?
It also does respect my
ruff.toml
but I cannot find anything about fixAll for formatter in here.Any chance somebody could tell me what I need to change either in my none-ls file or in ruff.toml please?
Thank you very much for all the help.
The text was updated successfully, but these errors were encountered: