stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.55k stars 135 forks source link

feature request: LSP fallback when formatting fails #437

Open abhinavnatarajan opened 1 month ago

abhinavnatarajan commented 1 month ago

Did you check existing requests?

Describe the feature

Fallback to LSP formatting if lsp_fallback is set to true and formatting fails.

Provide background

The current behaviour of conform.format({lsp_fallback = true}) is to fallback to LSP formatting only if there are no formatters available for the buffer. If a formatter is available, LSP fallback will not be used even if formatting fails.

What is the significance of this feature?

nice to have

Additional details

This is simple enough to implement using the callback feature of conform.format(), but I find the current behaviour unintuitive/surprising. It would be nice to have LSP fallback upon failure as default behaviour (assuming lsp_fallback = true).

stevearc commented 1 week ago

If your formatter fails, it usually indicates there is either something wrong with your formatter or the file you are formatting. In either case, it seems like you would typically want to fix the root problem. Do you have a common case where your formatter fails and you do not intend to fix it?

Michaelpalacce commented 5 days ago

This seems to happen a lot with bigger filex or with slower machines @stevearc I am having this issue quite a lot... When I do open a lot of projects conform is the first to start throwing, while without it things work fine