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

Autoformat on save not working for PHP / Twig files #263

Open
harmenjanssen opened this issue Sep 16, 2020 · 3 comments
Open

Autoformat on save not working for PHP / Twig files #263

harmenjanssen opened this issue Sep 16, 2020 · 3 comments

Comments

@harmenjanssen
Copy link

harmenjanssen commented Sep 16, 2020

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.

@harmenjanssen
Copy link
Author

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.

@Rodrigo-Barros
Copy link

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

@avrahamappel
Copy link

Seems like this was fixed by #272, but there hasn't been a new release since then.

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

No branches or pull requests

3 participants