stevearc / conform.nvim

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

feature request: format git-hunks only #371

Closed becknik closed 3 months ago

becknik commented 3 months ago

Did you check existing requests?

Describe the feature

It'd be really nice to have an option to just format the lines in the buffer which are indexed by git or aren't in stage yet.

I've thought about an additional property in the opt attribute of the format_on_save function, to just run the formatting on git hunks if enabled.

Certainly, this could be out of scope for this plugin. But I'm not really sure how to implement this feature myself just using your API & Lua...

Provide background

When working on projects a style guide wasn't established to a certain point, I'd be nice to gradually format the source code without loosing track of the file blames by reformatting the whole project code at once.

Also, I'd like to avoid covering the blame/hunks of my team comrades with my auto-formatting, when they disobey the style guide due to laziness/ by accident or whatever reason there is.

What is the significance of this feature?

nice to have

Additional details

No response

stevearc commented 3 months ago

Duplicate of #92. There's a workaround posted there, as well as some more context.