ankurdave / color-identifiers-mode

Emacs minor mode to highlight each source code identifier uniquely based on its name
308 stars 23 forks source link

Tree-sitter support #80

Closed Hi-Angel closed 2 years ago

Hi-Angel commented 3 years ago

As upstream Emacs are discussing possibility of migrating to tree-sitter, I decided to see if color-identifiers mode I use daily supports it.

In this PR, first 2 commits are unrelated fixes. 3rd commit is a small optimization; the variable color-identifiers:colorize-behavior it adds will be used in later commits. And finally, last commits introduce tree-sitter support for various languages.

Tree-sitter currently also supports JS, but I see lots of js-related modes in color-identifers and I'm kinda lost which needs to have the tree-sitter-hl-face:variable declared. As I don't usually use JS, I left that to the next motivated person to fix.

Note: the tree-sitter changes I only tested in c-mode and python-mode. Any additional testing is more than welcome.

Hi-Angel commented 3 years ago

Hmm, wait, something odd is happening in python mode without tree-sitter. Not sure yet what's going on.

Hi-Angel commented 3 years ago

Okay, so, I noticed that Exception is now highlighted as a variable. The reason is that python mode has font-lock-type-face in the list as one that signifies a variable. It wasn't getting highlighted before due to a bug that I'm fixing in commit Support tree-sitter mode for python-mode, which is that the variable face was hardcoded.

I don't really understand why this face is there, I propose we remove it.

Hi-Angel commented 3 years ago

Found a bug due to misplaced parens. Yeah, that kind of bug with such syntax is probably to be expected. Anyway, fixed it, and I also removed from python mode font-lock-type-face. I've been using it removed since I posted PR, and so far I noticed no difference.

Hi-Angel commented 2 years ago

If nobody against it, I think I'll merge the changes. I've been using these since the time they were posted and noticed no problems so far.