diff options
author | Michael Dyrynda <michael@dyrynda.com.au> | 2022-07-07 22:12:21 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 21:42:21 +0900 |
commit | ad2f75e4b207debb3b7cf2a007dd2d205fe603bd (patch) | |
tree | 8ec84d74eeb6a7ad9de930f5dccb1ec471e7dffa /autoload | |
parent | a918f8c7bc7faa8b035fecf23aa35d395d0636c4 (diff) | |
download | ale-ad2f75e4b207debb3b7cf2a007dd2d205fe603bd.zip |
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
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/pint.vim | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 57fff655..e9b289c6 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -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'], diff --git a/autoload/ale/fixers/pint.vim b/autoload/ale/fixers/pint.vim new file mode 100644 index 00000000..274ddd9e --- /dev/null +++ b/autoload/ale/fixers/pint.vim @@ -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 + |