othree / yajs.vim

YAJS.vim: Yet Another JavaScript Syntax for Vim
http://www.vim.org/scripts/script.php?script_id=4974
Vim License
688 stars 41 forks source link

Support more exotic method names #23

Closed maxnordlund closed 9 years ago

maxnordlund commented 9 years ago

Since ES6 allows methods to be named to pretty much anything, like return or throw, it would be nice if yajs correctly highlighted this as method names, instead of marking it as a syntax error. The same goes for computed method names, e.g. [Symbol.iterator]. The latter seams to mess up the following return statement, which is sad.

For comparison it works as intended when highlighted as TypeScript, which is a superset of JavaScript.

JavaScript TypeScript
JavaScript TypeScript
class Foo {
  constructor() {}

  throw(error) {}

  [Symbol.iterator](): Iterator {
    return this
  }

}
othree commented 9 years ago

Both issue were fixed, but you will need to remove the type annotation to check it. Currently, type annotation is not under TC39's discussion. So I have no plan to support it right now.

I think type annotation will merge into JavaScript one day. But its still unclear when and how it looks like.

maxnordlund commented 9 years ago

Awesome, that's much nicer. Yes, I forgot to remove the annotations.