You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
The support for js is pretty bad. Most of the issues are in the way of parsing variable names.
Load this example into atom. When I say something is not tagged I mean its scope is only .source.js.
import*aspfrom'point';//testimport{xasy}from'coordinates';//testconstANSWER=42;// ANSWER not tagged (fixed by #138, #140)varone,two,three,four;// variables not taggedvarfive=5,six=6;// variables not taggedfunctionsomeFunc(arg1,arg2,arg3){varaVariable='ok';// aVariable not taggedaVariable='nope';// aVariable not taggedvaranArray=newArray()// anArray not tagged (fixed)anArray.slice()// anArray not tagged (fixed)anArray.otherMethod()// anArray, otherMethod not tagged (fixed)randomGlobal.prop.omg()// not tagged (fixed)varanObject={key1: 'val1'// key1 not taggedkey2: function(one,two){}}}varfuncVar=function(arg1,arg2,arg3){}classCarextendsVehicle{constructor(speed,cost){super(speed);varcindex=Symbol('cost');// cindex not taggedthis[cindex]=cost;// cindex not taggedthis.intro=`This is a car runs at ${speed}.`;}}for(letnumof[1,2,3]){// num not taggedconsole.log(num+0b111110111);}
Giving these symbols correct scopes will greatly improve the support in the coming SymbolProvider in the soon-to-be-bundled-in-core autocomplete-plus.
I've temporarily worked around this by having my theme manually wrap any unwrapped scopes, and then adding a data-word attribute containing the 1st word. Here's the relevant code if anyone wants:
###* * Looks for text nodes and wraps them with a tag. Assuming we have the * following HTML: * <span> * <span>lorem</span> * hello // wraps this since we can't select just this via CSS otherwise. * </span> * There's no way to select just 'hello' with a CSS selector. Therefore, this * method looks for these and wraps them with a `<span>` to make them * selectable, and adds the first word in the tag into data-word attribute. * @method wrapTextNodes * @param {string} selector - Selector to .source.grammar nodes. * @param {string} wrapWith - String that will be used to generate a * jQuery object to wrap matched text nodes * with. example: '<span class="js"></span>'.###wrapTextNodes: (editorView, selector, wrapWith) ->@customWrappedTextNodes?= []
self=this# FIXME Currently this doesn't happen until the 1st time the cursor# moves, because jQuery.ready fires BEFORE the text has been added# to the buffer. Need to get it to run just once on activation at the# right time.$(editorView.shadowRoot).find(selector).each->contents=$(this).contents()
$.each contents, (i,val) ->ifval.nodeTypeis3# add tag which can be used for CSSmatch=$(this).text().trim().match/\b[\w]+\b/gfirstWord= match?[0]
# wrap the text$wrapped=$(this).wrap wrapWith
$wrapped.parent().attr'data-apathy-word', firstWord
self.customWrappedTextNodes.push $wrapped
###* * Unwrap nodes wrapped by @wrapTextNodes(). * @method unwrapTextNodes###unwrapTextNodes:->for node in@customWrappedTextNodes$(node).unwrap()
Another issue I have with the highlighting is that some variables will get special coloring, and others won't, example here: x and y are in orange, but z isn't the same color. This is annoying when working with 3D, but it would be nice if all the variables were the same color. Thanks
Is this just a question of expanding the grammar? Sublime Text 3 recently pulled the JavaScript Next package into core to improve highlighting. Perhaps it would be a good idea to look at that as a basis to improve our JS support?
Getting closer...pretty much the only issue left is tokenizing variables. That's also the hardest one, however 😔. The only other one I see is key1 not getting tokenized: we'll know for sure once Linguist picks up v0.101.0.
While not very helpful, FYI the subtle gradient solves all of these problems. You do have to take into account the fact that the master branch is ~10 commits ahead of the published version, but the RegEx is good from the repo.
Activity
czxtm commentedon May 6, 2015
off-by-some commentedon May 6, 2015
JamesMowery commentedon May 10, 2015
👍
I'd love to see better JS support, as I'd really like to see this made possible: https://discuss.atom.io/t/is-it-possible-to-change-the-color-of-declared-variables/16731/1
It's the one thing that keeps me from being totally in love with Atom.
czxtm commentedon May 10, 2015
@JamesMowery this might be of interest to you: https://atom.io/packages/language-javascript-semantic
bobrocke commentedon May 25, 2015
Here are some other examples:
But there are many others. This grammar appears to be pretty young.
jonkwheeler commentedon May 29, 2015
Here's a simple one. Most text is white. Objects, Methods, Props all the same.
I came here from this Atom thread.
It would really help me if the highlighting worked right.
czxtm commentedon May 29, 2015
I've temporarily worked around this by having my theme manually wrap any unwrapped scopes, and then adding a
data-wordattribute containing the 1st word. Here's the relevant code if anyone wants:Observer:
Method that does the wrapping:
junewunder commentedon Jun 5, 2015
Another issue I have with the highlighting is that some variables will get special coloring, and others won't, example here:

xandyare in orange, butzisn't the same color. This is annoying when working with 3D, but it would be nice if all the variables were the same color. Thankswinstliu commentedon Jun 5, 2015
Hi @jaywunder, I actually just fixed that. If you upgrade to Atom 0.206.0,
zshould be highlighted as well ✨.junewunder commentedon Jun 5, 2015
I seem to not be getting the 0.206.0 update pushed to my computer so I guess I'll get the fix tomorrow. Thanks for the quick response! 💖
winstliu commentedon Jun 5, 2015
Actually, sorry for the false information. A fix was pushed, but a new version wasn't published and integrated into Atom 😦. Maybe 0.207.0 then. Sorry!
braver commentedon Oct 16, 2015
Is this just a question of expanding the grammar? Sublime Text 3 recently pulled the JavaScript Next package into core to improve highlighting. Perhaps it would be a good idea to look at that as a basis to improve our JS support?
bobrocke commentedon Oct 16, 2015
Won't Atom essentially "just use" .tmLanguage files?
braver commentedon Oct 17, 2015
Well you convert them first, but that's basically what happens.
bobrocke commentedon Oct 17, 2015
@braver I see instructions for converting themes and bundles. Are there some for .tmLanguage files?
mgenev commentedon Oct 19, 2015
The-8-Bit-Zombie commentedon Nov 4, 2015
Victorystick commentedon Nov 4, 2015
The import statement
isn't valid JavaScript, so it isn't strange for the highlighting to be broken. This on the other hand works fine
winstliu commentedon Nov 4, 2015
@Victorystick thanks, updated the post.
winstliu commentedon Nov 18, 2015
Getting closer...pretty much the only issue left is tokenizing variables. That's also the hardest one, however 😔. The only other one I see is
key1not getting tokenized: we'll know for sure once Linguist picks up v0.101.0.dkimot commentedon Aug 9, 2017
While not very helpful, FYI the subtle gradient solves all of these problems. You do have to take into account the fact that the master branch is ~10 commits ahead of the published version, but the RegEx is good from the repo.
phillipmohr commentedon Feb 4, 2019
Is it still not possible to have colored variables?
https://discuss.atom.io/t/is-it-possible-to-change-the-color-of-declared-variables/16731