Why aren't variables passed as function arguments being wrapped in HTML tags?


#1

I’ve been loving Atom so far, but one thing irks me… when I pass a variable as a function argument, the variable name doesn’t appear to be wrapped as a DOM element, and therefore can’t be individually styled.

To clarify, when I type:

myFunction(myVariable, "foo");

the function name is wrapped in a .syntax--function span, and “foo” is wrapped in a .syntax--string span, but “myVariable” has no corresponding wrapper… it’s merely a text node at the beginning of the .syntax--arguments span.

Is there some setting I can change that would fix this?


#2

This is entirely controlled by the language- package that’s currently active. You can insert spans with the text decoration style. Check out this API page, then try the following code in the dev tools or init.coffee:

editor = atom.workspace.getActiveTextEditor()
range = editor.getSelectedBufferRange()
marker = editor.markBufferRange(range)
decoration = editor.decorateMarker(marker, {type: 'text', class: 'syntax--comment'})

#3

Thanks for the help. The language package in question is language-javascript, so maybe I’ll open an issue on that repo.


#4

The decoration should be sufficient for your needs, but I agree that having a “variable inside a function” class would be useful in a lot of cases.