diff options
-rw-r--r-- | ale_linters/go/gobuild.vim | 34 | ||||
-rw-r--r-- | ale_linters/php/phpcs.vim | 6 | ||||
-rw-r--r-- | doc/ale-php.txt | 7 | ||||
-rw-r--r-- | doc/ale.txt | 2 | ||||
-rw-r--r-- | test/command_callback/test_gobuild_command_callback.vader | 25 | ||||
-rw-r--r-- | test/command_callback/test_phpcs_command_callback.vader | 6 |
6 files changed, 27 insertions, 53 deletions
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim index c4608071..2d6febdd 100644 --- a/ale_linters/go/gobuild.vim +++ b/ale_linters/go/gobuild.vim @@ -5,35 +5,11 @@ call ale#Set('go_gobuild_options', '') -function! ale_linters#go#gobuild#ResetEnv() abort - unlet! s:go_env -endfunction - -function! ale_linters#go#gobuild#GoEnv(buffer) abort - if exists('s:go_env') - return '' - endif - - return 'go env GOPATH GOROOT' -endfunction - -function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort +function! ale_linters#go#gobuild#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_gobuild_options') - if !exists('s:go_env') - let s:go_env = { - \ 'GOPATH': a:goenv_output[0], - \ 'GOROOT': a:goenv_output[1], - \} - endif - - let l:gopath_env_command = has('win32') - \ ? 'set GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' && ' - \ : 'GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' ' - " Run go test in local directory with relative path - return l:gopath_env_command - \ . ale#path#BufferCdString(a:buffer) + return ale#path#BufferCdString(a:buffer) \ . 'go test' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -c -o /dev/null ./' @@ -73,10 +49,8 @@ call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], \ 'executable': 'go', -\ 'command_chain': [ -\ {'callback': 'ale_linters#go#gobuild#GoEnv', 'output_stream': 'stdout'}, -\ {'callback': 'ale_linters#go#gobuild#GetCommand', 'output_stream': 'stderr'}, -\ ], +\ 'command_callback': 'ale_linters#go#gobuild#GetCommand', +\ 'output_stream': 'stderr', \ 'callback': 'ale_linters#go#gobuild#Handler', \ 'lint_file': 1, \}) diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 25e53714..408c2652 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) + \ . ale#Pad(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* diff --git a/doc/ale.txt b/doc/ale.txt index 1bcccd41..416a48ff 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2692,7 +2692,7 @@ ALEFixPost *ALEFixPost-autocmd* augroup ALEProgress autocmd! autocmd User ALELintPre hi Statusline ctermfg=darkgrey - autocmd User ALELintPOST hi Statusline ctermfg=NONE + autocmd User ALELintPost hi Statusline ctermfg=NONE augroup end < Or to display the progress in the statusline: diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index 86113728..f9673213 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -1,36 +1,19 @@ Before: call ale#assert#SetUpLinterTest('go', 'gobuild') - let g:env_prefix = has('win32') - \ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && ' - \ : 'GOPATH=' . ale#Escape('/foo/bar') . ' ' - call ale_linters#go#gobuild#ResetEnv() - WithChainResults ['/foo/bar', '/foo/baz'] After: - unlet! g:env_prefix call ale#assert#TearDownLinterTest() Execute(The default commands should be correct): - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' - \ . 'go test -c -o /dev/null ./' - \] - - " We shouldn't run `go env` many times after we've got it. - AssertLinter 'go', [ - \ '', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'go test -c -o /dev/null ./' - \] Execute(Extra options should be supported): let g:ale_go_gobuild_options = '--foo-bar' - AssertLinter 'go', [ - \ 'go env GOPATH GOROOT', - \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + AssertLinter 'go', + \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' \ . 'go test --foo-bar -c -o /dev/null ./' - \] 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' |