Highlighting broken when a class lambda returns a single JSX tag not enclosed in parentheses
naveg opened this issue · comments
My coworkers are always telling me to remove useless parens, but they aren't useless to me! ;)
Here's a modified plugin section of my vimrc. The bug reproduces with a vimrc consisting of this snippet only.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'pangloss/vim-javascript', {'for': ['javascript', 'javascript.jsx']}
Plug 'mxw/vim-jsx', {'for': ['javascript', 'javascript.jsx']}
call plug#end()
Thanks for the report, @naveg, as well as the detailed examples and counterexamples! I am able to repro this issue.
Unfortunately, I don't see a great way to fix this. The core issue here is as follows:
- The
jsClassBlock
syntax region contains a pretty narrow subset of things, none of which transparently containsjsxRegion
. - The
jsArrowFunction
syntax element can impose a special-case match on the next element, but it only looks forjsFunctionBraces
, which you're omitting explicitly in your example. - The
jsClassValue
syntax element can contain arbitrary expressions (including JSX), but is explicitly ended by a newline character.
Together, this actually means that you could replace your JSX element with pretty much anything and the highlighting would be broken, e.g.:
The tl;dr is that this seems like a bug with pangloss/vim-javascript. Feel free to file a bug report over there, and if their fix doesn't address this specific case, let me know.
Closing out because it's not readily actionable from vim-jsx's end. (Feel free to reopen if things change upstream.)