othree / es.next.syntax.vim

ES.Next syntax for Vim
MIT License
125 stars 7 forks source link

Syntax highlighting breaks when function body not surrounded with {}? #8

Open olalonde opened 7 years ago

olalonde commented 7 years ago

I'm using this following plugins:

Plugin 'othree/yajs.vim'
Plugin 'othree/es.next.syntax.vim'
Plugin 'mxw/vim-jsx'

syntax-highlight

Sometimes when returning an expression surrounded with (``), the syntax highlighting breaks, e.g.:

const preset = (context, { loose } = {}) => ({
  plugins: [
    ...es2015,
    ...es2016,
    ...es2017,
  ].map((plugin) => [plugin, { loose }]),
})
othree commented 7 years ago

This issue belongs to yajs.vim. And I still not able to solve it.

The problem is. These is another case I can't distinguish from this one:

(arg1) => (arg2) => (arg3, arg4) => (arg5, arg6) => true

Vim's syntax system cant look forward. So I have to tell is it a function or a paren when cursor at:

(arg1) => (arg2) => (arg3, arg4) => (arg5, arg6) => true
          ^
olalonde commented 7 years ago

Ah, I see :( There are probably other syntax highlighters that have solved similar ambiguity in different languages, might be worth checking how they do it.