Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't spot why prettier fails to parse css: "1 col 6| Unexpected token, expected ;" #118

Closed
therealplato opened this issue Mar 5, 2018 · 2 comments
Labels

Comments

@therealplato
Copy link

Hi, after searching I saw other issues causing this error string, caused by syntax errors or incomplete expressions passed to the engine. I'm observing it when saving a css file.

I have installed prettier with Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
I have configured prettier with:

augroup js
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
au FileType js,html nmap <Leader>d :TernDef<CR>
au FileType js,html nmap <Leader>r :TernRename<CR>
let g:prettier#autoformat = 0
let g:prettier#config#single_quote = 'false'
let g:prettier#config#print_width = 120
let g:prettier#config#parser = 'babylon'
augroup END

The file I'm saving, foo.css:

label {
  display: block;
}
input[type="text"] {
  margin-bottom: 0.5em;
}
nav {
  background-color: LightCyan;
  padding: 1em;
}
#mevents {
  background-color:LightGoldenRodYellow;
  overflow:auto;
}
.grid {
  display: grid;
  box-sizing: border-box;
  width: 100vw;
  height: 100vh;
  grid-template-columns: 1fr 3fr;
  grid-gap: 1px;
  background-color: grey;
}
.left {
  grid-column-start: 1;
}
.right {
  grid-column-start: 2;
}

:messages shows "Prettier: failed to parse buffer."
Should Prettier succeed in parsing/formatting this CSS file?

@mitermayer
Copy link
Member

Hi @therealplato,

Thanks for submitting this issue, could you please provide me a bit more information in order for me be able to help debugging your issue ?

can you please provide me the output of the commands

  • :PrettierVersion
  • :PrettierCliVersion
  • :PrettierCliPath

Also can you try commenting out that line from your .vimrc:

from:

let g:prettier#config#parser = 'babylon'

to:

" let g:prettier#config#parser = 'babylon'

I wonder if you are using an older combination of vim-prettier and/or prettier CLI. Also it could be a bug where prettier is giving more precedence to the passed parser as opposed to the lang one.

I think if you can provide the above information I will be able to better understand what is happening and if it is a bug or just incompatible usage of prettier versions

@therealplato
Copy link
Author

    :PrettierVersion
0.2.6
    :PrettierCliVersion
Usage: prettier [opts] [filename ...]^@^@Available options:^@  --write              Edit the file in-place (beware!)^@  --stdin              Read input from
stdin^@  --print-width <int>  Specify the length of line that the printer will wrap on. Defaults to 80.^@  --tab-width <int>    Specify the number of spaces
per indentation-level. Defaults to 2.^@  --flow-parser        Use the flow parser instead of babylon^@  --single-quote       Use single quotes instead of dou
ble^@  --trailing-comma     Print trailing commas wherever possible^@  --bracket-spacing    Put spaces between brackets. Defaults to true, set false to turn
off^@
    :PrettierCliPath
prettier

😂
All good after yarn global add prettier installed 1.11.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants