runtime(vim): Update base-syntax, improve function definition matching

- Fix highlighting of function names including /fu\%[nction]/ (E.g.,
  s:func(), foo.fu(), fu.func())
- Match :delfunction argument.

Reported by Aliaksei Budavei.

closes: #17428

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-06-11 21:16:14 +02:00
committed by Christian Brabandt
parent 6cc9bd4001
commit 51289207f8
52 changed files with 868 additions and 467 deletions

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -1,2 +1,2 @@
highlight link vimVar Identifier
highlight link vimFuncScope Special
highlight link vimFunctionScope Special

View File

@ -0,0 +1,34 @@
" Vim :delfunction command
delfunction Foo
delfunction <SID>Foo
delfunction foo.bar
delfunction g:foo.bar
delfunction s:foo.bar
delfunction foo#bar
delfunction g:foo#bar
delfunction foo#bar.baz
delfunction g:foo#bar.baz
delfunction! Foo
delfunction! <SID>Foo
delfunction! foo.bar
delfunction! g:foo.bar
delfunction! s:foo.bar
delfunction! foo#bar
delfunction! g:foo#bar
delfunction! foo#bar.baz
delfunction! g:foo#bar.baz
delfunction Foo | echo "Foo"
delfunction Foo " comment
" Issue https://github.com/vim/vim/pull/17420#issuecomment-2927798687
" (arg named /fu%\[nction]/)
silent! delfunc! func

View File

@ -64,10 +64,48 @@ function <SID>Foo()
return 42
endfunction
function b:dict.Foo()
return 42
endfunction
function w:dict.Foo()
return 42
endfunction
function t:dict.Foo()
return 42
endfunction
function g:dict.Foo()
return 42
endfunction
function s:dict.Foo()
return 42
endfunction
function v:dict.Foo()
return 42
endfunction
function Foo(arg)
let l:dict = {}
function l:dict.BAR()
return 42
endfunction
function a:arg.BAR()
return 42
endfunction
endfunction
function foo#bar#Foo()
return 42
endfunction
function g:foo#bar#Foo()
return 42
endfunction
" same name as an Ex command
function s:ls()
endfunction
@ -152,6 +190,14 @@ function Foo(
return 42
endfunction
function Foo(
x,
y,
z,
...)
return 42
endfunction
function Foo(x, y = 42, z = "zed")
return 42
endfunction
@ -163,6 +209,13 @@ function Foo(
return 42
endfunction
function Foo(
x,
y = 42,
z = "zed")
return 42
endfunction
" arguments
@ -204,25 +257,9 @@ echo "Foo" | function Foo()
endfunction
" delete function
delfunction Foo
delfunction foo.bar
delfunction! Foo
delfunction foo.bar
" Issue https://github.com/vim/vim/pull/17420#issuecomment-2927798687
" (arg named /fu%\[nction]/)
" FIXME
silent! delfunc! func
" Issue https://github.com/vim/vim/pull/17420#issuecomment-2927798687
" (function named /s:fu%\[nction]/)
" FIXME
func! s:func(_, func)
return a:func
endfunc

View File

@ -66,10 +66,48 @@ function <SID>Foo()
return 42
endfunction
function b:dict.Foo()
return 42
endfunction
function w:dict.Foo()
return 42
endfunction
function t:dict.Foo()
return 42
endfunction
function g:dict.Foo()
return 42
endfunction
function s:dict.Foo()
return 42
endfunction
function v:dict.Foo()
return 42
endfunction
function Foo(arg)
let l:dict = {}
function l:dict.BAR()
return 42
endfunction
function a:arg.BAR()
return 42
endfunction
endfunction
function foo#bar#Foo()
return 42
endfunction
function g:foo#bar#Foo()
return 42
endfunction
" same name as an Ex command
function s:ls()
endfunction
@ -154,6 +192,14 @@ function Foo(
return 42
endfunction
function Foo(
x,
y,
z,
...)
return 42
endfunction
function Foo(x, y = 42, z = "zed")
return 42
endfunction
@ -165,6 +211,13 @@ function Foo(
return 42
endfunction
function Foo(
x,
y = 42,
z = "zed")
return 42
endfunction
" arguments
@ -179,6 +232,12 @@ function Foo(...)
endfunction
" Issue #16243 (Vim script def parameters syntax highlight is wrong)
function Test(lines = [line('.'), line('.')])
endfunction
" comments
function Foo()
@ -200,12 +259,12 @@ echo "Foo" | function Foo()
endfunction
" delete function
delfunction Foo
delfunction foo.bar
delfunction! Foo
delfunction foo.bar
" Issue https://github.com/vim/vim/pull/17420#issuecomment-2927798687
" (function named /s:fu%\[nction]/)
func! s:func(_, func)
return a:func
endfunc
" fold-region ending