diff options
-rw-r--r-- | runtime/doc/options.txt | 15 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 2 | ||||
-rw-r--r-- | test/old/testdir/test_ins_complete.vim | 17 |
3 files changed, 29 insertions, 5 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index c8d4bea5a8..875767283a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -384,15 +384,22 @@ the name, e.g. "<lambda>123". Examples: set opfunc=function('MyOpFunc') set opfunc=funcref('MyOpFunc') set opfunc={a\ ->\ MyOpFunc(a)} - " set using a funcref variable + +Set to a script-local function: > + set opfunc=s:MyLocalFunc + set opfunc=<SID>MyLocalFunc + +Set using a funcref variable: > let Fn = function('MyTagFunc') let &tagfunc = Fn - " set using a lambda expression + +Set using a lambda expression: > let &tagfunc = {t -> MyTagFunc(t)} - " set using a variable with lambda expression + +Set using a variable with lambda expression: > let L = {a, b, c -> MyTagFunc(a, b , c)} let &tagfunc = L -< + Setting the filetype diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 42391ecec7..ab8e67016f 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2084,7 +2084,7 @@ char *get_scriptlocal_funcname(char *funcname) if (strncmp(funcname, "s:", 2) != 0 && strncmp(funcname, "<SID>", 5) != 0) { - // The function name is not a script-local function name + // The function name does not have a script-local prefix. return NULL; } diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index 882e707f63..b90c0013d9 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -1691,6 +1691,23 @@ func Test_completefunc_callback() bw! delfunc s:CompleteFunc3 + " In Vim9 script s: can be omitted + let lines =<< trim END + vim9script + var CompleteFunc4Args = [] + def CompleteFunc4(findstart: bool, base: string): any + add(CompleteFunc4Args, [findstart, base]) + return findstart ? 0 : [] + enddef + set completefunc=CompleteFunc4 + new + setline(1, 'script1') + feedkeys("A\<C-X>\<C-U>\<Esc>", 'x') + assert_equal([[1, ''], [0, 'script1']], CompleteFunc4Args) + bw! + END + call CheckScriptSuccess(lines) + " invalid return value let &completefunc = {a -> 'abc'} call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x') |