stevearc / conform.nvim

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

Possible for formatters with function-defined configuration to only be called once per format? #367

Open scienceplease opened 4 months ago

scienceplease commented 4 months ago

Did you check existing requests?

Describe the feature

Formatters whose configuration is defined as a function get called twice upon every actual format. I'm not certain whether or not this can be avoided per the design of conform, but it can introduce unintended behavior whenever the dynamic configuration has side-effects or requires some notable overhead (e.g. searching directories for files). If it cannot be avoided, it's probably worth mentioning in the documentation.

Thanks for the awesome plugin!

Provide background

No response

What is the significance of this feature?

nice to have

Additional details

No response

stevearc commented 3 months ago

This not necessarily an intentional piece of the design of conform, but I have intentionally not attempted to change it. These functions should be deterministic, and I expect the overall performance of formatting will be dominated by the formatter itself rather than anything in these. Caching is tricky to do correctly and I don't want to put any work into this until it causes at least one issue in the wild.