from Hacker News

JavaScript Scope Context Coloring

by templaedhel on 4/7/13, 4:46 AM with 33 comments

  • by scjr on 4/7/13, 5:35 AM

    It might be better to use variations in the background color. It may feel more natural to do so and it would allow normal syntax highlighting alongside scope highlighting.
  • by wavesounds on 4/7/13, 7:29 AM

    Really great idea, would be super useful, it looks like its still got a ways to go though, it doesn't seem to recognize global variables yet for one

    http://stackoverflow.com/questions/235360/what-is-the-scope-...

  • by necolas on 4/7/13, 6:08 AM

    Ever since watching that Crockford talk, I've wanted to try this out as a Vim plugin.
  • by dag11 on 4/7/13, 5:34 AM

    This is great.

    Idea: Implement loose "syntax" highlighting over the scope highlighting by bolding syntax keywords instead of highlighting them. Perhaps also slightly change the brightness of certain syntax keywords.

  • by druska on 4/7/13, 5:28 AM

    Now we just need a Sublime Text plugin for this.
  • by VeejayRampay on 4/8/13, 2:28 AM

    That's excellent. A nice variation around this that I've been keen on for a long time and have been wanting to see in modern IDEs is using 3D (or drop shadows) to simulate the nesting of blocks/closures/scopes and give the programmer an instant understanding of the different levels and depths.
  • by Vivtek on 4/7/13, 9:39 AM

    This is probably one of those things that's really effective if you have working color vision, right?
  • by TheFuntastic on 4/7/13, 7:57 AM

    Can anyone point to which particular crockford talk this was inspired by? I've had the idea for scope highlighting bashing around my head for a while now, would love to know more.
  • by mateuszf on 4/7/13, 3:43 PM

    Actually Intellij Idea has the same concept, here it is working in HTML: https://dl.dropbox.com/u/456905/idea.png

    I think it would be great if they added it to JS, with their powerful syntax parsing it would be probably trivial to do.

    Edit: probably works in their php, django and rails ide-s.

  • by macca321 on 4/7/13, 11:58 AM

    I forked it with fonts: http://snag.gy/TnNBO.jpg

    Maybe not so useful...

  • by ebiester on 4/7/13, 7:11 AM

    I think this would make a lot of sense for Lisp or Clojure, at least when starting out.
  • by efnx on 4/7/13, 7:02 PM

    Someone should abstract this out (for an arbitrary number of languages) into a program that would provide annotations for vim or emacs or...
  • by phy6 on 4/7/13, 1:26 PM

    Wow, I'd love to have this in a Java IDE. I often have to deal with reverse engineering amateurish code in many 1000 line classes.
  • by seanp2k2 on 4/7/13, 1:21 PM

    What if it changed based on cursor position?
  • by curiousdannii on 4/7/13, 6:36 AM

    It doesn't seem to handle comments correctly. I need to delete all mine to make it work.