jaxbot / semantic-highlight.vim

Semantic Highlighting for Vim
http://jaxbot.me/
486 stars 34 forks source link

Some blacklist keywords being ignored on some files #46

Open jevogel opened 8 years ago

jevogel commented 8 years ago

I'm working with VHDL and I added about 120 VHDL keywords to the blacklist file. On some files they all seem to be correctly blacklisted and will use the highlighting specified in the color scheme, but on other files some of the keywords will be semantically-highlighted. It varies between files which keywords are handled correctly and which are not. Rebuilding the color cache doesn't seem to help.

I have a feeling it might have something to do with the plugin not excluding comments from matching, as it seems to happen only in files with lots of wordy comments. I looked at the cache file and noticed there were a lot of words in there that didn't look like my variables. I also noticed that there were no listings in the cache for my blacklisted keywords, which is what I would expect.

faceleg commented 8 years ago

In order to have someone debug this, we'll need some example files

jevogel commented 8 years ago

This example has a fair number of comment lines. This is a list of VHDL keywords similar to what I was using.

This example file doesn't have as many comments as the files I was dealing with, but you could always add more (the more words, the better... could try adding "lorem ipsum").

If you run the plugin on this file and then check the cache, you should see that words from the comments show up there. I suspect that if the comments are wordy enough, you will note that some keywords will be highlighted when they should not be.

My stopgap fix for this was to modify the regex used to identify variable names to exclude comments. Perhaps you could modify the regex such that it accepted an argument that defined the comment characters for the current language. Of course, dealing with block comments would be a whole 'nother issue.