formatprg in my vimrc to use the par text formatter when I type
setg formatprg=par\ -w90
When I'm in a buffer whose
textwidth has been set (e.g. the gitcommit filetype sets
textwidth=72), I'd like to use that number rather than 90.
Instead of hard-coding different values in a bunch of ftplugin files, I'd like to compute the number dynamically upon usage.
I took a look at
formatexpr, but if I set a formatexpr it would also be called whenever I enter characters beyond the textwidth line length, and I don't think I'd want to call out to an external process that frequently.
The only other solutions I can think of are writing a wrapper around
gq (which I imagine would get complex if I want to support operating-pending mode correctly) and adding an autocmd that listens for the Filetype event and sets
formatprg appropriately. That last solution seems the most reasonable, actually.
I'm curious if there's another option I'm overlooking?