Вопрос

I am trying to build my own Objective-C highlighting scheme for vim. The problem is that when I define some rule with contained it still being applied even if there are no rules containing this one. I have this in my objc.vim for test purposes:

syntax clear
runtime! syntax/c.vim
syn match firstComponent "[_A-Za-z0-9()]*:" contained
hi link firstComponent Function

I suspect this is because c.vim has a lot of rules with contained=ALLBUT so they include my rule as well. Are there ways to work around this?

Thanks.

PS I am building my own scheme to highlight methods because the one I was using before is slow, in particular method signature matching is slow, I've made a reduction that shows that. I suspect this could be because of the problem above. Complicated inner rules get matched everywhere.

Это было полезно?

Решение

Your hunch is right, this is due to contained=ALLBUT. There are limits to reusing an existing syntax. Though you can try to override or :syntax clear certain elements, there comes a point where this becomes overly tedious.

If the original syntax author is still maintaining his syntax, you can discuss this, and submit patches to ease integration, or maybe even completely split off a common sub-syntax that you can then use to base yours on. If that's not the case, or the coupling is undesired, you'd better start creating your own, completely separate syntax, even if that means some duplication.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top