mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
runtime(vim): Update base syntax, match "any" type distinctly
Allow for special highlighting of the "any" Vim9 type. Addresses comment https://github.com/vim/vim/pull/17722#issuecomment-3075531052 closes: #17769 Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
138381bde0
commit
97501afda3
@@ -2,7 +2,7 @@
|
|||||||
" Language: Vim script
|
" Language: Vim script
|
||||||
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
||||||
" Doug Kearns <dougkearns@gmail.com>
|
" Doug Kearns <dougkearns@gmail.com>
|
||||||
" Last Change: 2025 Jul 11
|
" Last Change: 2025 Jul 17
|
||||||
" Former Maintainer: Charles E. Campbell
|
" Former Maintainer: Charles E. Campbell
|
||||||
|
|
||||||
" DO NOT CHANGE DIRECTLY.
|
" DO NOT CHANGE DIRECTLY.
|
||||||
@@ -544,14 +544,15 @@ syn region vimReturnType contained
|
|||||||
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
|
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
|
||||||
|
|
||||||
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
|
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
|
||||||
syn keyword vimType contained any blob bool channel float job number string void
|
syn keyword vimType contained blob bool channel float job number string void
|
||||||
|
syn keyword vimTypeAny contained any
|
||||||
syn match vimType contained "\<\%(func\)\>"
|
syn match vimType contained "\<\%(func\)\>"
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
|
||||||
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
|
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
|
||||||
|
|
||||||
syn cluster vimType contains=vimType,vimCompoundType,vimUserType
|
syn cluster vimType contains=vimType,vimTypeAny,vimCompoundType,vimUserType
|
||||||
|
|
||||||
" Classes, Enums And Interfaces: {{{2
|
" Classes, Enums And Interfaces: {{{2
|
||||||
" =============================
|
" =============================
|
||||||
@@ -1063,7 +1064,8 @@ syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vim9VariableTyp
|
|||||||
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
|
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
|
||||||
|
|
||||||
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
|
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
|
||||||
syn keyword vim9VariableType contained any blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
|
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
|
||||||
|
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
|
||||||
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
|
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
|
||||||
syn region vim9VariableCompoundType contained
|
syn region vim9VariableCompoundType contained
|
||||||
\ matchgroup=vim9VariableType
|
\ matchgroup=vim9VariableType
|
||||||
@@ -1089,7 +1091,7 @@ syn region vim9VariableCompoundType contained
|
|||||||
\ transparent
|
\ transparent
|
||||||
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
|
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
|
||||||
|
|
||||||
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableCompoundType,vim9VariableUserType
|
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableTypeAny,vim9VariableCompoundType,vim9VariableUserType
|
||||||
|
|
||||||
" Lockvar and Unlockvar: {{{2
|
" Lockvar and Unlockvar: {{{2
|
||||||
" =====================
|
" =====================
|
||||||
@@ -2424,6 +2426,7 @@ if !exists("skip_vim_syntax_inits")
|
|||||||
hi def link vimThrow vimCommand
|
hi def link vimThrow vimCommand
|
||||||
hi def link vimTodo Todo
|
hi def link vimTodo Todo
|
||||||
hi def link vimType Type
|
hi def link vimType Type
|
||||||
|
hi def link vimTypeAny vimType
|
||||||
hi def link vimUniq vimCommand
|
hi def link vimUniq vimCommand
|
||||||
hi def link vimUniqBang vimBang
|
hi def link vimUniqBang vimBang
|
||||||
hi def link vimUniqOptions Special
|
hi def link vimUniqOptions Special
|
||||||
@@ -2514,6 +2517,7 @@ if !exists("skip_vim_syntax_inits")
|
|||||||
hi def link vim9TypeEquals vimOper
|
hi def link vim9TypeEquals vimOper
|
||||||
hi def link vim9Variable vimVar
|
hi def link vim9Variable vimVar
|
||||||
hi def link vim9VariableType vimType
|
hi def link vim9VariableType vimType
|
||||||
|
hi def link vim9VariableTypeAny vimType
|
||||||
hi def link vim9Var vimCommand
|
hi def link vim9Var vimCommand
|
||||||
hi def link vim9Vim9ScriptArg Special
|
hi def link vim9Vim9ScriptArg Special
|
||||||
hi def link vim9Vim9Script vimCommand
|
hi def link vim9Vim9Script vimCommand
|
||||||
|
20
runtime/syntax/testdir/dumps/vim9_types_00.dump
Normal file
20
runtime/syntax/testdir/dumps/vim9_types_00.dump
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
|
||||||
|
|#+0#0000e05&| |V|i|m|9| |t|y|p|e|s| +0#0000000&@62
|
||||||
|
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|T|y|p|e|A|n|y| |T|o|d|o| +0#0000000&@34
|
||||||
|
|#+0#0000e05&| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i| |l|i|n|k| |v|i|m|V|a|r|i|a|b|l|e|T|y|p|e|A|n|y| |T|o|d|o| +0#0000000&@26
|
||||||
|
@75
|
||||||
|
@75
|
||||||
|
|#+0#0000e05&| |b|u|i|l|t|i|n| |t|y|p|e|s| |(|d|i|s|t|i|n|c|t| |a|n|y| |h|i|g|h|l|i|g|h|t|i|n|g|)| +0#0000000&@31
|
||||||
|
@75
|
||||||
|
|v+0#af5f00255&|a|r| +0#0000000&|f|o@1|:| |b+0#00e0003&|o@1|l| +0#0000000&@61
|
||||||
|
|v+0#af5f00255&|a|r| +0#0000000&|b|a|r|:| |a+0#00e0003&|n|y| +0#0000000&@62
|
||||||
|
@75
|
||||||
|
|d+0#af5f00255&|e|f| +0#0000000&|F|o@1|(+0#e000e06&|a+0#0000000&|r|g|:| |b+0#00e0003&|o@1|l|)+0#e000e06&|:+0#0000000&| |b+0#00e0003&|o@1|l| +0#0000000&@50
|
||||||
|
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
|
||||||
|
@75
|
||||||
|
|d+0#af5f00255&|e|f| +0#0000000&|B|a|r|(+0#e000e06&|a+0#0000000&|r|g|:| |a+0#0000001#ffff4012|n|y|)+0#e000e06#ffffff0|:+0#0000000&| |a+0#0000001#ffff4012|n|y| +0#0000000#ffffff0@52
|
||||||
|
|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
|
||||||
|
@75
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
| +0#0000000&@56|1|,|1| @10|A|l@1|
|
17
runtime/syntax/testdir/input/vim9_types.vim
Normal file
17
runtime/syntax/testdir/input/vim9_types.vim
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
vim9script
|
||||||
|
# Vim9 types
|
||||||
|
# VIM_TEST_SETUP hi link vimTypeAny Todo
|
||||||
|
# VIM_TEST_SETUP hi link vimVariableTypeAny Todo
|
||||||
|
|
||||||
|
|
||||||
|
# builtin types (distinct any highlighting)
|
||||||
|
|
||||||
|
var foo: bool
|
||||||
|
var bar: any
|
||||||
|
|
||||||
|
def Foo(arg: bool): bool
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Bar(arg: any): any
|
||||||
|
enddef
|
||||||
|
|
@@ -2,7 +2,7 @@
|
|||||||
" Language: Vim script
|
" Language: Vim script
|
||||||
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
|
||||||
" Doug Kearns <dougkearns@gmail.com>
|
" Doug Kearns <dougkearns@gmail.com>
|
||||||
" Last Change: 2025 Jul 16
|
" Last Change: 2025 Jul 17
|
||||||
" Former Maintainer: Charles E. Campbell
|
" Former Maintainer: Charles E. Campbell
|
||||||
|
|
||||||
" DO NOT CHANGE DIRECTLY.
|
" DO NOT CHANGE DIRECTLY.
|
||||||
@@ -598,14 +598,15 @@ syn region vimReturnType contained
|
|||||||
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
|
syn match vimParamType contained ":\s" skipwhite skipnl nextgroup=@vimType contains=vimTypeSep
|
||||||
|
|
||||||
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
|
syn match vimTypeSep contained ":\%(\s\|\n\)\@=" skipwhite nextgroup=@vimType
|
||||||
syn keyword vimType contained any blob bool channel float job number string void
|
syn keyword vimType contained blob bool channel float job number string void
|
||||||
|
syn keyword vimTypeAny contained any
|
||||||
syn match vimType contained "\<\%(func\)\>"
|
syn match vimType contained "\<\%(func\)\>"
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<func(" end=")" nextgroup=vimTypeSep contains=@vim9Continue,@vimType transparent
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<tuple<" end=">" contains=@vim9Continue,@vimType transparent
|
||||||
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
|
syn region vimCompoundType contained matchgroup=vimType start="\<\%(list\|dict\)<" end=">" contains=@vimType oneline transparent
|
||||||
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
|
syn match vimUserType contained "\<\%(\h\w*\.\)*\u\w*\>"
|
||||||
|
|
||||||
syn cluster vimType contains=vimType,vimCompoundType,vimUserType
|
syn cluster vimType contains=vimType,vimTypeAny,vimCompoundType,vimUserType
|
||||||
|
|
||||||
" Classes, Enums And Interfaces: {{{2
|
" Classes, Enums And Interfaces: {{{2
|
||||||
" =============================
|
" =============================
|
||||||
@@ -1119,7 +1120,8 @@ syn match vim9Variable contained "\<\h\w*\>" skipwhite nextgroup=vim9VariableTyp
|
|||||||
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
|
syn region vim9VariableList contained start="\[" end="]" contains=@vimContinue,@vimSpecialVar,vim9Variable skipwhite nextgroup=vimLetHeredoc
|
||||||
|
|
||||||
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
|
syn match vim9VariableTypeSep contained "\S\@1<=:\%(\s\|\n\)\@=" skipwhite nextgroup=@vim9VariableType
|
||||||
syn keyword vim9VariableType contained any blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
|
syn keyword vim9VariableType contained blob bool channel float job number string void skipwhite nextgroup=vimLetHeredoc
|
||||||
|
syn keyword vim9VariableTypeAny contained any skipwhite nextgroup=vimLetHeredoc
|
||||||
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
|
syn match vim9VariableType contained "\<\%(func\)\>" skipwhite nextgroup=vimLetHeredoc
|
||||||
syn region vim9VariableCompoundType contained
|
syn region vim9VariableCompoundType contained
|
||||||
\ matchgroup=vim9VariableType
|
\ matchgroup=vim9VariableType
|
||||||
@@ -1145,7 +1147,7 @@ syn region vim9VariableCompoundType contained
|
|||||||
\ transparent
|
\ transparent
|
||||||
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
|
syn match vim9VariableUserType contained "\<\%(\h\w*\.\)*\u\w*\>" skipwhite nextgroup=vimLetHeredoc
|
||||||
|
|
||||||
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableCompoundType,vim9VariableUserType
|
syn cluster vim9VariableType contains=vim9VariableType,vim9VariableTypeAny,vim9VariableCompoundType,vim9VariableUserType
|
||||||
|
|
||||||
" Lockvar and Unlockvar: {{{2
|
" Lockvar and Unlockvar: {{{2
|
||||||
" =====================
|
" =====================
|
||||||
@@ -2486,6 +2488,7 @@ if !exists("skip_vim_syntax_inits")
|
|||||||
hi def link vimThrow vimCommand
|
hi def link vimThrow vimCommand
|
||||||
hi def link vimTodo Todo
|
hi def link vimTodo Todo
|
||||||
hi def link vimType Type
|
hi def link vimType Type
|
||||||
|
hi def link vimTypeAny vimType
|
||||||
hi def link vimUniq vimCommand
|
hi def link vimUniq vimCommand
|
||||||
hi def link vimUniqBang vimBang
|
hi def link vimUniqBang vimBang
|
||||||
hi def link vimUniqOptions Special
|
hi def link vimUniqOptions Special
|
||||||
@@ -2576,6 +2579,7 @@ if !exists("skip_vim_syntax_inits")
|
|||||||
hi def link vim9TypeEquals vimOper
|
hi def link vim9TypeEquals vimOper
|
||||||
hi def link vim9Variable vimVar
|
hi def link vim9Variable vimVar
|
||||||
hi def link vim9VariableType vimType
|
hi def link vim9VariableType vimType
|
||||||
|
hi def link vim9VariableTypeAny vimType
|
||||||
hi def link vim9Var vimCommand
|
hi def link vim9Var vimCommand
|
||||||
hi def link vim9Vim9ScriptArg Special
|
hi def link vim9Vim9ScriptArg Special
|
||||||
hi def link vim9Vim9Script vimCommand
|
hi def link vim9Vim9Script vimCommand
|
||||||
|
Reference in New Issue
Block a user