我有一个具有以下定义的语法文件:
syn keyword pythonBuiltinFunc __import__ abs all any
\ bin bool bytearray
\ callable chr classmethod compile complex
\ delattr dict dir divmod
\ enumerate eval
\ filter float format frozenset
\ getattr globals hasattr hash hex
\ id input int isinstance issubclass iter
\ len list locals
\ map max min next
\ object oct open ord pow property
\ range repr reversed round
\ set setattr slice sorted
\ staticmethod str sum super
\ tuple type vars zip
\ nextgroup=pythonArgs skipwhite
问题在于,即使该名称被引用为对象的属性(例如next
),它也会匹配obj.next
的出现(例如),这会使高亮显示混乱。
虽然我可能会买到不要掩盖内置名称很有用,但我不确定我是否会为有界名称购买。
有没有人对如何应用上述定义有想法,但排除了我在下面提到的病理情况?我想我会在单词模式中允许使用空格,但是在比赛中忽略了它?
答案 0 :(得分:0)
为了使用Vim的语法包含规则排除那些内置于对象属性中的内建函数,您必须定义一个模式来检测对象。我想那是不可能的。
这样就可以将这些关键字转换为:syntax match
并向其中添加 lookbehind断言,以避免像obj.builtin
那样进行匹配,如下所示:
:syntax match pythonBuildinFunc "\.\@<!\<next\>"