pangloss / vim-javascript

Vastly improved Javascript indentation and syntax support in Vim.
http://www.vim.org/scripts/script.php?script_id=4452
3.79k stars 358 forks source link

Thoughts on Operators #95

Closed amadeus closed 11 years ago

amadeus commented 11 years ago

According to this doc, quite a few things are Operators.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators

I am thinking of merging a few more pieces into the Operator group. Some of it I think is overkill (,, . and this specifically).

What are your thoughts?

goatslacker commented 11 years ago

I'm ok with . since I think it should be further distinguished from Noise.

, isn't an operator unless it's used as an operator.

Example:

[1, 2, 3] // not an operator
var a = sideEffectFunction(), value // operator

I don't think it's possible to differentiate both use cases so -1 on highlighting , as an operator.

this : http://es5.github.io/#x11.1.1

new however is an operator: http://es5.github.io/#x11.2.2

amadeus commented 11 years ago

Sorry, I worded that poorly. I meant to say merging things into Operators EXCEPT for ,, . and this

I mean't to say that those items were overkill for the Operator group.

amadeus commented 11 years ago

Thinking of something along the lines of this:

https://github.com/amadeus/vim-javascript/commit/dde0c5c41809766b5abd759d2466c11676d05acd

goatslacker commented 11 years ago

yield and with are not operators though.

http://es5.github.io/#x7.6.1.1 - with is a keyword. and I know it lists in as a keyword also, but http://es5.github.io/#x11.8.7

in as an operator is further corroborated by http://esprima.org/demo/parse.html if you do a in b you'll see in as an operator in the SpiderMonkey Parse API.

yield is a keyword according to http://people.mozilla.org/~jorendorff/es6-draft.html I'm trying to find a more definitive answer there but I'm sure it's just like return.

:+1: to new and in

amadeus commented 11 years ago

Fair enough, here's a couple modifications based on what you said:

https://github.com/amadeus/vim-javascript/commit/7265eb7066d273b222fe9a1b44ac679045abee9c

goatslacker commented 11 years ago

Just found this: http://es5.github.io/#x12.10

return is also a Statement, I'm guessing that makes yield a statement too although the ES6 Draft specifies it as YieldExpression. Not sure what to make of it.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield MDN calls it a keyword.

Keyword seems like just a catch-all. Still looking for more insight for yield would suck to have that as the lone keyword.

amadeus commented 11 years ago

Ok, let me know what you find. In the meantime I've updated the branch to reflect this:

https://github.com/amadeus/vim-javascript/commit/7cd555a622585510181868d9bd06d415a9ba6371

goatslacker commented 11 years ago

:shipit: