mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 20:18:32 +00:00
vim-patch:8.2.3619: cannot use a lambda for 'operatorfunc' (#19846)
Problem: Cannot use a lambda for 'operatorfunc'.
Solution: Support using a lambda or partial. (Yegappan Lakshmanan,
closes vim/vim#8775)
777175b0df
Omit duplicate docs. It's removed in patch 8.2.3623.
Nvim doesn't seem to need callback_set() as it was omitted when patch 8.1.1437
was first ported.
This commit is contained in:
@@ -905,6 +905,17 @@ or `unnamedplus`.
|
||||
The `mode()` function will return the state as it will be after applying the
|
||||
operator.
|
||||
|
||||
Here is an example for using a lambda function to create a normal-mode
|
||||
operator to add quotes around text in the current line: >
|
||||
|
||||
nnoremap <F4> <Cmd>let &opfunc='{t ->
|
||||
\ getline(".")
|
||||
\ ->split("\\zs")
|
||||
\ ->insert("\"", col("'']"))
|
||||
\ ->insert("\"", col("''[") - 1)
|
||||
\ ->join("")
|
||||
\ ->setline(".")}'<CR>g@
|
||||
|
||||
==============================================================================
|
||||
2. Abbreviations *abbreviations* *Abbreviations*
|
||||
|
||||
|
@@ -312,6 +312,17 @@ Note: In the future more global options can be made |global-local|. Using
|
||||
":setlocal" on a global option might work differently then.
|
||||
|
||||
|
||||
*option-value-function*
|
||||
Some options ('completefunc', 'imactivatefunc', 'imstatusfunc', 'omnifunc',
|
||||
'operatorfunc', 'quickfixtextfunc' and 'tagfunc') are set to a function name
|
||||
or a function reference or a lambda function. Examples:
|
||||
>
|
||||
set opfunc=MyOpFunc
|
||||
set opfunc=function("MyOpFunc")
|
||||
set opfunc=funcref("MyOpFunc")
|
||||
set opfunc={t\ ->\ MyOpFunc(t)}
|
||||
<
|
||||
|
||||
Setting the filetype
|
||||
|
||||
:setf[iletype] [FALLBACK] {filetype} *:setf* *:setfiletype*
|
||||
@@ -4402,7 +4413,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
'operatorfunc' 'opfunc' string (default: empty)
|
||||
global
|
||||
This option specifies a function to be called by the |g@| operator.
|
||||
See |:map-operator| for more info and an example.
|
||||
See |:map-operator| for more info and an example. The value can be
|
||||
the name of a function, a |lambda| or a |Funcref|. See
|
||||
|option-value-function| for more information.
|
||||
|
||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||
security reasons.
|
||||
@@ -4696,8 +4709,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
customize the information displayed in the quickfix or location window
|
||||
for each entry in the corresponding quickfix or location list. See
|
||||
|quickfix-window-function| for an explanation of how to write the
|
||||
function and an example. The value can be the name of a function or a
|
||||
lambda.
|
||||
function and an example. The value can be the name of a function, a
|
||||
|lambda| or a |Funcref|. See |option-value-function| for more
|
||||
information.
|
||||
|
||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||
security reasons.
|
||||
|
Reference in New Issue
Block a user