To have configVar
match inside configValue
, you have to contain it; this is done via the contained
(leave this off if the var can also match anywhere, not just inside key=value) and contains=...
attributes:
syn match configValue "\(\S\+=\)\@<=\"[^\"]*\"\|\(\S\+=\)\@<=\S\+" contains=configVar
syn match configVar "\$([^)]*)" contained
Note that I've changed the pattern for configVar
to avoid matching $(foo) and $(bar)
as one element.
You said that configVar
can also appear in configKey
, but for that, the range of allowed characters needs to include $()
, too. Then, the containment works just as well:
syn match configKey "^\s*[a-zA-Z0-9_.$()]\+\(\s*=\)\@=" contains=configVar