Ways to affect syntax highlights in a package


#1

Hi everyone,

First let me say that this first beta is quite impressive and I have the feeling that it’ll be one of the most promising webdev tool in the near future.

Now let’s move to the main topic.

I started to dig a bit in the sources of the various packages in order to figure how to make a plugin that highlights color codes (hexa, rgb, etc) in a file by applying a background color to the color declaration (as FDT does for instance). I figured out how I could place an element behind some text parts using markers (as done by the find-and-replace package), but the issue here is that it doesn’t modify the color declaration itself, leading to poor contrast depending of the color and theme.

So, I was wondering if there was a preferred way to dynamically add rules to the grammar used on a particular editor view ? Is it simply possible ?


Editor marker CSS
How can we help you write packages?
#2

Wondering the same thing. Trying to implement rainbow-parens in Atom, and currently I’m doing it the same way @abe is in his Atom Color Highlight, by making elements in the overlayer, covering the original text and reprinting it. Feels very clunky, so a way of doing it directly would be very nice.


#4

atom does not set classes or ids for opening and closing braces.

I am not solid enough with :before and :after but I guess checking content of div if it has ( [ { or } ] ) and then style it with nth-child(n) should be possible.

What my doubt about rainbow parents package is that it may does cause color conflicts with themes.
We see it happen already with packages like coffee script preview. It does not use theme colors but does use its own.

this is what i get when i check devtools about all types of braces
.meta .brace .round .js -> ( )
.meta .brace .curly .js -> { }
.meta .brace .square .js -> [ ]

If form validations can be done with :before and :after to check for content. then I think its possible to do rainbow brackets with pseudo classes and nth-child(n) too.

But respecting the theme is a must. Or at least help theme builders to support rainbow brackets.


#5

Any update on this? this is the only feature keeping me in LightTable for clojure(script) dev.


#6

Perhaps you should start a new topic and state what it is you’re trying to do, @afhammad. This topic does not reflect the current state of affairs, seeing as it is a year old.


#7

will do, thanks