fzf-preview.vim icon indicating copy to clipboard operation
fzf-preview.vim copied to clipboard

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

Open kaka-ruto opened this issue 2 years ago • 2 comments

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

  • fzf-preview version (package.json): 2.12.9

  • OS: Mac OS Monterey

  • Vim/Neovim version: 0.7.0

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 avatar May 18 '22 15:05 kaka-ruto

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!)

kaka-ruto avatar May 19 '22 08:05 kaka-ruto

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"

lucioreyli avatar Sep 21 '22 17:09 lucioreyli