mhartington/formatter.nvim

Support synchronous formatting

Opened this issue · 2 comments

calops commented

I know, this has already been requested before (#108), and at the time it was judged better to implement locking formatting instead (#175), to prevent inadvertent buffer modification.

I do think however that there's still a use-case for synchronous formatting that isn't covered otherwise by the available options. When I save my file, my LSP is running diagnostics on everything. This can be a heavy process that takes a while. If the formatting happens after the writing, then the diagnostics won't correspond to the lines in my buffer, unless I save again (and start the whole checking process again, making the feedback loop even longer).

So, in order to have a proper BufWritePre hook that formats before anything is saved, synchronous formatting is the only solution I see.

I'll understand if you think this is out of scope for this plugin, but I thought I would offer another perspective for how this feature that almost got implemented (#109) could be useful.

Yeah I would still like this too - it's quite annoying to have to run the formatter twice and not supporting formatting on :x/:wq is a PITA too.

Any updates here? Support for BufWritePre would be awesome to avoid having to double undo.