I’m working on plugins for the Swift language. As part of another feature, I’ve managed to load the compiler in-process and can run arbitrary queries to the compiler about the current buffer.
It occurs to me, now that I’ve set this up, it would be a convenient way to power syntax highlighting. After all, the compiler is the “final authority” about whether foo
is a keyword or not. Moreover, Swift is a hard language to parse, the language is in a state of flux right now, and the parser changes almost weekly if you’re running the compiler out of master. (And if you are not, well, your syntax highlighting should be different than mine, but which definition should I distribute in the plugin?)
Is there any API I could use to just “assign” syntax highlighting scopes to the current buffer? I would prefer to just foist the compiler’s opinion of how to parse the language instead of writing a language definition that will go out of date as soon as it is written, and is already wrong for users with older language versions.