Ok, for visual mode I had to redefine `gq`
vim9script
import autoload 'dist/json.vim'
setl formatexpr=json.FormatExpr()
xnoremap <buffer> gq <scriptcmd>json.Format(line('v'), line('.'))<CR>
суббота, 5 ноября 2022 г. в 21:49:54 UTC+5, Maxim Kim:
> > It would be good to review, have others make comments.
> > A PR should work for that.
>
> https://github.com/vim/vim/pull/11506
>
> Hopefully other people will try it and improve if needed.
>
> * It doesn't handle escapes of \" and I don't know if json allows it
> actually
> * {Visual}gq doesn't work and I am not sure how formatexpr should look like
>
> суббота, 5 ноября 2022 г. в 20:35:19 UTC+5, Bram Moolenaar:
>
>>
>> > Oh, `formatexpr` can't speak vim9script!
>> >
>> > ```
>> > setl formatexpr=json#FormatExpr()
>> > ```
>> >
>> > Works!
>> >
>> > @brammool I can create a PR if needed.
>>
>> It would be good to review, have others make comments.
>> A PR should work for that.
>>
>> I suppose including the script under autoload/dist works, then those who
>> want to use it can set 'formatexpr' as you mentioned, with a filetype
>> autocmd. If it works really well we could do it in the json filetype
>> plugin. I suppose we would somehow need to vote about that.
>>
>> --
>> Anyone who is capable of getting themselves made President should on no
>> account be allowed to do the job.
>> -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
>>
>> /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net
>> \\\
>> /// \\\
>> \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
>> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>>
>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/800a8994-b9ee-4f5f-9d28-84cf199cceb1n%40googlegroups.com.