Add g:ale_php_cs_fixer_options variable (#1477)
* Add g:ale_php_cs_fixer_options variable * Fix test
This commit is contained in:
parent
bb775e4e22
commit
121e806423
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
call ale#Set('php_cs_fixer_executable', 'php-cs-fixer')
|
call ale#Set('php_cs_fixer_executable', 'php-cs-fixer')
|
||||||
call ale#Set('php_cs_fixer_use_global', 0)
|
call ale#Set('php_cs_fixer_use_global', 0)
|
||||||
|
call ale#Set('php_cs_fixer_options', '')
|
||||||
|
|
||||||
function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort
|
function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort
|
||||||
return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [
|
return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [
|
||||||
@ -14,10 +15,9 @@ endfunction
|
|||||||
function! ale#fixers#php_cs_fixer#Fix(buffer) abort
|
function! ale#fixers#php_cs_fixer#Fix(buffer) abort
|
||||||
let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer)
|
let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer)
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable) . ' fix %t',
|
\ 'command': ale#Escape(l:executable)
|
||||||
|
\ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options')
|
||||||
|
\ . ' fix %t',
|
||||||
\ 'read_temporary_file': 1,
|
\ 'read_temporary_file': 1,
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,5 +183,12 @@ g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global*
|
|||||||
|
|
||||||
This variable force globally installed fixer.
|
This variable force globally installed fixer.
|
||||||
|
|
||||||
|
g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options*
|
||||||
|
*b:ale_php_cs_fixer_options*
|
||||||
|
Type: |String|
|
||||||
|
Default: `''`
|
||||||
|
|
||||||
|
This variable can be set to pass additional options to php-cs-fixer.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
Before:
|
Before:
|
||||||
Save g:ale_php_cs_fixer_executable
|
Save g:ale_php_cs_fixer_executable
|
||||||
|
Save g:ale_php_cs_fixer_options
|
||||||
let g:ale_php_cs_fixer_executable = 'php-cs-fixer'
|
let g:ale_php_cs_fixer_executable = 'php-cs-fixer'
|
||||||
|
let g:ale_php_cs_fixer_options = ''
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
silent cd ..
|
silent cd ..
|
||||||
@ -42,5 +44,22 @@ Execute(The php-cs-fixer callback should return the correct default values):
|
|||||||
call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/foo/test.php')
|
call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/foo/test.php')
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {'read_temporary_file': 1, 'command': ale#Escape('php-cs-fixer') . ' fix %t' },
|
\ {
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ 'command': ale#Escape('php-cs-fixer')
|
||||||
|
\ . ' ' . g:ale_php_cs_fixer_options
|
||||||
|
\ . ' fix %t'
|
||||||
|
\ },
|
||||||
|
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
|
||||||
|
|
||||||
|
Execute(The php-cs-fixer callback should include custom php-cs-fixer options):
|
||||||
|
let g:ale_php_cs_fixer_options = '--config="$HOME/.php_cs"'
|
||||||
|
call ale#test#SetFilename('php_paths/project-without-php-cs-fixer/test.php')
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ {
|
||||||
|
\ 'command': ale#Escape(g:ale_php_cs_fixer_executable)
|
||||||
|
\ . ' --config="$HOME/.php_cs" fix %t',
|
||||||
|
\ 'read_temporary_file': 1,
|
||||||
|
\ },
|
||||||
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
|
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user