Here is what I got so far:
syntax match cfg_Comment '
syntax match cfg_DocTag '
highlight default link cfg_Comment Comment
highlight default link cfg_DocTag SpecialComment
Works well for something like:
Next, I want to highlight the next word after @typeusing a group Type. So I did the following:
syntax match cfg_Comment '
syntax match cfg_DocTag '
syntax match cfg_DocTag_type '@type' containedin=cfg_DocTag nextgroup=cfg_DocField_type skipwhite
syntax match cfg_DocField_type '\a\+' contained
highlight default link cfg_Comment Comment
highlight default link cfg_DocTag SpecialComment
highlight default link cfg_DocField_type Type
There are 2 problems with this:
- Now it
@typedoesn’t highlight, and I get it, because obviously I didn’t show the group to it, but I expected it to inherit the color from its parent container cfg_DocTag. - Of course, now everything in the comments has a color
Type, not just the word after @type, and I get it again because I indicated that it cfg_Commentis a container cfg_DocField_type.
I know where the problems arise, but I don’t know how to solve them gracefully and write code as conditional as possible.
, - ,
syntax match cfg_DocTag_type '@type' containedin=cfg_DocTag nextgroup=cfg_DocField_type skipwhite
syntax keyword cfg_DocTag_type @type containedin=cfg_DocTag nextgroup=cfg_DocField_type skipwhite
? , : @type , , . , , , , . :
Update
Ingo . , ?
syntax match cfg_Comment '
syntax match cfg_DocTag '
syntax match cfg_DocTag_type '@type' transparent containedin=cfg_DocTag nextgroup=cfg_DocField_type skipwhite
syntax match cfg_DocField_type '\a\+' contained
highlight default link cfg_Comment Comment
highlight default link cfg_DocTag SpecialComment
highlight default link cfg_DocField_type Type
, . . @ Type , .. . cfg_DocField_type ? ?