yuki-yano / fzf-preview.vim

The plugin that powerfully integrates fzf and (Neo)vim. It is also possible to integrate with coc.nvim.
MIT License
910 stars 37 forks source link

Older versions of Node throwing SyntaxError: Unexpected token '?' #304

Open kaka-ruto opened 2 years ago

kaka-ruto commented 2 years ago

Problems summary

I am working on a project that uses Node version 12.16.1.

Neovim picks this version of Node and uses it, making some fzf-preview functions to fail with syntax errors since I believe fzf-preview uses latest Node versions.

An example, when I run :FzfPreviewProjectGrep, I get SyntaxError: Unexpected token '?'

Expected

The grep preview above works

Environment Information

Provide a minimal init.vim

" call plug#begin('~/.vim/plugged')
" Plug 'junegunn/fzf'
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'ryanoasis/vim-devicons'
" call plug#end()
" 
" let g:coc_global_extensions = ['coc-fzf-preview']

Screenshot

Screenshot 2022-05-18 at 14 26 36

Dockerfile that reproduces the problem (if possible)

Refer to https://github.com/yuki-yano/fzf-preview.vim/blob/main/.github/issue_example/Dockerfile

kaka-ruto commented 2 years ago

I know it's extra work to support this so let me know if and how I can help! (haven't dug into the code deep enough to know what to tweak but if you give a brief guidance I will be happy to do it!)

lucioreyli commented 2 years ago

it's because de Nullish coalescing ?? has introduced in Node version 14, and you are using Node version 12 (look https://node.green/#ES2020-features--nullish-coalescing-operator-----).

But you can change the

BAT_THEME = process.env.FZF_PREVIEW_PREVIEW_BAT_THEME ?? "OneHalfDark"

to

BAT_THEME = process.env.FZF_PREVIEW_PREVIEW_BAT_THEME || "OneHalfDark"