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

Nullish coalescing operator confuses surrounding syntax highlighting #1164

Closed jeffvandyke closed 5 years ago

jeffvandyke commented 5 years ago

When working with syntax using https://github.com/tc39/proposal-nullish-coalescing (a ?? operator as a better alternative to ||), highlighting gets confused on surrounding parentheses and braces. My best guess is that it's expecting a ternary statement to follow.

I gave fixing it a stab, but I'm not familiar enough with vim syntax highlighting to know what to do. Any help would be appreciated!

Example:

function nullishTest() {
    const obj = { a: 'a' };
    console.log(obj.b ?? 'empty');
}

Screenshot: image

pbondoer commented 5 years ago

I'm experiencing this as well, I'd be happy to look into it with some direction :)

jeffvandyke commented 5 years ago

@pbondoer As far as a stab at it, I think the problem lies somewhere in the "syntax/javascript.vim" file. My suspicion is the regexes around jsTernaryIf and jsTernaryIfOperator, but I'm unfamiliar with the vim syntax rules.

amadeus commented 5 years ago

Added in #1165