vim-prettier
vim-prettier copied to clipboard
Autoformat on save not working for PHP / Twig files
Do you want to request a feature or report a bug?
Bug.
What is the current/expected behavior?
Currently it's not formatting PHP files on save.
I can successfully format them myself by running :Prettier
.
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
) ?
It's a local install:
/Users/harmen/Code/subsidieportaal/node_modules/.bin/prettier
Did this work in previous versions of vim-prettier and/or prettier ?
I don't know.
I feel stupid for even bringing up this basic issue, but I don't know how to debug this?
I have the prettier-php
plugin installed locally ("@prettier/plugin-php": "^0.14.3",
), and it does seem to work when I run :Prettier
manually, but it's not formatting on save.
I can reproduce this with the following minimal vimrc:
set nocompatible
filetype off
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'prettier/vim-prettier'
call vundle#end()
filetype plugin indent on
syntax on
I then open a new PHP file like this:
vim -u test.vimrc foo.php
Using :Prettier
manually works great, but on save nothing happens.
this affects me too, but I only tested on pure PHP Files.
I made work on save by adding this line to my vimrc:
autocmd BufWritePre *.php Prettier
and now is working well.
tip: you can Change Prettier to PrettierAsync if you use vim 8+
One last question what's the purpose of these lines in these issue?
let b:prettier_ft_default_args = {
\ 'parser': 'php',
\ }
I add them on my vimrc index and see no diference when I save the php file
Seems like this was fixed by #272, but there hasn't been a new release since then.