es.next.syntax.vim icon indicating copy to clipboard operation
es.next.syntax.vim copied to clipboard

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

Open olalonde opened this issue 9 years ago • 2 comments

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 }]),
})

olalonde avatar Sep 12 '16 03:09 olalonde

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
          ^

othree avatar Sep 12 '16 14:09 othree

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.

olalonde avatar Sep 12 '16 18:09 olalonde