Semantic highlighting


I like Atom, but I’m addicted to semantic highlighting. Would it be possible to add it?

I saw Semantic Variable Name Highlighting, but it was closed since a javascript specific package was created. I would need ruby/more than just javascript.

Looking for feedback and tips to target more elements

What is it you’re asking for exactly? Are you asking:

  • Is it possible and easy to extend Atom to add something along the lines of this feature for all possible grammars?
  • Is it possible to extend Atom, even though it might take a significant amount of work?
  • Does the Atom team have any plans to make such a feature available for all possible grammars?
  • Will someone (besides the Atom team) make this feature/package?


Fair question(s). Answering your questions in order.

  • This is what my original question meant to ask.

  • This leads me to wonder how much work would be involved… a cursory 30 second glance at the source of the javascript package did not immediately make it obvious to me what would be needed to do this for other grammars. Obviously, I can do more research, but if there is a substantial amount of work I probably would not undertake the endeavor.

  • This would be amazing!

  • Has anyone already done so that I’m not aware of? I would love it if someone had/will.


Is there direct support in Atom to make colorization of certain grammar elements variable based on some function (in the mathematic sense)? No, there isn’t. (This is what I assume would be necessary to make it “easy”.)

Yes, it is possible to extend Atom in this way as others have shown, i.e. the package you mention as well as @abe’s package atom-color-highlight. Though making a single package that would handle all possible grammars is potentially a very tall order given variations in languages and grammars.

There has been no mention that the Atom team has this on their roadmap. That doesn’t mean that they don’t … just that they haven’t publicly discussed it.


Having now more insight on how grammars works, it should be possible to add new rules dynamically to an existing grammar:

Grammars can be accessed through atom.syntax.grammars.
Once you have the grammar you want to extend, you can insert rules in the rawPatterns property of the grammar. I haven’t tried this approach yet, but I think it could be a good starting point for this kind of feature. My guess is that it’ll be simpler this way that forking/creating a grammar to implement this.


There was this post where someone attempted to build dynamic grammars along these lines:

I think they got it working reasonably well eventually. It might be something to look at.


Lots of reading to do. Thanks guys!