forked from github-mirrors/ale
Add support for Laravel Pint (#4238)
* add support, docs, tests for Laravel Pint * fix php-cs-fixer link * add missing project-without-pint * fix indentation * fix pint executable in pint fixer test * fix variables, docs related to pint support
This commit is contained in:
parent
a918f8c7bc
commit
ad2f75e4b2
|
@ -231,6 +231,11 @@ let s:default_registry = {
|
|||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with php-cs-fixer.',
|
||||
\ },
|
||||
\ 'pint': {
|
||||
\ 'function': 'ale#fixers#pint#Fix',
|
||||
\ 'suggested_filetypes': ['php'],
|
||||
\ 'description': 'Fix PHP files with Laravel Pint.',
|
||||
\ },
|
||||
\ 'astyle': {
|
||||
\ 'function': 'ale#fixers#astyle#Fix',
|
||||
\ 'suggested_filetypes': ['c', 'cpp'],
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
" Author: Michael Dyrynda <michael@dyrynda.com.au>
|
||||
" Description: Fixing files with Laravel Pint.
|
||||
|
||||
call ale#Set('php_pint_executable', 'pint')
|
||||
call ale#Set('php_pint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('php_pint_options', '')
|
||||
|
||||
function! ale#fixers#pint#GetExecutable(buffer) abort
|
||||
return ale#path#FindExecutable(a:buffer, 'php_pint', [
|
||||
\ 'vendor/bin/pint',
|
||||
\ 'pint'
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#pint#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#pint#GetExecutable(a:buffer)
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' ' . ale#Var(a:buffer, 'php_pint_options')
|
||||
\ . ' %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
endfunction
|
||||
|
|
@ -272,6 +272,33 @@ g:ale_php_php_executable *g:ale_php_php_executable*
|
|||
This variable sets the executable used for php.
|
||||
|
||||
|
||||
===============================================================================
|
||||
pint *ale-php-pint*
|
||||
|
||||
g:ale_php_pint_executable *g:ale_php_pint_executable*
|
||||
*b:ale_php_pint_executable*
|
||||
Type: |String|
|
||||
Default: `'pint'`
|
||||
|
||||
This variable sets the executable used for pint.
|
||||
|
||||
|
||||
g:ale_php_pint_options *g:ale_php_pint_options*
|
||||
*b:ale_php_pint_options*
|
||||
Type: |String|
|
||||
Default: `''`
|
||||
|
||||
This variable can be set to pass additional options to pint.
|
||||
|
||||
|
||||
g:ale_php_pint_use_global *g:ale_php_pint_use_global*
|
||||
*b:ale_php_pint_use_global*
|
||||
Type: |Boolean|
|
||||
Default: `get(g:, 'ale_use_global_executables', 0)`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
===============================================================================
|
||||
tlint *ale-php-tlint*
|
||||
|
||||
|
|
|
@ -417,6 +417,7 @@ Notes:
|
|||
* `phpcs`
|
||||
* `phpmd`
|
||||
* `phpstan`
|
||||
* `pint`
|
||||
* `psalm`!!
|
||||
* `tlint`
|
||||
* PO
|
||||
|
|
|
@ -3071,6 +3071,7 @@ documented in additional help files.
|
|||
psalm.................................|ale-php-psalm|
|
||||
php-cs-fixer..........................|ale-php-php-cs-fixer|
|
||||
php...................................|ale-php-php|
|
||||
pint..................................|ale-php-pint|
|
||||
tlint.................................|ale-php-tlint|
|
||||
intelephense..........................|ale-php-intelephense|
|
||||
po......................................|ale-po-options|
|
||||
|
|
|
@ -420,12 +420,13 @@ formatting.
|
|||
* [langserver](https://github.com/felixfbecker/php-language-server)
|
||||
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
|
||||
* [php -l](https://secure.php.net/)
|
||||
* [php-cs-fixer](http://cs.sensiolabs.org/)
|
||||
* [php-cs-fixer](https://cs.symfony.com)
|
||||
* [phpactor](https://github.com/phpactor/phpactor)
|
||||
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||
* [phpcs](https://github.com/squizlabs/PHP_CodeSniffer)
|
||||
* [phpmd](https://phpmd.org)
|
||||
* [phpstan](https://github.com/phpstan/phpstan)
|
||||
* [pint](https://github.com/laravel/pint) :beer:
|
||||
* [psalm](https://getpsalm.org) :floppy_disk:
|
||||
* [tlint](https://github.com/tightenco/tlint)
|
||||
* PO
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
Before:
|
||||
Save g:ale_php_pint_executable
|
||||
Save g:ale_php_pint_options
|
||||
let g:ale_php_pint_executable = 'pint'
|
||||
let g:ale_php_pint_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
|
||||
Execute(project with pint should use local by default):
|
||||
call ale#test#SetFilename('../test-files/php/project-with-pint/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/php/project-with-pint/vendor/bin/pint'),
|
||||
\ ale#fixers#pint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use-global should override local detection):
|
||||
let g:ale_php_pint_use_global = 1
|
||||
call ale#test#SetFilename('../test-files/php/project-with-pint/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ 'pint',
|
||||
\ ale#fixers#pint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(project without pint should use global):
|
||||
call ale#test#SetFilename('../test-files/php/project-without-pint/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ 'pint',
|
||||
\ ale#fixers#pint#GetExecutable(bufnr(''))
|
||||
|
||||
|
||||
|
||||
|
||||
Execute(The pint callback should return the correct default values):
|
||||
call ale#test#SetFilename('../test-files/php/project-without-pint/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('pint')
|
||||
\ . ' ' . g:ale_php_pint_options
|
||||
\ . ' %t'
|
||||
\ },
|
||||
\ ale#fixers#pint#Fix(bufnr(''))
|
||||
|
||||
Execute(The pint callback should include custom pint options):
|
||||
let g:ale_php_pint_options = '--test'
|
||||
call ale#test#SetFilename('../test-files/php/project-without-pint/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape(g:ale_php_pint_executable)
|
||||
\ . ' --test %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\ },
|
||||
\ ale#fixers#pint#Fix(bufnr(''))
|
Loading…
Reference in New Issue