mxw / vim-jsx

React JSX syntax highlighting and indenting for vim.
1.59k stars 95 forks source link

JSX pragma detection fails because of non POSIX grep options #13

Closed baskerville closed 10 years ago

baskerville commented 10 years ago

On my system, grep doesn't provide any -P or -z option, hence, grep -Pz '(?s)/\*(?:.(?!\*\*/))*jsx.*?\*/' always fails (on a side note: maybe React.DOM should be matched against?).

I would recommend not to use grep, vim can handle this by itself:

autocmd BufNewFile,BufRead * if getline(1) =~ 'REGEX' | SUCCESS | endif
mxw commented 10 years ago

AFAIK, vim isn't able to perform quite the correct match on its own, since matching the JSX pragma exactly requires multi-line matching.

I've heard that the pragma may no longer be required in future releases of the JSX transformer, though, so I'm planning on adding a global option for whether or not the pragma needs to be checked in the morning.

baskerville commented 10 years ago

Please have a look at :h perl-patterns.

It seems that . will match new lines if \_ precedes it.

mxw commented 10 years ago

Cool, thanks for pushing on this—I tried doing the \%(\_.\%(\*\/\)\@!\)* match before, but I think I forgot one of the backslashes before a ). Also just wasn't aware of \_s or \%^... lesson learned!