I'm writing a color syntax highlighting file for a derivative of Pick Basic. Two of the oddities that this language allows is periods in variable names and embedding a keyword in a variable name, surrounding by periods. So for example, AND
is a keyword, but FOO.AND.BAR
is a variable name. I'd like to prevent the AND
in the middle of a variable name from being highlighted, but my attempts are failing.
I've defined my set of keywords as contained, but the container definition isn't working, and I'm not quite sure why.
Two different attempts (different keyword sets, but the same basic idea). The only difference in these two examples is that some builtin language functions contain periods (and thus need to be in the middle character class), while operators do not.
syn keyword universeBasicFunctionName ABORTM ABS ABSS ACOS ADDS ALL ALPHA AM ANDS ARG. ASCII ASIN ASSIGN ASSIGNED ATAN AUTHORIZATION contained
syn match universeBasicFunction /\M\( \)\@<=\zs[A-Z\.]\+\ze\([ (]\)\@=/ contains=universeBasicFunctionName
syn keyword universeBasicOperatorName AND EQ GT LT MATCH MATCHES NE NOT OFF ON OR contained
syn match universeBasicOperator /\(\.\)@<![A-Z]\+\(\.\)@!/ contains=universeBasicOperatorName
syn keyword
I think they should not match insideFOO.AND.BAR
. You can configure the syntax keyword definition using:syn iskeyword
setting:syn iskeyword syn iskeyword @,48-57,_,192-255,.
to make the.
part of a keyword match. I'll post an answer soon