Trying to create a simple syntax highlighting for a special file type we use. within this file there are simple functions defined which I match using keywords:

syn keyword Funcs foo bar baz
hi def link Func Special 

The functions can take arguments which are type-less: foo(arg1, arg2, arg3) The keywords take care of coloring the function name + parentheses but not the arguments. I would like to get those colored but cannot seem to get it to work. Tried with :

syn keyword Funcs foo bar baz contains=arguments
syn match arguments "(\s*\w\+,*)\+" contained
hi def link Func Special 
hi def link arguments Type

What am I missing here?

  • The contains shouldn't be used. A keyword is a keyword, it doesn't match anything before or after it. I think there's an option to match the following part as something, but I don't recall what it is. Maybe matching a region that covers both the function and arguments, and then including the keyword and argument highlighting in it, might be better. – muru Apr 12 '17 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.