Do you want to request a feature or report a bug?
Bug
What is the current/expected behavior?
The error Prettier: failed to parse buffer. occurs when running vim-prettier on any .js file I have in my project.
If there is more debugging output that I can get somehow, please let me know and I will add it to the issue.
I have the following configuration in my init.vim:
let g:prettier#config#single_quote = 'false'
let g:prettier#config#bracket_spacing = 'true'
let g:prettier#config#jsx_bracket_same_line = 'false'
let g:prettier#config#arrow_parens = 'avoid'
let g:prettier#config#arrow_parens = 'none'
let g:prettier#config#parser = 'flow'
What version of vim-prettier are you using - (output of :PrettierVersion) ?
0.2.7
What version of prettier are you using - (output of :PrettierCliVersion) ?
1.13.7
What is your prettier executable path - (output of :PrettierCliPath) ?
/home/christos/code/headstartapp/import-application-states/node_modules/.bin/prettier
Did this work in previous versions of vim-prettier and/or prettier ?
Not 100% sure but I installed/setup in the same way with the same version of prettier cli about 1-2 weeks
ago on my work computer and that setup worked fine. Not sure which version of vim-prettier
is installed on that machine but I can check and get back to you here when I do.
Output of :version
NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-_mzR4z/neovim-0.2.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTI
FY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototyp
es -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-_mzR4z/neovim-0.2.2/build/config -I/build/neovim-_mzR4z
/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-_mzR4z/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-_mzR4z/neovim-0.
2.2/build/include
Compiled by [email protected]
Same issue here, with a new install of vim-prettier. The outputs are the same (of :PrettierVersion, etc)
Update: sorry, please ignore my comment! I get the same error message but with scss files (not css though) so it's something else probably.
Edit2: my issue is definitely related to #108, having white-space in the file path.
Hi there,
Thanks for reporting this issue will investigate this ASAP.
Not 100% sure but I installed/setup in the same way with the same version of prettier cli about 1-2 weeksago on my work computer and that setup worked fine.
Where you using the same prettier cli 1.13.7 version ?
@cdimitroulas , if you still have access to the machine that has a working prettier and vim-prettier would be awesome to double check the versions to see if they match (prettier cli and vim-prettier) also if possible go to the vim-prettier installation directory and do a git log and check what is the current commit hash that you are on.
I did some minor exploratory testing now to try to reproduce the issue without success (using vim 8.0) will try doing more tests later when I get home using different vim versions and scenarios
Hey, just got back to my work machine (was away yesterday) so here are the version numbers where it is working correctly:
vim-prettier version: 0.2.7
prettier cli version: 1.13.7
The only difference is that I have an extra couple of lines of config here, which maybe are required and I didn't realise:
Plug 'prettier/vim-prettier', {
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue']
\ }
I can try adding this config on my home computer this evening and see if that fixes the problem
Turns out I had an invalid line in my config which was this one:
let g:prettier#config#arrow_parens = 'none'
That was supposed to be:
let g:prettier#config#trailing_comma = 'none'
Woops!
Maybe there is be a way we could change the error message to make it clear that that the reason that the parsing is failing is due to an invalid configuration? If this is not practical, feel free to close the issue
Thanks for commenting in here! I will try to think on what would be the best way to deal with error handling and will open an issue for it! Glad you got it fixed !
Most helpful comment
Turns out I had an invalid line in my config which was this one:
That was supposed to be:
Woops!
Maybe there is be a way we could change the error message to make it clear that that the reason that the parsing is failing is due to an invalid configuration? If this is not practical, feel free to close the issue