Hi,
On Mon, Dec 6, 2021 at 7:36 PM lacygoill <[email protected]> wrote:
> Thank you very much for all your work on this. I don't know whether it's
> planned at some point, but we can still not set an opfunc with a simple
> assignment in Vim9:
>
Thanks for testing this. Setting the 'opfunc', 'completefunc', etc. options
to a funcref
variable in a compiled Vim9 function is currently not supported.
Regards,
Yegappan
> vim9scriptnnoremap <expr> <F4><F4> <SID>CountSpaces() .. '_'def
> CountSpaces(type = ''): string
> if type == ''
> &operatorfunc = (t) => CountSpaces(t)
> return 'g@'
> endif
> normal! '[V']y
> echomsg getreg('"')->count(' ')
> return ''enddef'a b c d e'->setline(1)feedkeys("\<F4>\<F4>")
>
> E1012: Type mismatch; expected string but got func(any): string
>
> The issue comes from this line:
>
> &operatorfunc = (t) => CountSpaces(t)
>
> Which works in legacy:
>
> legacy let &operatorfunc = {t -> CountSpaces(t)}
>
> Test:
>
> vim9scriptnnoremap <expr> <F4><F4> <SID>CountSpaces() .. '_'def
> CountSpaces(type = ''): string
> if type == ''
> legacy let &operatorfunc = {t -> CountSpaces(t)}
> return 'g@'
> endif
> normal! '[V']y
> echomsg getreg('"')->count(' ')
> return ''enddef'a b c d e'->setline(1)feedkeys("\<F4>\<F4>")
>
> 4
>
> ------------------------------
>
> Also, still in Vim9, we can not use a partial; neither with :set:
>
> set operatorfunc=function(Zd,\ [cmd])
>
> Test:
>
> vim9scriptnnoremap <expr> zd <SID>ZdSetup('zd')def ZdSetup(cmd: string):
> string
> set operatorfunc=function(Zd,\ [cmd])
> return 'g@l'enddefdef Zd(cmd: string, type: string)
> execute 'normal! ' .. cmdenddefvar lines =<< trim END
> some folded lines {{{
> some folded lines
> some folded lines }}}
> ENDlines->setline(1)
> &foldmethod = 'marker'normal zd
>
> E121: Undefined variable: cmd
>
> nor with an assignment:
>
> &operatorfunc = function(Zd, [cmd])
>
> Test:
>
> vim9scriptnnoremap <expr> zd <SID>ZdSetup('zd')def ZdSetup(cmd: string):
> string
> &operatorfunc = function(Zd, [cmd])
> return 'g@l'enddefdef Zd(cmd: string, type: string)
> execute 'normal! ' .. cmdenddefvar lines =<< trim END
> some folded lines {{{
> some folded lines
> some folded lines }}}
> ENDlines->setline(1)
> &foldmethod = 'marker'normal zd
>
> E1012: Type mismatch; expected string but got func(...): unknown
>
>
>
--
--
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/CAAW7x7%3DSqkTG_0AGoOkWpannHnpyJczZd1TPYs6BQ18jL7FAYg%40mail.gmail.com.