I am trying to make an angularjs syntax highlighting file for vim. A piece of the file is:
syn match ngMethods /\.[0-9A-Za-z_\-\$]\+\s*\((\|=\)/ contains=AngularMethods
syn keyword AngularMethods contained $addControl $anchorScroll $animate ...
syn match ngObjMethods /^\s*[0-9A-Za-z_\-\$]\+\s*:/ contains=AngularObjectMethods
syn keyword AngularObjectMethods contained compile controller link ...
etc...
Down below I have:
hi def link AngularMethods Function
hi def link AngularObjectMethods Function
The first regular expression (for AngularMethods
) is supposed to capture things like $addControl
in the following:
myelement.$addControl()
myelement.$addControl = function ()
The second regular expression (for AngularObjectMethods
) captures things like compile
in:
compile : function () {}
The AngularMethods
one does NOT work but the latter one does. Can anyone see the problem? I've also tried using the regexes:
/\.\zs[0-9A-Za-z_\-\$]\+\ze\s*\((\|=\)/
/\.[0-9A-Za-z_\-\$]\+\s*\((\|=\)\@=/
The former matches the exact word. The latter is something I saw in another syntax file. Any ideas? Thanks for your help!
Edit:
Kent (below) was correct about the keyword. This uncovered the real problem which is that I have another regex:
syn match ngProperties /\.[0-9A-Za-z_\-\$]\+\s*[^(=]/ contains=AngularProperties
syn keyword AngularProperties contained $attr $dirty $error ...
which is supposed to be the complement of the ngMethods regex. If I comment out the ngProperties
regex, the ngMethods
regex works. This means ngProperties
is bad. It is supposed to catch things like $attr
in:
var myAttribute = element.$attr;
I will try to fix this. Can someone post the correct regex just in case?