I am trying to come up with a vim syntax for python function call, e.g.
foo(notarg==0, arg2, kwarg='a', kwarg2='b') dict(a=1, b=2, c=3)
where we want to highlight
- (i) function name
- (ii) keyword parameters, e.g.
I know there is a great answer on a similar question. To repeat:
syn region FCall matchgroup=FName start='[[:alpha:]_]\i*\s*(' end=')' contains=FCall,FCallKeyword syn match FCallKeyword /\i*\ze\s*=[^=]/ contained
Or, alternatively, in my own vim syntax file for python, I could manage to achieve a similar behavior:
syn match pythonCall /\<\h\i*\ze\s*(/ contains=pythonBuiltin,pythonBuiltinFunc,pythonBuiltinType \ nextgroup=pythonCallRegion skipwhite keepend syn region pythonCallRegion contained matchgroup=pythonParamsDelim start=/(/ end=/)/ keepend extend \ contains=pythonCallComma,pythonCall,@pythonCallArgument,pythonCallArgKeyword syn match pythonCallArgKeyword contained /\h\i*\ze\s*==\@!/
However, the problem is that when a previously existing syntax group (e.g.
pythonBuiltinType) matches function name, the entire highlight for keyword arguments would not work:
where we have the following highlighting rule somewhere (e.g. python-mode)
syn keyword pythonBuiltinType dict ....
pythonBuiltinType, but not matches
pythonCall. This happens for the both ways I just described. A screenshot:
What did I wrong here? Vim syntax is quite difficult, so your help would be greatly appreciated.