javascript-libraries-syntax.vim
javascript-libraries-syntax.vim copied to clipboard
Properties that are keywords cause cascading highlighting issues
I also use vim-javascript for my normal syntax highlighting. However, I've tried commenting out this library in my setup and I don't see the bug, so something here clashes with the setup there. Without this library, vim-javascript correctly does not highlight javascript keywords used as object properties, like obj.class = 'success'
. With this library, class
gets highlighted according to the syntax highlighting specified by vim-javascript (which is to say, it's the same color "class" would be when used as a class declaration). That by itself isn't really a problem; I could live with it. The problem is that subsequent text is then highlighted erratically because this library seems to think it was an actual class declaration and is expecting the class itself to follow. Here's a screen shot. Note how "MemberService.member.personal.firstname" is yellow. Without this library, it's white, as I'd expect for any object property path.

Related - strings are highlighted incorrectly if they contain keywords, such as the library names themselves

Comments too:

I think these are two different issue. The first one I am not sure what is the root cause.
The word highlighted in comment and string is because the syntax of vim-javascript use incorrect(or not following convention) group name.
The first issue has something to do with postprocess.javascript.vim
. If I make it not source that file, I don't get syntax highlighting errors with class
, but I also don't get library function highlighting on chained functions. Like
angular.module('app').controller
Here angular
and module
are correctly highlighted but controller
is not. And btw, this particular issue is unaffected by vim-javascript. If I remove that from my plugins, I still get these errors on things like .class
.
You are correct that the second issue is a discrepancy between this library (which expects things called, e.g., javascriptComment
and vim-javascript which is naming them jsComment
.