Skip to content

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

@ghost

Description

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions