Skip to content

Commit

Permalink
Add prettier to php formatters (#394)
Browse files Browse the repository at this point in the history
I added prettier to the PHP formatters as prettier also works with PHP with the [php-plugin](https://github.com/prettier/plugin-php).
  • Loading branch information
mogottsch authored Jan 17, 2022
1 parent 74c91bb commit d31b425
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ that caused Neoformat to be invoked.
- PHP
- [`php_beautifier`](http://pear.php.net/package/PHP_Beautifier),
[`php-cs-fixer`](http://cs.sensiolabs.org/),
[`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer)
[`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer),
[`prettier`](https://github.com/prettier/plugin-php)
- PowerShell
- [`PSScriptAnalyzer`](https://github.com/PowerShell/PSScriptAnalyzer),
[`PowerShell-Beautifier`](https://github.com/DTW-DanWard/PowerShell-Beautifier)
Expand Down
11 changes: 10 additions & 1 deletion autoload/neoformat/formatters/php.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#php#enabled() abort
return ['phpbeautifier', 'phpcsfixer', 'phpcbf']
return ['phpbeautifier', 'phpcsfixer', 'phpcbf', 'prettier']
endfunction

function! neoformat#formatters#php#phpbeautifier() abort
Expand All @@ -24,3 +24,12 @@ function! neoformat#formatters#php#phpcbf() abort
\ 'valid_exit_codes': [0,1],
\ }
endfunction

function! neoformat#formatters#php#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
1 change: 1 addition & 0 deletions doc/neoformat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- [`php_beautifier`](http://pear.php.net/package/PHP_Beautifier)
- [`php-cs-fixer`](http://cs.sensiolabs.org/)
- [`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer)
- [`prettier`](https://github.com/prettier/plugin-php)
- PowerShell
- [`PSScriptAnalyzer`](https://github.com/PowerShell/PSScriptAnalyzer),
[`PowerShell-Beautifier`](https://github.com/DTW-DanWard/PowerShell-Beautifier)
Expand Down

0 comments on commit d31b425

Please sign in to comment.