Closed dangvanthanh closed 1 year ago
Hi, I'm receiving the same error.
.vimrc
" specify dir for plugins
call plug#begin('~/.vim/plugged')
Plug 'prettier/vim-prettier', { 'do' : 'yarn install' }
" colorschemes
Plug 'morhetz/gruvbox'
" initialize plugin system
call plug#end()
:PrettierVersion 1.0.0-beta :PrettierCliVersion 2.0.4 :PrettierCliPath /Users/khuynh/.vim/plugged/vim-prettier/node_modules/.bin/prettier
MacVim 8.2
Same here
call plug#begin('~/.vim/plugged')
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
call plug#end()
More details
:PrettierVersion 1.0.0-beta
:PrettierCliVersion 2.0.4
:PrettierCliPath home/spongebob/.vim/plugged/vim-prettier/no
I had the same issue with old versions.
It got resolved when I removed .prettierrc
After upgrading to the latest, even without a config file, I get this error leaving me unable to use the plugins.
I found the workaround.
put this in vim config
let g:prettier#config#single_quote = 'true'
let g:prettier#config#trailing_comma = 'all'
I found the workaround.
put this in vim config
let g:prettier#config#single_quote = 'true' let g:prettier#config#trailing_comma = 'all'
Thanks @zirho
I was removed
let g:prettier#config#parser = 'babylon'
then put your config. It's working for me.
i can confirm that @zirho 's solution works for me!
I too confirm @zirho 's solution worked for me!
this might be related to error
[error] Invalid --trailing-comma value. Expected "all", "none", "php5" or "php7.2", but received "es5".
possibly related to NVM and the default version of node being set in the system. Prettier is being run with the default version and that could lead to this error.
I can confirm that @zirho's solution also worked for me :), really enjoying this plugin, thank you to the devs for creating this it is wonderful to get Prettier support inside of Neovim!
FWIW and in case it's a clue for the root cause, I only needed one line:
let g:prettier#config#trailing_comma = 'all'
from @zirho's solution to get rid of Prettier: failed to parse buffer
. That was with vim-prettier 1.0.0-beta and prettier installed by the plugin at version 2.0.4.
It is potentially an issue with the php plugin, though I've no idea. Maybe it is overwriting the available trailing comma options? I'm getting the same issue on my Mac setup. If I remove the plugins from the package.json
file (as I don't need any of them) then delete node_modules
and yarn install
again then it starts working.
I would also deeply appreciate some way of getting more information out of prettier when seeing the "failed to parse buffer" error. I didn't see any option but is there some kind of verbose logging mode to help debug this? I ended up adding echom join(a:errors, "\n")
to the onError
function in job/runner.vim
.
Possibly also because the package.json
specifies 0.10.2
for the php plugin and that was released back in February 2019. There have been a number of fixes (probably including this) since then.
It might make sense to specify a much looser constraint.
I found the workaround.
put this in vim config
let g:prettier#config#single_quote = 'true' let g:prettier#config#trailing_comma = 'all'
Thank you so much – this finally fixed my issue!
This is indeed related to prettier-php version being too old. The problem was fixed: https://github.com/prettier/plugin-php/issues/964 Updating to a newer version than plugin-php 0.11.1 should solve the problem.
This is indeed related to prettier-php version being too old. The problem was fixed: prettier/plugin-php#964 Updating to a newer version than plugin-php 0.11.1 should solve the problem.
Not fixed
possibly related to NVM and the default version of node being set in the system. Prettier is being run with the default version and that could lead to this error.
I stumbled across this issue after searching for the Prettier: failed to parse buffer
error and my issue was indeed my Node version. My shell was running version 8 via nvm
rather than my default version 16 when I started vim
. After exiting, switching and trying again it worked.
I found the workaround.
put this in vim config
let g:prettier#config#single_quote = 'true' let g:prettier#config#trailing_comma = 'all'
This works for me but I want to run prettier with the defaults so it's not an ideal solution.
possibly related to NVM and the default version of node being set in the system. Prettier is being run with the default version and that could lead to this error.
I stumbled across this issue after searching for the
Prettier: failed to parse buffer
error and my issue was indeed my Node version. My shell was running version 8 vianvm
rather than my default version 16 when I startedvim
. After exiting, switching and trying again it worked.
What's the best way to check which version of node vim-prettier is running and is there a way to configure a version for vim-prettier? NVM is currently set to current LTS v14.17.4
This is causing me issues for me now :(
Solutions I tried:
My versions:
1.0.0-beta
~/.vim/plugged/vim-prettier/node_modules/.bin/prettier
[error] No parser and no file path given, couldn't infer a parser.^@
In my experience this issue is caused by me renaming the root directory of a directory containing node packages.
My fix has been to delete the node_modules
folder and run npm
or yarn
to refresh it:
rm -rf node_modules
yarn
I found the workaround. put this in vim config
let g:prettier#config#single_quote = 'true' let g:prettier#config#trailing_comma = 'all'
Thanks @zirho
I was removed
let g:prettier#config#parser = 'babylon'
then put your config. It's working for me.
This fixed it for me.
(removed)
I found the workaround.
put this in vim config
let g:prettier#config#single_quote = 'true' let g:prettier#config#trailing_comma = 'all'
I tried this but it did not work for me on my _vimrc
file on windows,
surprisingly enough :Prettier
or my map <Leader><Leader>p
works just fine
and .ts/tsx files work just fine on save!
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.svelte,*.yaml,*.html PrettierAsync
I don't face this issue on my linux machine however
Do you want to request a feature or report a bug?
In NeoVim show error
Prettier: failed to parse buffer
in I save JavaScript file.This is my
init.vim
configureWhat is the current/expected behavior?
What version of
vim-prettier
are you using - (output of:PrettierVersion
) ?1.0.0-beta
What version of
prettier
are you using - (output of:PrettierCliVersion
) ?2.1.2
What is your
prettier
executable path - (output of:PrettierCliPath
) ?Users/dangvanthanh/.config/nvim/plugged/vim-prettier/node_modules/.bin/prettier