Conversation
dbarnett
left a comment
There was a problem hiding this comment.
I like providing a simple hook for people who want to override formatexpr and an example of how. It would be pretty aggressive behavior to unconditionally override formatexpr, though. Could be based on a setting, but for things like this it's usually more flexible and less brittle to provide the pieces and let the user hook it up themselves. For instance, if they wanted to override formatexpr for some but not all filetypes, they'd come asking how to adapt this to do what they wanted and we wouldn't have a simple clean way to offer them.
What do you think about changing it so the autocmd is in your vimrc and just calls a simple codefmt helper?
dbarnett
left a comment
There was a problem hiding this comment.
I think it needs to be opt-in. See my previous longer comment in Conversation.
|
Removed autocmd from mappings file, PTAL |
dbarnett
left a comment
There was a problem hiding this comment.
LG to merge besides getting the functions into the generated help docs. LMK if you need any help with that part.
| if !empty(get(b:, 'codefmt_formatter')) | ||
| let l:Predicate = {f -> f.name ==# b:codefmt_formatter} | ||
| else | ||
| let l:Predicate = {f -> f.AppliesToBuffer() && s:IsAvailable(f)} | ||
| endif |
There was a problem hiding this comment.
For reference: We haven't been using lambdas in any of our plugins yet, but I checked and they were originally added in 7.4.2044 from 2016. That's probably long enough ago. At some point I should probably declare a min supported vim version for the plugin and get it testing against that version, though.
| endfunction | ||
|
|
||
| "" | ||
| " Returns whether there is a default formatter available for the current |
There was a problem hiding this comment.
Could you make this @public and regenerate the vimdoc?
It should have a sample of how to use it somewhere in the help docs, but for that part I'm happy to merge it w/o and add the docs after.
Signed-off-by: Ari Archer <truncateddinosour@gmail.com>
|
Thanks!
Looks like the autocmd is still in the mappings file? I'd suggest to instead restructure a bit to define a augroup codefmt_formatexpr
autocmd!
autocmd BufEnter * call codefmt#SetFormatExprIfAvailable()
augroup END |
No description provided.