Reputation: 2082
I have a syntaxfile for highlighting awk embedded in bash script:
syn include @AWKScript syntax/awk.vim
syn region AWKScriptCode matchgroup=AWKCommand
\ start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains @AWKScript contained
syn region AWKScriptEmbedded matchgroup=AWKCommand
\ start=+\<\(g\?awk\|\$AWK\)\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1
\ contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
syn cluster shCommandSubList add=AWKScriptEmbedded
hi def link AWKCommand Type
The problem is with this section:
start=+\<\(g\?awk\|\$AWK\)\>+
It works fine for awk and gawk, but not for $AWK. How can I add a rule to match $AWK as a starting pattern for the AWKScriptEmbedded region?
Upvotes: 3
Views: 1396
Reputation: 172728
The problem is that the $AWK
is already highlighted by the shDerefSimple
syntax group, so your new region isn't applied. Split the syntax definition into two parts and add the containedin=
for the latter:
syn region AWKScriptEmbedded matchgroup=AWKCommand
\ start=+\<g\?awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1
\ contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
syn region AWKScriptEmbedded matchgroup=AWKCommand
\ start=+\$AWK\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1
\ contains=@shIdList,@shExprList2 containedin=shDerefSimple nextgroup=AWKScriptCode
Upvotes: 3