vim-prettier
vim-prettier copied to clipboard
Prettier: failed to parse buffer — on mixed HTML/PHP file
Do you want to request a feature or report a bug? Either a configuration issue, unsupported functionality or a bug.
What is the current/expected behavior?
When working with PHP template files of the Kirby CMS system, vim-prettier is unable to format the files and aborts with a Prettier: failed to parse buffer
error. The file extension and loaded filetype is php
(file name is default.php) but contains mostly HTML. Excerpt:
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<meta name="description" content="something here" />
<meta name="robots" content="index,follow" />
<meta name="revisit-after" content="2 days" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?= $page->title() ?></title>
<?= css(["assets/css/main.min.css", "@auto"]) ?>
</head>
<body>
<header class="section">HEADER</header>
<main class="section">
<div class="columns">
<div class="column">
<article>
[...]
If I install @prettier/plugin-php
, the error disappears and the PHP part of the file gets formatted. All of the HTML is left untouched though.
Setting ft=html
, either directly or via mode line does not change this behavior, only renaming the file to have an .html
extension works. This breaks the CMS expectations regarding file naming however, making this untenable.
Is this a bug or expected behavior? If expected, how do I get this setup to work? I'm looking to format the HTML content of the files. Ideally, the PHP plugin would work as well but I don't care too much about that. Alternatively, as I'm using ALE, I'm very much open regarding ideas how to make this work but I should probably ask their community.
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.4.1
What is your prettier
executable path - (output of :PrettierCliPath
) ?
prettier
Did this work in previous versions of vim-prettier and/or prettier ? unknown
Im getting the same error, but with jsx and nextjs