othree / javascript-libraries-syntax.vim

Syntax for JavaScript libraries
http://www.vim.org/scripts/script.php?script_id=4428
621 stars 36 forks source link

Properties that are keywords cause cascading highlighting issues #67

Open tandrewnichols opened 7 years ago

tandrewnichols commented 7 years ago

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.

screen shot 41
lararosekelley commented 6 years ago

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

screen shot 2017-11-25 at 3 37 04 pm
tandrewnichols commented 6 years ago

Comments too:

screen shot 11
othree commented 6 years ago

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.

tandrewnichols commented 5 years ago

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.