Miek Gieben, Wed 2012-09-19 @ 15:53:49+0200:
In specific cases, like in your Go data type example, you could probably
get by with a lot less than a full parser, using regex matches and other
heuristics. But in the general case, as in, if we wanted to add support
for language grammar-based highlighting for arbitrary grammatical
constructs in arbitrary languages, I don't think you could get away with
anything less than actually parsing the language.
Omnicompletion is an example of the "specific cases" approach. In the
handful of languages that actually have omnicompletion support, we are
not, as far as I am aware, actually parsing the language fully, but
rather using clever searches and other "tricks" to approximate a parser
as far as the completion features actually require it. This kind of
technique can only take you so far, though, and if you propose
highlighting based on grammar, then unlike completion, that would
potentially affect the appearance of every token in every buffer in that
language, and thus we couldn't really just "skip over" complexity and
make do with a partial implementation.
That said, I am also far from an expert on Vim internals, so anyone who
can prove me wrong should feel free to do so. :)