stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.72k stars 142 forks source link

feature request: Provide way to toggle autoformat on save #376

Closed daniele821 closed 3 months ago

daniele821 commented 3 months ago

Did you check existing requests?

Describe the feature

Providing a command to toggle Formatting on save, or even also just a global boolean variable which we can use in in our config to toggle formatting on save.

And this command/variable should only affect formatting on save autocmd, thus if i press leader+f, I should still be able to format.

Provide background

Currently, when i edit a file in lua i have stylua declared as a formatter, and lsp_fallback set to true. Sometimes i want to edit files which have different formatting, without changing the formatting. At the moment, I either do :noautocmd w everytime i save, which works, but it also disables ALL autocmd which run on save (linters for example), or i go in the config and temporarely remove stylua as a formatter for lua and set lsp_fallback to false (which is crazy to do everytime).

What is the significance of this feature?

cannot use this plugin without it

Additional details

I am open to discussion, as i really like this plugin, and this is the one thing which really makes it hard for me to use it. Thanks!

christianlegge commented 3 months ago

This is quite easy to add yourself, as outlined in the recipes doc: https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-format-on-save

stevearc commented 3 months ago

The linked recipe is the official way to do toggling of format-on-save

daniele821 commented 3 months ago

thanks!