From 02fdfcda58857855d80ddb6eb3a26b3bc36ccbb0 Mon Sep 17 00:00:00 2001 From: matthias Date: Thu, 16 Aug 2018 16:44:41 +0200 Subject: [PATCH 1/2] Added phpcs options support as described in #257 --- ale_linters/php/phpcs.vim | 6 +++++- doc/ale-php.txt | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 25e53714..45f57cda 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -3,6 +3,7 @@ let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '') +call ale#Set('php_phpcs_options', '') call ale#Set('php_phpcs_executable', 'phpcs') call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0)) @@ -11,8 +12,11 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort let l:standard_option = !empty(l:standard) \ ? '--standard=' . l:standard \ : '' + let l:options = ale#Var(a:buffer, 'php_phpcs_options') - return '%e -s --report=emacs --stdin-path=%s' . ale#Pad(l:standard_option) + return '%e -s --report=emacs --stdin-path=%s' + \ . ale#Pad(l:standard_option) + \ . ' ' . l:options endfunction function! ale_linters#php#phpcs#Handle(buffer, lines) abort diff --git a/doc/ale-php.txt b/doc/ale-php.txt index ba53db89..f38c3f88 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -114,6 +114,13 @@ g:ale_php_phpcs_use_global *g:ale_php_phpcs_use_global* See |ale-integrations-local-executables| +g:ale_php_phpcs_options *g:ale_php_phpcs_options* + *b:ale_php_phpcs_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cs + =============================================================================== phpmd *ale-php-phpmd* From f82ab768333d677f692d6301230c55108bf66d40 Mon Sep 17 00:00:00 2001 From: matthias Date: Sat, 18 Aug 2018 20:59:35 +0200 Subject: [PATCH 2/2] Added and fixed tests --- ale_linters/php/phpcs.vim | 2 +- test/command_callback/test_phpcs_command_callback.vader | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 45f57cda..408c2652 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -16,7 +16,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort return '%e -s --report=emacs --stdin-path=%s' \ . ale#Pad(l:standard_option) - \ . ' ' . l:options + \ . ale#Pad(l:options) endfunction function! ale_linters#php#phpcs#Handle(buffer, lines) abort diff --git a/test/command_callback/test_phpcs_command_callback.vader b/test/command_callback/test_phpcs_command_callback.vader index 941a92d6..e5d2f449 100644 --- a/test/command_callback/test_phpcs_command_callback.vader +++ b/test/command_callback/test_phpcs_command_callback.vader @@ -27,3 +27,9 @@ Execute(Projects without local executables should use the global one): AssertLinter 'phpcs', \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s' + +Execute(User provided options are used): + let g:ale_php_phpcs_options = '--my-user-provided-option my-value' + + AssertLinter 'phpcs', + \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s --my-user-provided-option my-value'