summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CONTRIBUTING.md2
-rw-r--r--README.md8
-rw-r--r--ale_linters/asm/gcc.vim13
-rw-r--r--ale_linters/awk/gawk.vim18
-rw-r--r--ale_linters/c/clang.vim11
-rw-r--r--ale_linters/c/clangd.vim11
-rw-r--r--ale_linters/c/clangtidy.vim8
-rw-r--r--ale_linters/c/cppcheck.vim9
-rw-r--r--ale_linters/c/cquery.vim16
-rw-r--r--ale_linters/c/flawfinder.vim12
-rw-r--r--ale_linters/c/gcc.vim11
-rw-r--r--ale_linters/chef/foodcritic.vim11
-rw-r--r--ale_linters/cpp/clang.vim11
-rw-r--r--ale_linters/cpp/clangcheck.vim11
-rw-r--r--ale_linters/cpp/clangtidy.vim8
-rw-r--r--ale_linters/cpp/cppcheck.vim9
-rw-r--r--ale_linters/cpp/cpplint.vim10
-rw-r--r--ale_linters/cpp/cquery.vim17
-rw-r--r--ale_linters/cpp/flawfinder.vim10
-rw-r--r--ale_linters/cpp/gcc.vim11
-rw-r--r--ale_linters/css/stylelint.vim13
-rw-r--r--ale_linters/cuda/nvcc.vim15
-rw-r--r--ale_linters/dart/dartanalyzer.vim9
-rw-r--r--ale_linters/dart/language_server.vim6
-rw-r--r--ale_linters/elm/make.vim26
-rw-r--r--ale_linters/erlang/syntaxerl.vim24
-rw-r--r--ale_linters/fortran/gcc.vim28
-rw-r--r--ale_linters/fortran/language_server.vim12
-rw-r--r--ale_linters/fuse/fusionlint.vim9
-rw-r--r--ale_linters/gitcommit/gitlint.vim17
-rw-r--r--ale_linters/glsl/glslang.vim14
-rw-r--r--ale_linters/glsl/glslls.vim11
-rw-r--r--ale_linters/go/gometalinter.vim11
-rw-r--r--ale_linters/hack/hack.vim22
-rw-r--r--ale_linters/hack/hhast.vim40
-rw-r--r--ale_linters/handlebars/embertemplatelint.vim17
-rw-r--r--ale_linters/haskell/hdevtools.vim11
-rw-r--r--ale_linters/haskell/hie.vim44
-rw-r--r--ale_linters/html/htmlhint.vim14
-rw-r--r--ale_linters/html/tidy.vim6
-rw-r--r--ale_linters/idris/idris.vim11
-rw-r--r--ale_linters/java/javac.vim10
-rw-r--r--ale_linters/javascript/flow_ls.vim18
-rw-r--r--ale_linters/javascript/jscs.vim14
-rw-r--r--ale_linters/javascript/jshint.vim13
-rw-r--r--ale_linters/javascript/tsserver.vim19
-rw-r--r--ale_linters/kotlin/languageserver.vim13
-rwxr-xr-xale_linters/less/lessc.vim21
-rw-r--r--ale_linters/less/stylelint.vim15
-rw-r--r--ale_linters/llvm/llc.vim16
-rw-r--r--ale_linters/lua/luac.vim13
-rw-r--r--ale_linters/lua/luacheck.vim16
-rw-r--r--ale_linters/markdown/remark_lint.vim15
-rw-r--r--ale_linters/matlab/mlint.vim17
-rw-r--r--ale_linters/mercury/mmc.vim9
-rw-r--r--ale_linters/nasm/nasm.vim24
-rw-r--r--ale_linters/objc/clang.vim2
-rw-r--r--ale_linters/objcpp/clang.vim2
-rw-r--r--ale_linters/perl/perl.vim17
-rw-r--r--ale_linters/perl/perlcritic.vim25
-rw-r--r--ale_linters/php/hack.vim28
-rw-r--r--ale_linters/php/langserver.vim16
-rw-r--r--ale_linters/php/phpcs.vim17
-rw-r--r--ale_linters/php/phpmd.vim13
-rw-r--r--ale_linters/php/phpstan.vim11
-rw-r--r--ale_linters/pony/ponyc.vim9
-rw-r--r--ale_linters/pug/puglint.vim14
-rw-r--r--ale_linters/puppet/languageserver.vim14
-rw-r--r--ale_linters/puppet/puppetlint.vim16
-rw-r--r--ale_linters/pyrex/cython.vim11
-rw-r--r--ale_linters/qml/qmlfmt.vim33
-rw-r--r--ale_linters/ruby/ruby.vim14
-rw-r--r--ale_linters/rust/rls.vim13
-rw-r--r--ale_linters/sass/stylelint.vim17
-rw-r--r--ale_linters/scala/fsc.vim23
-rw-r--r--ale_linters/scala/scalac.vim23
-rw-r--r--ale_linters/scss/stylelint.vim17
-rw-r--r--ale_linters/sh/shellcheck.vim11
-rw-r--r--ale_linters/spec/rpmlint.vim17
-rw-r--r--ale_linters/stylus/stylelint.vim14
-rw-r--r--ale_linters/tcl/nagelfar.vim10
-rw-r--r--ale_linters/terraform/tflint.vim11
-rw-r--r--ale_linters/tex/lacheck.vim15
-rw-r--r--ale_linters/thrift/thrift.vim8
-rw-r--r--ale_linters/typescript/tsserver.vim19
-rw-r--r--ale_linters/vim/ale_custom_linting_rules.vim57
-rw-r--r--ale_linters/vue/vls.vim18
-rw-r--r--ale_linters/xml/xmllint.vim8
-rw-r--r--ale_linters/yaml/swaglint.vim17
-rw-r--r--ale_linters/yaml/yamllint.vim16
-rw-r--r--ale_linters/yang/yang_lsp.vim14
-rw-r--r--autoload/ale.vim5
-rw-r--r--autoload/ale/assert.vim42
-rw-r--r--autoload/ale/c.vim12
-rw-r--r--autoload/ale/fix/registry.vim2
-rw-r--r--autoload/ale/fixers/hackfmt.vim8
-rw-r--r--autoload/ale/fixers/prettier.vim41
-rw-r--r--autoload/ale/handlers/gcc.vim86
-rw-r--r--autoload/ale/linter.vim2
-rw-r--r--autoload/ale/lsp.vim17
-rw-r--r--autoload/ale/lsp/response.vim16
-rw-r--r--autoload/ale/node.vim5
-rw-r--r--autoload/ale/python.vim1
-rw-r--r--autoload/ale/util.vim4
-rw-r--r--doc/ale-hack.txt51
-rw-r--r--doc/ale-haskell.txt11
-rw-r--r--doc/ale-php.txt18
-rw-r--r--doc/ale-python.txt1
-rw-r--r--doc/ale-rust.txt5
-rw-r--r--doc/ale-typescript.txt10
-rw-r--r--doc/ale-yaml.txt14
-rw-r--r--doc/ale-yang.txt17
-rw-r--r--doc/ale.txt42
-rw-r--r--plugin/ale.vim4
-rw-r--r--test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json (renamed from test/hack_files/testfile.php)0
-rw-r--r--test/command_callback/cquery_paths/with_cquery/.cquery0
-rw-r--r--test/command_callback/test_c_cquery_command_callbacks.vader33
-rw-r--r--test/command_callback/test_c_flawfinder_command_callbacks.vader2
-rw-r--r--test/command_callback/test_c_import_paths.vader223
-rw-r--r--test/command_callback/test_cpp_cquery_command_callbacks.vader14
-rw-r--r--test/command_callback/test_cuda_nvcc_command_callbacks.vader6
-rw-r--r--test/command_callback/test_elm_make_command_callback.vader32
-rw-r--r--test/command_callback/test_fsc_command_callback.vader2
-rw-r--r--test/command_callback/test_gawk_command_callback.vader6
-rw-r--r--test/command_callback/test_gfortran_command_callback.vader8
-rw-r--r--test/command_callback/test_haskell_hie_callbacks.vader27
-rw-r--r--test/command_callback/test_javascript_tsserver_command_callback.vader8
-rw-r--r--test/command_callback/test_luac_command_callback.vader4
-rw-r--r--test/command_callback/test_luacheck_command_callback.vader4
-rw-r--r--test/command_callback/test_mercury_mmc_command_callback.vader6
-rw-r--r--test/command_callback/test_nasm_nasm_command_callbacks.vader2
-rw-r--r--test/command_callback/test_phpcs_command_callback.vader29
-rw-r--r--test/command_callback/test_scalac_command_callback.vader2
-rw-r--r--test/command_callback/test_swaglint_command_callback.vader8
-rw-r--r--test/command_callback/test_terraform_tflint_command_callback.vader9
-rw-r--r--test/command_callback/test_typescript_tsserver_command_callback.vader8
-rw-r--r--test/command_callback/test_yang_lsp_command_callbacks.vader12
-rw-r--r--test/fixers/test_hackfmt_fixer_callback.vader14
-rw-r--r--test/fixers/test_prettier_fixer_callback.vader32
-rw-r--r--test/handler/test_clang_handler.vader15
-rw-r--r--test/handler/test_gcc_handler.vader81
-rw-r--r--test/lsp/test_read_lsp_diagnostics.vader29
-rw-r--r--test/test_c_import_paths.vader254
-rw-r--r--test/test_elm_executable_detection.vader36
-rw-r--r--test/test_engine_lsp_response_handling.vader4
-rw-r--r--test/test_go_to_definition.vader10
-rw-r--r--test/test_ignoring_linters.vader1
-rw-r--r--test/test_phpcs_executable_detection.vader39
-rw-r--r--test/test_tflint_config_detection.vader18
149 files changed, 1384 insertions, 1388 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index e59f8326..f2e7474c 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -3,7 +3,7 @@
Have fun, and work on whatever floats your boat. Take It Easy :tm:.
For help with contributing to ALE, see `:help ale-development` in Vim, or view
-the help file online [here](/w0rp/ale/blob/master/doc/ale-development.txt).
+the help file online [here](/doc/ale-development.txt).
## Creating Issues
diff --git a/README.md b/README.md
index bc7b1ee6..cd11d323 100644
--- a/README.md
+++ b/README.md
@@ -126,9 +126,10 @@ formatting.
| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/) !!, [golint](https://godoc.org/github.com/golang/lint), [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) !!, [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint), [prettier](https://github.com/prettier/prettier) |
+| Hack | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/hhvm/tree/master/hphp/hack/hackfmt), [hhast](https://github.com/hhvm/hhast) (disabled by default; see `:help ale-integration-hack`) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
| Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) |
-| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [cabal-ghc](https://www.haskell.org/cabal/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt) |
+| Haskell | [brittany](https://github.com/lspitzner/brittany), [ghc](https://www.haskell.org/ghc/), [cabal-ghc](https://www.haskell.org/cabal/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt), [hie](https://github.com/haskell/haskell-ide-engine) |
| HTML | [alex](https://github.com/wooorm/alex) !!, [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [write-good](https://github.com/btford/write-good) |
| Idris | [idris](http://www.idris-lang.org/) |
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/) |
@@ -152,7 +153,7 @@ formatting.
| Objective-C++ | [clang](http://clang.llvm.org/) |
| OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions, [ols](https://github.com/freebroccolo/ocaml-language-server) |
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic), [perltidy](https://metacpan.org/pod/distribution/Perl-Tidy/bin/perltidy) |
-| PHP | [hack](http://hacklang.org/), [hackfmt](https://github.com/facebook/flow/tree/master/hack/hackfmt), [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/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) |
+| PHP | [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/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer), [php-cs-fixer](http://cs.sensiolabs.org/) |
| PO | [alex](https://github.com/wooorm/alex) !!, [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html), [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
| Pod | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
| Pony | [ponyc](https://github.com/ponylang/ponyc) |
@@ -189,7 +190,8 @@ formatting.
| Vue | [prettier](https://github.com/prettier/prettier), [vls](https://github.com/vuejs/vetur/tree/master/server) |
| XHTML | [alex](https://github.com/wooorm/alex) !!, [proselint](http://proselint.com/), [write-good](https://github.com/btford/write-good) |
| XML | [xmllint](http://xmlsoft.org/xmllint.html) |
-| YAML | [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) |
+| YAML | [prettier](https://github.com/prettier/prettier), [swaglint](https://github.com/byCedric/swaglint), [yamllint](https://yamllint.readthedocs.io/) |
+| YANG | [yang-lsp](https://github.com/theia-ide/yang-lsp) |
<a name="usage"></a>
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim
index 4ac876f8..fdd0ee83 100644
--- a/ale_linters/asm/gcc.vim
+++ b/ale_linters/asm/gcc.vim
@@ -4,15 +4,10 @@
call ale#Set('asm_gcc_executable', 'gcc')
call ale#Set('asm_gcc_options', '-Wall')
-function! ale_linters#asm#gcc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'asm_gcc_executable')
-endfunction
-
function! ale_linters#asm#gcc#GetCommand(buffer) abort
- return ale#Escape(ale_linters#asm#gcc#GetExecutable(a:buffer))
- \ . ' -x assembler -fsyntax-only '
- \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
- \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
+ return '%e -x assembler -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
+ \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
@@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('asm', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#asm#gcc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('asm_gcc_executable'),
\ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
\ 'callback': 'ale_linters#asm#gcc#Handle',
\})
diff --git a/ale_linters/awk/gawk.vim b/ale_linters/awk/gawk.vim
index 8b60815f..eb92e45e 100644
--- a/ale_linters/awk/gawk.vim
+++ b/ale_linters/awk/gawk.vim
@@ -1,29 +1,21 @@
" Author: kmarc <korondi.mark@gmail.com>
" Description: This file adds support for using GNU awk with sripts.
-let g:ale_awk_gawk_executable =
-\ get(g:, 'ale_awk_gawk_executable', 'gawk')
-
-let g:ale_awk_gawk_options =
-\ get(g:, 'ale_awk_gawk_options', '')
-
-function! ale_linters#awk#gawk#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'awk_gawk_executable')
-endfunction
+call ale#Set('awk_gawk_executable', 'gawk')
+call ale#Set('awk_gawk_options', '')
function! ale_linters#awk#gawk#GetCommand(buffer) abort
" note the --source 'BEGIN ...' is to prevent
" gawk from attempting to execute the body of the script
" it is linting.
- return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer))
- \ . " --source 'BEGIN { exit } END { exit 1 }'"
+ return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
- \ . ' ' . '-f %t --lint /dev/null'
+ \ . ' -f %t --lint /dev/null'
endfunction
call ale#linter#Define('awk', {
\ 'name': 'gawk',
-\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable',
+\ 'executable_callback': ale#VarFunc('awk_gawk_executable'),
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
\ 'output_stream': 'both'
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim
index 48ea76dd..f1bd675b 100644
--- a/ale_linters/c/clang.vim
+++ b/ale_linters/c/clang.vim
@@ -4,17 +4,12 @@
call ale#Set('c_clang_executable', 'clang')
call ale#Set('c_clang_options', '-std=c11 -Wall')
-function! ale_linters#c#clang#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_clang_executable')
-endfunction
-
function! ale_linters#c#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
- return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer))
- \ . ' -S -x c -fsyntax-only'
+ return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
@@ -23,10 +18,10 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#c#clang#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#clang#GetCommand'}
\ ],
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/c/clangd.vim b/ale_linters/c/clangd.vim
index 5aa2e221..2c7c5c13 100644
--- a/ale_linters/c/clangd.vim
+++ b/ale_linters/c/clangd.vim
@@ -9,21 +9,14 @@ function! ale_linters#c#clangd#GetProjectRoot(buffer) abort
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
-function! ale_linters#c#clangd#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_clangd_executable')
-endfunction
-
function! ale_linters#c#clangd#GetCommand(buffer) abort
- let l:executable = ale_linters#c#clangd#GetExecutable(a:buffer)
- let l:options = ale#Var(a:buffer, 'c_clangd_options')
-
- return ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '')
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
endfunction
call ale#linter#Define('c', {
\ 'name': 'clangd',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#c#clangd#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_clangd_executable'),
\ 'command_callback': 'ale_linters#c#clangd#GetCommand',
\ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot',
\})
diff --git a/ale_linters/c/clangtidy.vim b/ale_linters/c/clangtidy.vim
index d456a5a2..84c103e6 100644
--- a/ale_linters/c/clangtidy.vim
+++ b/ale_linters/c/clangtidy.vim
@@ -16,10 +16,6 @@ call ale#Set('c_clangtidy_checks', ['*'])
call ale#Set('c_clangtidy_options', '')
call ale#Set('c_build_dir', '')
-function! ale_linters#c#clangtidy#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_clangtidy_executable')
-endfunction
-
function! s:GetBuildDirectory(buffer) abort
" Don't include build directory for header files, as compile_commands.json
" files don't consider headers to be translation units, and provide no
@@ -47,7 +43,7 @@ function! ale_linters#c#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'c_clangtidy_options')
\ : ''
- return ale#Escape(ale_linters#c#clangtidy#GetExecutable(a:buffer))
+ return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
@@ -57,7 +53,7 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'clangtidy',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#c#clangtidy#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_clangtidy_executable'),
\ 'command_callback': 'ale_linters#c#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim
index 4db93f74..5e8c7936 100644
--- a/ale_linters/c/cppcheck.vim
+++ b/ale_linters/c/cppcheck.vim
@@ -4,10 +4,6 @@
call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style')
-function! ale_linters#c#cppcheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_cppcheck_executable')
-endfunction
-
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
@@ -23,8 +19,7 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort
\ : ''
return l:cd_command
- \ . ale#Escape(ale_linters#c#cppcheck#GetExecutable(a:buffer))
- \ . ' -q --language=c '
+ \ . '%e -q --language=c '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'c_cppcheck_options')
\ . ' %t'
@@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
-\ 'executable_callback': 'ale_linters#c#cppcheck#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_cppcheck_executable'),
\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})
diff --git a/ale_linters/c/cquery.vim b/ale_linters/c/cquery.vim
index 208c226f..a20782a2 100644
--- a/ale_linters/c/cquery.vim
+++ b/ale_linters/c/cquery.vim
@@ -6,16 +6,12 @@ call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#c#cquery#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
- return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
-endfunction
-function! ale_linters#c#cquery#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_cquery_executable')
-endfunction
+ if empty(l:project_root)
+ let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
+ endif
-function! ale_linters#c#cquery#GetCommand(buffer) abort
- let l:executable = ale_linters#c#cquery#GetExecutable(a:buffer)
- return ale#Escape(l:executable)
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort
@@ -25,8 +21,8 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'cquery',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#c#cquery#GetExecutable',
-\ 'command_callback': 'ale_linters#c#cquery#GetCommand',
+\ 'executable_callback': ale#VarFunc('c_cquery_executable'),
+\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions',
\})
diff --git a/ale_linters/c/flawfinder.vim b/ale_linters/c/flawfinder.vim
index df6fbebe..7e1f6769 100644
--- a/ale_linters/c/flawfinder.vim
+++ b/ale_linters/c/flawfinder.vim
@@ -6,18 +6,12 @@ call ale#Set('c_flawfinder_options', '')
call ale#Set('c_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6)
-function! ale_linters#c#flawfinder#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_flawfinder_executable')
-endfunction
-
function! ale_linters#c#flawfinder#GetCommand(buffer) abort
-
" Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel')
- return ale#Escape(ale_linters#c#flawfinder#GetExecutable(a:buffer))
- \ . ' -CDQS'
- \ . ale#Var(a:buffer, 'c_flawfinder_options')
+ return '%e -CDQS'
+ \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options'))
\ . l:minlevel
\ . ' %t'
endfunction
@@ -25,7 +19,7 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'flawfinder',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#c#flawfinder#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_flawfinder_executable'),
\ 'command_callback': 'ale_linters#c#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\})
diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim
index 63fe87a6..60ecb712 100644
--- a/ale_linters/c/gcc.vim
+++ b/ale_linters/c/gcc.vim
@@ -4,17 +4,12 @@
call ale#Set('c_gcc_executable', 'gcc')
call ale#Set('c_gcc_options', '-std=c11 -Wall')
-function! ale_linters#c#gcc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'c_gcc_executable')
-endfunction
-
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
- return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer))
- \ . ' -S -x c -fsyntax-only'
+ return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
@@ -23,10 +18,10 @@ endfunction
call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('c_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#gcc#GetCommand'}
\ ],
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim
index 2c28246c..c86336d6 100644
--- a/ale_linters/chef/foodcritic.vim
+++ b/ale_linters/chef/foodcritic.vim
@@ -6,17 +6,10 @@
call ale#Set('chef_foodcritic_executable', 'foodcritic')
call ale#Set('chef_foodcritic_options', '')
-function! ale_linters#chef#foodcritic#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'chef_foodcritic_executable')
-endfunction
-
function! ale_linters#chef#foodcritic#GetCommand(buffer) abort
- let l:executable = ale_linters#chef#foodcritic#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'chef_foodcritic_options')
- return ale#Escape(l:executable)
- \ . (!empty(l:options) ? ' ' . escape(l:options, '~') : '')
- \ . ' %s'
+ return '%e' . ale#Pad(escape(l:options, '~')) . ' %s'
endfunction
function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
@@ -41,7 +34,7 @@ endfunction
call ale#linter#Define('chef', {
\ 'name': 'foodcritic',
-\ 'executable_callback': 'ale_linters#chef#foodcritic#GetExecutable',
+\ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'),
\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
\ 'callback': 'ale_linters#chef#foodcritic#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/cpp/clang.vim b/ale_linters/cpp/clang.vim
index 4f3c5b6f..649c5993 100644
--- a/ale_linters/cpp/clang.vim
+++ b/ale_linters/cpp/clang.vim
@@ -4,17 +4,12 @@
call ale#Set('cpp_clang_executable', 'clang++')
call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
-function! ale_linters#cpp#clang#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_clang_executable')
-endfunction
-
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
- return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer))
- \ . ' -S -x c++ -fsyntax-only'
+ return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -'
@@ -23,10 +18,10 @@ endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#clang#GetCommand'},
\ ],
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/cpp/clangcheck.vim b/ale_linters/cpp/clangcheck.vim
index 687991bd..c66d6702 100644
--- a/ale_linters/cpp/clangcheck.vim
+++ b/ale_linters/cpp/clangcheck.vim
@@ -5,10 +5,6 @@ call ale#Set('cpp_clangcheck_executable', 'clang-check')
call ale#Set('cpp_clangcheck_options', '')
call ale#Set('c_build_dir', '')
-function! ale_linters#cpp#clangcheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_clangcheck_executable')
-endfunction
-
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
@@ -22,17 +18,16 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
" The extra arguments in the command are used to prevent .plist files from
" being generated. These are only added if no build directory can be
" detected.
- return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer))
- \ . ' -analyze %s'
+ return '%e -analyze %s'
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
- \ . (!empty(l:user_options) ? ' ' . l:user_options : '')
+ \ . ale#Pad(l:user_options)
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangcheck',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim
index d683327f..930087a8 100644
--- a/ale_linters/cpp/clangtidy.vim
+++ b/ale_linters/cpp/clangtidy.vim
@@ -10,10 +10,6 @@ call ale#Set('cpp_clangtidy_checks', ['*'])
call ale#Set('cpp_clangtidy_options', '')
call ale#Set('c_build_dir', '')
-function! ale_linters#cpp#clangtidy#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_clangtidy_executable')
-endfunction
-
function! s:GetBuildDirectory(buffer) abort
" Don't include build directory for header files, as compile_commands.json
" files don't consider headers to be translation units, and provide no
@@ -41,7 +37,7 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
\ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
\ : ''
- return ale#Escape(ale_linters#cpp#clangtidy#GetExecutable(a:buffer))
+ return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
@@ -51,7 +47,7 @@ endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangtidy',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#cpp#clangtidy#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'),
\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim
index 8b2aa802..229d6133 100644
--- a/ale_linters/cpp/cppcheck.vim
+++ b/ale_linters/cpp/cppcheck.vim
@@ -4,10 +4,6 @@
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style')
-function! ale_linters#cpp#cppcheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_cppcheck_executable')
-endfunction
-
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
@@ -23,8 +19,7 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
\ : ''
return l:cd_command
- \ . ale#Escape(ale_linters#cpp#cppcheck#GetExecutable(a:buffer))
- \ . ' -q --language=c++ '
+ \ . '%e -q --language=c++ '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'cpp_cppcheck_options')
\ . ' %t'
@@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
-\ 'executable_callback': 'ale_linters#cpp#cppcheck#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})
diff --git a/ale_linters/cpp/cpplint.vim b/ale_linters/cpp/cpplint.vim
index 346ac815..d135fa79 100644
--- a/ale_linters/cpp/cpplint.vim
+++ b/ale_linters/cpp/cpplint.vim
@@ -4,22 +4,16 @@
call ale#Set('cpp_cpplint_executable', 'cpplint')
call ale#Set('cpp_cpplint_options', '')
-function! ale_linters#cpp#cpplint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_cpplint_executable')
-endfunction
-
function! ale_linters#cpp#cpplint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'cpp_cpplint_options')
- return ale#Escape(ale_linters#cpp#cpplint#GetExecutable(a:buffer))
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' %s'
+ return '%e' . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cpplint',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#cpp#cpplint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'),
\ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1,
diff --git a/ale_linters/cpp/cquery.vim b/ale_linters/cpp/cquery.vim
index 7997c843..b1c81989 100644
--- a/ale_linters/cpp/cquery.vim
+++ b/ale_linters/cpp/cquery.vim
@@ -7,16 +7,11 @@ call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
- return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
-endfunction
+ if empty(l:project_root)
+ let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
+ endif
-function! ale_linters#cpp#cquery#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_cquery_executable')
-endfunction
-
-function! ale_linters#cpp#cquery#GetCommand(buffer) abort
- let l:executable = ale_linters#cpp#cquery#GetExecutable(a:buffer)
- return ale#Escape(l:executable)
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort
@@ -26,8 +21,8 @@ endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cquery',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#cpp#cquery#GetExecutable',
-\ 'command_callback': 'ale_linters#cpp#cquery#GetCommand',
+\ 'executable_callback': ale#VarFunc('cpp_cquery_executable'),
+\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions',
\})
diff --git a/ale_linters/cpp/flawfinder.vim b/ale_linters/cpp/flawfinder.vim
index 5a7092cf..4f669bff 100644
--- a/ale_linters/cpp/flawfinder.vim
+++ b/ale_linters/cpp/flawfinder.vim
@@ -6,17 +6,11 @@ call ale#Set('cpp_flawfinder_options', '')
call ale#Set('cpp_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6)
-function! ale_linters#cpp#flawfinder#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_flawfinder_executable')
-endfunction
-
function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort
-
" Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel')
- return ale#Escape(ale_linters#cpp#flawfinder#GetExecutable(a:buffer))
- \ . ' -CDQS'
+ return '%e -CDQS'
\ . ale#Var(a:buffer, 'cpp_flawfinder_options')
\ . l:minlevel
\ . ' %t'
@@ -25,7 +19,7 @@ endfunction
call ale#linter#Define('cpp', {
\ 'name': 'flawfinder',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#cpp#flawfinder#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'),
\ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\})
diff --git a/ale_linters/cpp/gcc.vim b/ale_linters/cpp/gcc.vim
index 242e389e..9935b0bb 100644
--- a/ale_linters/cpp/gcc.vim
+++ b/ale_linters/cpp/gcc.vim
@@ -4,17 +4,12 @@
call ale#Set('cpp_gcc_executable', 'gcc')
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
-function! ale_linters#cpp#gcc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cpp_gcc_executable')
-endfunction
-
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
- return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer))
- \ . ' -S -x c++ -fsyntax-only'
+ return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
@@ -24,10 +19,10 @@ call ale#linter#Define('cpp', {
\ 'name': 'gcc',
\ 'aliases': ['g++'],
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cpp_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#gcc#GetCommand'},
\ ],
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/css/stylelint.vim b/ale_linters/css/stylelint.vim
index a16dfde2..6f8bef68 100644
--- a/ale_linters/css/stylelint.vim
+++ b/ale_linters/css/stylelint.vim
@@ -4,21 +4,16 @@ call ale#Set('css_stylelint_executable', 'stylelint')
call ale#Set('css_stylelint_options', '')
call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#css#stylelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'css_stylelint', [
- \ 'node_modules/.bin/stylelint',
- \])
-endfunction
-
function! ale_linters#css#stylelint#GetCommand(buffer) abort
- return ale_linters#css#stylelint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'css_stylelint_options')
+ return '%e ' . ale#Pad(ale#Var(a:buffer, 'css_stylelint_options'))
\ . ' --stdin-filename %s'
endfunction
call ale#linter#Define('css', {
\ 'name': 'stylelint',
-\ 'executable_callback': 'ale_linters#css#stylelint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('css_stylelint', [
+\ 'node_modules/.bin/stylelint',
+\ ]),
\ 'command_callback': 'ale_linters#css#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})
diff --git a/ale_linters/cuda/nvcc.vim b/ale_linters/cuda/nvcc.vim
index 3764fe9d..a3678910 100644
--- a/ale_linters/cuda/nvcc.vim
+++ b/ale_linters/cuda/nvcc.vim
@@ -4,20 +4,15 @@
call ale#Set('cuda_nvcc_executable', 'nvcc')
call ale#Set('cuda_nvcc_options', '-std=c++11')
-function! ale_linters#cuda#nvcc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'cuda_nvcc_executable')
-endfunction
-
function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
" Unused: use ale#util#nul_file
" let l:output_file = ale#util#Tempname() . '.ii'
" call ale#engine#ManageFile(a:buffer, l:output_file)
- return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer))
- \ . ' -cuda '
- \ . ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))
- \ . ale#Var(a:buffer, 'cuda_nvcc_options') . ' %s'
- \ . ' -o ' . g:ale#util#nul_file
+ return '%e -cuda'
+ \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
+ \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options'))
+ \ . ' %s -o ' . g:ale#util#nul_file
endfunction
function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
@@ -49,7 +44,7 @@ endfunction
call ale#linter#Define('cuda', {
\ 'name': 'nvcc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#cuda#nvcc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'),
\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
\ 'lint_file': 1,
diff --git a/ale_linters/dart/dartanalyzer.vim b/ale_linters/dart/dartanalyzer.vim
index ef33c9d4..26817df5 100644
--- a/ale_linters/dart/dartanalyzer.vim
+++ b/ale_linters/dart/dartanalyzer.vim
@@ -3,15 +3,10 @@
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
-function! ale_linters#dart#dartanalyzer#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'dart_dartanalyzer_executable')
-endfunction
-
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
- let l:executable = ale_linters#dart#dartanalyzer#GetExecutable(a:buffer)
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
- return ale#Escape(l:executable)
+ return '%e'
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
\ . ' %s'
endfunction
@@ -34,7 +29,7 @@ endfunction
call ale#linter#Define('dart', {
\ 'name': 'dartanalyzer',
-\ 'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable',
+\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'),
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/dart/language_server.vim b/ale_linters/dart/language_server.vim
index 2265e37a..14b6ab93 100644
--- a/ale_linters/dart/language_server.vim
+++ b/ale_linters/dart/language_server.vim
@@ -3,10 +3,6 @@
call ale#Set('dart_language_server_executable', 'dart_language_server')
-function! ale_linters#dart#language_server#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'dart_language_server_executable')
-endfunction
-
function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort
" Note: pub only looks for pubspec.yaml, there's no point in adding
" support for pubspec.yml
@@ -18,7 +14,7 @@ endfunction
call ale#linter#Define('dart', {
\ 'name': 'language_server',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#dart#language_server#GetExecutable',
+\ 'executable_callback': ale#VarFunc('dart_language_server_executable'),
\ 'command_callback': 'ale_linters#dart#language_server#GetExecutable',
\ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot',
\})
diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim
index 8231ad47..ddea983f 100644
--- a/ale_linters/elm/make.vim
+++ b/ale_linters/elm/make.vim
@@ -4,12 +4,6 @@
call ale#Set('elm_make_executable', 'elm')
call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#elm#make#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'elm_make', [
- \ 'node_modules/.bin/elm',
- \])
-endfunction
-
function! ale_linters#elm#make#Handle(buffer, lines) abort
let l:output = []
let l:unparsed_lines = []
@@ -147,7 +141,6 @@ endfunction
" If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
- let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer)
if empty(l:elm_json)
" Fallback to Elm 0.18
@@ -165,18 +158,15 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
" a sort of flag to tell the compiler not to generate an output file,
" which is why this is hard coded here.
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253
- let l:elm_cmd = ale#Escape(l:elm_exe)
- \ . ' make'
- \ . ' --report=json'
- \ . ' --output=/dev/null'
-
- return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t'
+ return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t'
endfunction
call ale#linter#Define('elm', {
-\ 'name': 'make',
-\ 'executable_callback': 'ale_linters#elm#make#GetExecutable',
-\ 'output_stream': 'both',
-\ 'command_callback': 'ale_linters#elm#make#GetCommand',
-\ 'callback': 'ale_linters#elm#make#Handle'
+\ 'name': 'make',
+\ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [
+\ 'node_modules/.bin/elm',
+\ ]),
+\ 'output_stream': 'both',
+\ 'command_callback': 'ale_linters#elm#make#GetCommand',
+\ 'callback': 'ale_linters#elm#make#Handle'
\})
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim
index 46ecdcb7..5b679743 100644
--- a/ale_linters/erlang/syntaxerl.vim
+++ b/ale_linters/erlang/syntaxerl.vim
@@ -3,24 +3,12 @@
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
-
-function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
-endfunction
-
-
-function! ale_linters#erlang#syntaxerl#FeatureCheck(buffer) abort
- return s:GetEscapedExecutable(a:buffer) . ' -h'
-endfunction
-
-
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
- return s:GetEscapedExecutable(a:buffer) . (l:use_b_option ? ' -b %s %t' : ' %t')
+ return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t')
endfunction
-
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
let l:loclist = []
@@ -36,17 +24,11 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
return l:loclist
endfunction
-
-function! s:GetEscapedExecutable(buffer) abort
- return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer))
-endfunction
-
-
call ale#linter#Define('erlang', {
\ 'name': 'syntaxerl',
-\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable',
+\ 'executable_callback': ale#VarFunc('erlang_syntaxerl_executable'),
\ 'command_chain': [
-\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'},
+\ {'callback': {-> '%e -h'}},
\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
\ ],
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim
index 5f2ac018..f1595789 100644
--- a/ale_linters/fortran/gcc.vim
+++ b/ale_linters/fortran/gcc.vim
@@ -2,18 +2,10 @@
" Description: gcc for Fortran files
" This option can be set to 0 to use -ffixed-form
-if !exists('g:ale_fortran_gcc_use_free_form')
- let g:ale_fortran_gcc_use_free_form = 1
-endif
-
-if !exists('g:ale_fortran_gcc_executable')
- let g:ale_fortran_gcc_executable = 'gcc'
-endif
-
+call ale#Set('fortran_gcc_use_free_form', 1)
+call ale#Set('fortran_gcc_executable', 'gcc')
" Set this option to change the GCC options for warnings for Fortran.
-if !exists('g:ale_fortran_gcc_options')
- let g:ale_fortran_gcc_options = '-Wall'
-endif
+call ale#Set('fortran_gcc_options', '-Wall')
function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
" We have to match a starting line and a later ending line together,
@@ -61,26 +53,20 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
return l:output
endfunction
-function! ale_linters#fortran#gcc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'fortran_gcc_executable')
-endfunction
-
function! ale_linters#fortran#gcc#GetCommand(buffer) abort
let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form')
\ ? '-ffree-form'
\ : '-ffixed-form'
- return ale_linters#fortran#gcc#GetExecutable(a:buffer)
- \ . ' -S -x f95 -fsyntax-only '
- \ . l:layout_option . ' '
- \ . ale#Var(a:buffer, 'fortran_gcc_options') . ' '
- \ . '-'
+ return '%e -S -x f95 -fsyntax-only ' . l:layout_option
+ \ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options'))
+ \ . ' -'
endfunction
call ale#linter#Define('fortran', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#fortran#gcc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('fortran_gcc_executable'),
\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand',
\ 'callback': 'ale_linters#fortran#gcc#Handle',
\})
diff --git a/ale_linters/fortran/language_server.vim b/ale_linters/fortran/language_server.vim
index fd763fcf..4e5f5dc4 100644
--- a/ale_linters/fortran/language_server.vim
+++ b/ale_linters/fortran/language_server.vim
@@ -4,14 +4,6 @@
call ale#Set('fortran_language_server_executable', 'fortls')
call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#fortran#language_server#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'fortran_language_server_executable')
-endfunction
-
-function! ale_linters#fortran#language_server#GetCommand(buffer) abort
- return ale#Escape(ale_linters#fortran#language_server#GetExecutable(a:buffer))
-endfunction
-
function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort
let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls')
@@ -21,7 +13,7 @@ endfunction
call ale#linter#Define('fortran', {
\ 'name': 'language_server',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#fortran#language_server#GetExecutable',
-\ 'command_callback': 'ale_linters#fortran#language_server#GetCommand',
+\ 'executable_callback': ale#VarFunc('fortran_language_server_executable'),
+\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot',
\})
diff --git a/ale_linters/fuse/fusionlint.vim b/ale_linters/fuse/fusionlint.vim
index cf20e1b4..ab8f143b 100644
--- a/ale_linters/fuse/fusionlint.vim
+++ b/ale_linters/fuse/fusionlint.vim
@@ -4,13 +4,8 @@
call ale#Set('fuse_fusionlint_executable', 'fusion-lint')
call ale#Set('fuse_fusionlint_options', '')
-function! ale_linters#fuse#fusionlint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'fuse_fusionlint_executable')
-endfunction
-
function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort
- return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer))
- \ . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
\ . ' --filename %s -i'
endfunction
@@ -32,7 +27,7 @@ endfunction
call ale#linter#Define('fuse', {
\ 'name': 'fusionlint',
-\ 'executable_callback': 'ale_linters#fuse#fusionlint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('fuse_fusionlint_executable'),
\ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand',
\ 'callback': 'ale_linters#fuse#fusionlint#Handle',
\})
diff --git a/ale_linters/gitcommit/gitlint.vim b/ale_linters/gitcommit/gitlint.vim
index 64731055..ec3bfb0b 100644
--- a/ale_linters/gitcommit/gitlint.vim
+++ b/ale_linters/gitcommit/gitlint.vim
@@ -1,11 +1,9 @@
" Author: Nick Yamane <nick.diego@gmail.com>
" Description: gitlint for git commit message files
-let g:ale_gitcommit_gitlint_executable =
-\ get(g:, 'ale_gitcommit_gitlint_executable', 'gitlint')
-let g:ale_gitcommit_gitlint_options = get(g:, 'ale_gitcommit_gitlint_options', '')
-let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
-
+call ale#Set('gitcommit_gitlint_executable', 'gitlint')
+call ale#Set('gitcommit_gitlint_options', '')
+call ale#Set('gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint'])
@@ -13,12 +11,9 @@ endfunction
function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options')
- let l:executable = ale_linters#gitcommit#gitlint#GetExecutable(a:buffer)
- return ale#Escape(l:executable)
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' lint'
-endfunction
+ return '%e' . ale#Pad(l:options) . ' lint'
+endfunction
function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
@@ -45,7 +40,6 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
return l:output
endfunction
-
call ale#linter#Define('gitcommit', {
\ 'name': 'gitlint',
\ 'output_stream': 'stderr',
@@ -53,4 +47,3 @@ call ale#linter#Define('gitcommit', {
\ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand',
\ 'callback': 'ale_linters#gitcommit#gitlint#Handle',
\})
-
diff --git a/ale_linters/glsl/glslang.vim b/ale_linters/glsl/glslang.vim
index d494df0e..d55a5e7c 100644
--- a/ale_linters/glsl/glslang.vim
+++ b/ale_linters/glsl/glslang.vim
@@ -4,17 +4,11 @@
" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
" we can use stdin.
-let g:ale_glsl_glslang_executable =
-\ get(g:, 'ale_glsl_glslang_executable', 'glslangValidator')
-
-let g:ale_glsl_glslang_options = get(g:, 'ale_glsl_glslang_options', '')
-
-function! ale_linters#glsl#glslang#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'glsl_glslang_executable')
-endfunction
+call ale#Set('glsl_glslang_executable', 'glslangValidator')
+call ale#Set('glsl_glslang_options', '')
function! ale_linters#glsl#glslang#GetCommand(buffer) abort
- return ale#Escape(ale_linters#glsl#glslang#GetExecutable(a:buffer))
+ return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
\ . ' -C %t'
endfunction
@@ -40,7 +34,7 @@ endfunction
call ale#linter#Define('glsl', {
\ 'name': 'glslang',
-\ 'executable_callback': 'ale_linters#glsl#glslang#GetExecutable',
+\ 'executable_callback': ale#VarFunc('glsl_glslang_executable'),
\ 'command_callback': 'ale_linters#glsl#glslang#GetCommand',
\ 'callback': 'ale_linters#glsl#glslang#Handle',
\})
diff --git a/ale_linters/glsl/glslls.vim b/ale_linters/glsl/glslls.vim
index 77e30f9c..8c6d9bd9 100644
--- a/ale_linters/glsl/glslls.vim
+++ b/ale_linters/glsl/glslls.vim
@@ -4,18 +4,15 @@
call ale#Set('glsl_glslls_executable', 'glslls')
call ale#Set('glsl_glslls_logfile', '')
-function! ale_linters#glsl#glslls#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'glsl_glslls_executable')
-endfunction
-
function! ale_linters#glsl#glslls#GetCommand(buffer) abort
- let l:executable = ale_linters#glsl#glslls#GetExecutable(a:buffer)
let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile')
let l:logfile_args = ''
+
if l:logfile isnot# ''
let l:logfile_args = ' --verbose -l ' . l:logfile
endif
- return ale#Escape(l:executable) . l:logfile_args . ' --stdin'
+
+ return '%e' . l:logfile_args . ' --stdin'
endfunction
function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort
@@ -27,7 +24,7 @@ endfunction
call ale#linter#Define('glsl', {
\ 'name': 'glslls',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable',
+\ 'executable_callback': ale#VarFunc('glsl_glslls_executable'),
\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand',
\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot',
\})
diff --git a/ale_linters/go/gometalinter.vim b/ale_linters/go/gometalinter.vim
index 375a8b0f..d005e1d2 100644
--- a/ale_linters/go/gometalinter.vim
+++ b/ale_linters/go/gometalinter.vim
@@ -5,12 +5,7 @@ call ale#Set('go_gometalinter_options', '')
call ale#Set('go_gometalinter_executable', 'gometalinter')
call ale#Set('go_gometalinter_lint_package', 0)
-function! ale_linters#go#gometalinter#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'go_gometalinter_executable')
-endfunction
-
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
- let l:executable = ale_linters#go#gometalinter#GetExecutable(a:buffer)
let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package')
@@ -19,12 +14,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort
" be calculated to absolute paths in the Handler
if l:lint_package
return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable)
+ \ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable)
+ \ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endfunction
@@ -55,7 +50,7 @@ endfunction
call ale#linter#Define('go', {
\ 'name': 'gometalinter',
-\ 'executable_callback': 'ale_linters#go#gometalinter#GetExecutable',
+\ 'executable_callback': ale#VarFunc('go_gometalinter_executable'),
\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand',
\ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1,
diff --git a/ale_linters/hack/hack.vim b/ale_linters/hack/hack.vim
new file mode 100644
index 00000000..aea428cc
--- /dev/null
+++ b/ale_linters/hack/hack.vim
@@ -0,0 +1,22 @@
+" Author: Fred Emmott <fe@fb.com>
+" Description: Hack support via `hack lsp`
+
+call ale#Set('hack_hack_executable', 'hh_client')
+
+function! ale_linters#hack#hack#GetProjectRoot(buffer) abort
+ let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
+
+ return !empty(l:hhconfig) ? fnamemodify(l:hhconfig, ':h') : ''
+endfunction
+
+function! ale_linters#hack#hack#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'hack_hack_executable')
+endfunction
+
+call ale#linter#Define('hack', {
+\ 'name': 'hack',
+\ 'lsp': 'stdio',
+\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable',
+\ 'command': '%e lsp --from vim-ale',
+\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot',
+\})
diff --git a/ale_linters/hack/hhast.vim b/ale_linters/hack/hhast.vim
new file mode 100644
index 00000000..710b7b25
--- /dev/null
+++ b/ale_linters/hack/hhast.vim
@@ -0,0 +1,40 @@
+" Author: Fred Emmott <fe@fb.com>
+" Description: Hack support via `hhast lsp`
+
+call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint')
+
+function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort
+ " Find the hack root, then figure out if it's also an HHAST root.
+ " Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json
+ let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
+
+ if empty(l:hhconfig)
+ return ''
+ endif
+
+ let l:root = fnamemodify(l:hhconfig, ':h')
+ let l:hhast_config = findfile('hhast-lint.json', l:root)
+
+ return !empty(l:hhast_config) ? l:root : ''
+endfunction
+
+function! ale_linters#hack#hhast#GetExecutable(buffer) abort
+ let l:root = ale_linters#hack#hhast#GetProjectRoot(a:buffer)
+ let l:relative = ale#Var(a:buffer, 'hack_hhast_executable')
+ let l:absolute = findfile(l:relative, l:root)
+
+ return !empty(l:absolute) ? l:absolute : ''
+endfunction
+
+function! ale_linters#hack#hhast#GetInitializationOptions(buffer) abort
+ return {'lintMode': 'open-files'}
+endfunction
+
+call ale#linter#Define('hack', {
+\ 'name': 'hhast',
+\ 'lsp': 'stdio',
+\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable',
+\ 'command': '%e --mode lsp --from vim-ale',
+\ 'project_root_callback': 'ale_linters#hack#hhast#GetProjectRoot',
+\ 'initialization_options_callback': 'ale_linters#hack#hhast#GetInitializationOptions',
+\})
diff --git a/ale_linters/handlebars/embertemplatelint.vim b/ale_linters/handlebars/embertemplatelint.vim
index 162a033c..4fc0f20d 100644
--- a/ale_linters/handlebars/embertemplatelint.vim
+++ b/ale_linters/handlebars/embertemplatelint.vim
@@ -4,17 +4,6 @@
call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
- \ 'node_modules/.bin/ember-template-lint',
- \])
-endfunction
-
-function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer) abort
- return ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer)
- \ . ' --json %t'
-endfunction
-
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
let l:output = []
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
@@ -42,7 +31,9 @@ endfunction
call ale#linter#Define('handlebars', {
\ 'name': 'ember-template-lint',
-\ 'executable_callback': 'ale_linters#handlebars#embertemplatelint#GetExecutable',
-\ 'command_callback': 'ale_linters#handlebars#embertemplatelint#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('handlebars_embertemplatelint', [
+\ 'node_modules/.bin/ember-template-lint',
+\ ]),
+\ 'command': '%e --json %t',
\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle',
\})
diff --git a/ale_linters/haskell/hdevtools.vim b/ale_linters/haskell/hdevtools.vim
index dc902152..fbd5278e 100644
--- a/ale_linters/haskell/hdevtools.vim
+++ b/ale_linters/haskell/hdevtools.vim
@@ -4,19 +4,14 @@
call ale#Set('haskell_hdevtools_executable', 'hdevtools')
call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall'))
-function! ale_linters#haskell#hdevtools#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'haskell_hdevtools_executable')
-endfunction
-
function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort
- return ale#Escape(ale_linters#haskell#hdevtools#GetExecutable(a:buffer))
- \ . ' check ' . ale#Var(a:buffer, 'haskell_hdevtools_options')
- \ . ' -p %s %t'
+ return '%e check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options'))
+ \ . ' -p %s %t'
endfunction
call ale#linter#Define('haskell', {
\ 'name': 'hdevtools',
-\ 'executable_callback': 'ale_linters#haskell#hdevtools#GetExecutable',
+\ 'executable_callback': ale#VarFunc('haskell_hdevtools_executable'),
\ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand',
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\})
diff --git a/ale_linters/haskell/hie.vim b/ale_linters/haskell/hie.vim
new file mode 100644
index 00000000..558d36a3
--- /dev/null
+++ b/ale_linters/haskell/hie.vim
@@ -0,0 +1,44 @@
+" Author: Luxed <devildead13@gmail.com>
+" Description: A language server for Haskell
+
+call ale#Set('haskell_hie_executable', 'hie')
+
+function! ale_linters#haskell#hie#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'haskell_hie_executable')
+endfunction
+
+function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort
+ " Search for the stack file first
+ let l:project_file = ale#path#FindNearestFile(a:buffer, 'stack.yaml')
+
+ " If it's empty, search for the cabal file
+ if empty(l:project_file)
+ let l:cabal_file = fnamemodify(bufname(a:buffer), ':p:h')
+ let l:paths = ''
+
+ while empty(matchstr(l:cabal_file, '^\(\/\|\(\w:\\\)\)$'))
+ let l:cabal_file = fnamemodify(l:cabal_file, ':h')
+ let l:paths = l:paths . l:cabal_file . ','
+ endwhile
+
+ let l:project_file = globpath(l:paths, '*.cabal')
+ endif
+
+ " Either extract the project directory or take the current working
+ " directory
+ if !empty(l:project_file)
+ let l:project_file = fnamemodify(l:project_file, ':h')
+ else
+ let l:project_file = expand('#' . a:buffer . ':p:h')
+ endif
+
+ return l:project_file
+endfunction
+
+call ale#linter#Define('haskell', {
+\ 'name': 'hie',
+\ 'lsp': 'stdio',
+\ 'command': '%e --lsp',
+\ 'executable_callback': 'ale_linters#haskell#hie#GetExecutable',
+\ 'project_root_callback': 'ale_linters#haskell#hie#GetProjectRoot',
+\})
diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim
index caa15bbb..234c1176 100644
--- a/ale_linters/html/htmlhint.vim
+++ b/ale_linters/html/htmlhint.vim
@@ -5,12 +5,6 @@ call ale#Set('html_htmlhint_options', '')
call ale#Set('html_htmlhint_executable', 'htmlhint')
call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#html#htmlhint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [
- \ 'node_modules/.bin/htmlhint',
- \])
-endfunction
-
function! ale_linters#html#htmlhint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'html_htmlhint_options')
let l:config = l:options !~# '--config'
@@ -25,14 +19,14 @@ function! ale_linters#html#htmlhint#GetCommand(buffer) abort
let l:options = substitute(l:options, '--format=unix', '', '')
endif
- return ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer))
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --format=unix %t'
+ return '%e' . ale#Pad(l:options) . ' --format=unix %t'
endfunction
call ale#linter#Define('html', {
\ 'name': 'htmlhint',
-\ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('html_htmlhint', [
+\ 'node_modules/.bin/htmlhint',
+\ ]),
\ 'command_callback': 'ale_linters#html#htmlhint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
\})
diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim
index 913cdade..cab8bc24 100644
--- a/ale_linters/html/tidy.vim
+++ b/ale_linters/html/tidy.vim
@@ -37,10 +37,6 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
\)
endfunction
-function! ale_linters#html#tidy#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'html_tidy_executable')
-endfunction
-
function! ale_linters#html#tidy#Handle(buffer, lines) abort
" Matches patterns lines like the following:
" line 7 column 5 - Warning: missing </title> before </head>
@@ -67,7 +63,7 @@ endfunction
call ale#linter#Define('html', {
\ 'name': 'tidy',
-\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable',
+\ 'executable_callback': ale#VarFunc('html_tidy_executable'),
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#html#tidy#GetCommand',
\ 'callback': 'ale_linters#html#tidy#Handle',
diff --git a/ale_linters/idris/idris.vim b/ale_linters/idris/idris.vim
index 115d04fc..b3275b40 100644
--- a/ale_linters/idris/idris.vim
+++ b/ale_linters/idris/idris.vim
@@ -4,16 +4,10 @@
call ale#Set('idris_idris_executable', 'idris')
call ale#Set('idris_idris_options', '--total --warnpartial --warnreach --warnipkg')
-function! ale_linters#idris#idris#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'idris_idris_executable')
-endfunction
-
function! ale_linters#idris#idris#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'idris_idris_options')
- return ale#Escape(ale_linters#idris#idris#GetExecutable(a:buffer))
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --check %s'
+ return '%e' . ale#Pad(l:options) . ' --check %s'
endfunction
function! ale_linters#idris#idris#Handle(buffer, lines) abort
@@ -80,8 +74,7 @@ endfunction
call ale#linter#Define('idris', {
\ 'name': 'idris',
-\ 'executable_callback': 'ale_linters#idris#idris#GetExecutable',
+\ 'executable_callback': ale#VarFunc('idris_idris_executable'),
\ 'command_callback': 'ale_linters#idris#idris#GetCommand',
\ 'callback': 'ale_linters#idris#idris#Handle',
\})
-
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index d7a39aa7..76445c18 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -36,10 +36,6 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : ''
endfunction
-function! ale_linters#java#javac#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'java_javac_executable')
-endfunction
-
function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
let l:sp_option = ''
@@ -77,13 +73,11 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
" Create .class files in a temporary directory, which we will delete later.
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
- let l:executable = ale_linters#java#javac#GetExecutable(a:buffer)
" Always run javac from the directory the file is in, so we can resolve
" relative paths correctly.
return ale#path#BufferCdString(a:buffer)
- \ . ale#Escape(l:executable)
- \ . ' -Xlint'
+ \ . '%e -Xlint'
\ . ale#Pad(l:cp_option)
\ . ale#Pad(l:sp_option)
\ . ' -d ' . ale#Escape(l:class_file_directory)
@@ -126,7 +120,7 @@ endfunction
call ale#linter#Define('java', {
\ 'name': 'javac',
-\ 'executable_callback': 'ale_linters#java#javac#GetExecutable',
+\ 'executable_callback': ale#VarFunc('java_javac_executable'),
\ 'command_chain': [
\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},
diff --git a/ale_linters/javascript/flow_ls.vim b/ale_linters/javascript/flow_ls.vim
index 20fc2217..75377183 100644
--- a/ale_linters/javascript/flow_ls.vim
+++ b/ale_linters/javascript/flow_ls.vim
@@ -6,18 +6,6 @@ call ale#Set('javascript_flow_ls_use_global',
\ get(g:, 'ale_use_global_executables', 0)
\)
-function! ale_linters#javascript#flow_ls#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'javascript_flow_ls', [
- \ 'node_modules/.bin/flow',
- \])
-endfunction
-
-function! ale_linters#javascript#flow_ls#GetCommand(buffer) abort
- let l:executable = ale_linters#javascript#flow_ls#GetExecutable(a:buffer)
-
- return ale#Escape(l:executable) . ' lsp --from ale-lsp'
-endfunction
-
function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort
let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig')
@@ -31,8 +19,10 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'flow-language-server',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#javascript#flow_ls#GetExecutable',
-\ 'command_callback': 'ale_linters#javascript#flow_ls#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('javascript_flow_ls', [
+\ 'node_modules/.bin/flow',
+\ ]),
+\ 'command': '%e lsp --from ale-lsp',
\ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot',
\ 'language': 'javascript',
\})
diff --git a/ale_linters/javascript/jscs.vim b/ale_linters/javascript/jscs.vim
index 60044037..a38766a6 100644
--- a/ale_linters/javascript/jscs.vim
+++ b/ale_linters/javascript/jscs.vim
@@ -4,12 +4,6 @@
call ale#Set('javascript_jscs_executable', 'jscs')
call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#javascript#jscs#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'javascript_jscs', [
- \ 'node_modules/.bin/jscs',
- \])
-endfunction
-
function! ale_linters#javascript#jscs#GetCommand(buffer) abort
" Search for a local JShint config locaation, and default to a global one.
let l:jscs_config = ale#path#ResolveLocalPath(
@@ -18,8 +12,7 @@ function! ale_linters#javascript#jscs#GetCommand(buffer) abort
\ get(g:, 'ale_jscs_config_loc', '')
\)
- let l:command = ale#Escape(ale_linters#javascript#jscs#GetExecutable(a:buffer))
- let l:command .= ' --reporter inline --no-colors'
+ let l:command = '%e --reporter inline --no-colors'
if !empty(l:jscs_config)
let l:command .= ' --config ' . ale#Escape(l:jscs_config)
@@ -60,8 +53,9 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'jscs',
-\ 'executable_callback': 'ale_linters#javascript#jscs#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jscs', [
+\ 'node_modules/.bin/jscs',
+\ ]),
\ 'command_callback': 'ale_linters#javascript#jscs#GetCommand',
\ 'callback': 'ale_linters#javascript#jscs#Handle',
\})
-
diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim
index 2e9bb9fd..83909fa4 100644
--- a/ale_linters/javascript/jshint.vim
+++ b/ale_linters/javascript/jshint.vim
@@ -4,12 +4,6 @@
call ale#Set('javascript_jshint_executable', 'jshint')
call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#javascript#jshint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [
- \ 'node_modules/.bin/jshint',
- \])
-endfunction
-
function! ale_linters#javascript#jshint#GetCommand(buffer) abort
" Search for a local JShint config locaation, and default to a global one.
let l:jshint_config = ale#path#ResolveLocalPath(
@@ -18,8 +12,7 @@ function! ale_linters#javascript#jshint#GetCommand(buffer) abort
\ get(g:, 'ale_jshint_config_loc', '')
\)
- let l:command = ale#Escape(ale_linters#javascript#jshint#GetExecutable(a:buffer))
- let l:command .= ' --reporter unix --extract auto'
+ let l:command = '%e --reporter unix --extract auto'
if !empty(l:jshint_config)
let l:command .= ' --config ' . ale#Escape(l:jshint_config)
@@ -32,7 +25,9 @@ endfunction
call ale#linter#Define('javascript', {
\ 'name': 'jshint',
-\ 'executable_callback': 'ale_linters#javascript#jshint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jshint', [
+\ 'node_modules/.bin/jshint',
+\ ]),
\ 'command_callback': 'ale_linters#javascript#jshint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
\})
diff --git a/ale_linters/javascript/tsserver.vim b/ale_linters/javascript/tsserver.vim
index 62dded10..6cf08dd6 100644
--- a/ale_linters/javascript/tsserver.vim
+++ b/ale_linters/javascript/tsserver.vim
@@ -5,22 +5,13 @@ call ale#Set('javascript_tsserver_executable', 'tsserver')
call ale#Set('javascript_tsserver_config_path', '')
call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0))
-" These functions need to be defined just to comply with the API for LSP.
-function! ale_linters#javascript#tsserver#GetProjectRoot(buffer) abort
- return ''
-endfunction
-
-function! ale_linters#javascript#tsserver#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'javascript_tsserver', [
- \ 'node_modules/.bin/tsserver',
- \])
-endfunction
-
call ale#linter#Define('javascript', {
\ 'name': 'tsserver',
\ 'lsp': 'tsserver',
-\ 'executable_callback': 'ale_linters#javascript#tsserver#GetExecutable',
-\ 'command_callback': 'ale_linters#javascript#tsserver#GetExecutable',
-\ 'project_root_callback': 'ale_linters#javascript#tsserver#GetProjectRoot',
+\ 'executable_callback': ale#node#FindExecutableFunc('javascript_tsserver', [
+\ 'node_modules/.bin/tsserver',
+\ ]),
+\ 'command': '%e',
+\ 'project_root_callback': {-> ''},
\ 'language': '',
\})
diff --git a/ale_linters/kotlin/languageserver.vim b/ale_linters/kotlin/languageserver.vim
index 0ab673ec..08f1c055 100644
--- a/ale_linters/kotlin/languageserver.vim
+++ b/ale_linters/kotlin/languageserver.vim
@@ -3,15 +3,6 @@
call ale#Set('kotlin_languageserver_executable', 'kotlin-language-server')
-function! ale_linters#kotlin#languageserver#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'kotlin_languageserver_executable')
-endfunction
-
-function! ale_linters#kotlin#languageserver#GetCommand(buffer) abort
- let l:executable = ale_linters#kotlin#languageserver#GetExecutable(a:buffer)
- return ale#Escape(l:executable)
-endfunction
-
function! ale_linters#kotlin#languageserver#GetProjectRoot(buffer) abort
let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer)
@@ -31,8 +22,8 @@ endfunction
call ale#linter#Define('kotlin', {
\ 'name': 'languageserver',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#kotlin#languageserver#GetExecutable',
-\ 'command_callback': 'ale_linters#kotlin#languageserver#GetCommand',
+\ 'executable_callback': ale#VarFunc('kotlin_languageserver_executable'),
+\ 'command_callback': '%e',
\ 'language': 'kotlin',
\ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot',
\})
diff --git a/ale_linters/less/lessc.vim b/ale_linters/less/lessc.vim
index 5fd9a383..37600649 100755
--- a/ale_linters/less/lessc.vim
+++ b/ale_linters/less/lessc.vim
@@ -5,21 +5,10 @@ call ale#Set('less_lessc_executable', 'lessc')
call ale#Set('less_lessc_options', '')
call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#less#lessc#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'less_lessc', [
- \ 'node_modules/.bin/lessc',
- \])
-endfunction
-
function! ale_linters#less#lessc#GetCommand(buffer) abort
- let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer)
- let l:dir = expand('#' . a:buffer . ':p:h')
- let l:options = ale#Var(a:buffer, 'less_lessc_options')
-
- return ale#Escape(l:executable)
- \ . ' --no-color --lint'
- \ . ' --include-path=' . ale#Escape(l:dir)
- \ . (!empty(l:options) ? ' ' . l:options : '')
+ return '%e --no-color --lint'
+ \ . ' --include-path=' . ale#Escape(expand('#' . a:buffer . ':p:h'))
+ \ . ale#Pad(ale#Var(a:buffer, 'less_lessc_options'))
\ . ' -'
endfunction
@@ -49,7 +38,9 @@ endfunction
call ale#linter#Define('less', {
\ 'name': 'lessc',
-\ 'executable_callback': 'ale_linters#less#lessc#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('less_lessc', [
+\ 'node_modules/.bin/lessc',
+\ ]),
\ 'command_callback': 'ale_linters#less#lessc#GetCommand',
\ 'callback': 'ale_linters#less#lessc#Handle',
\ 'output_stream': 'stderr',
diff --git a/ale_linters/less/stylelint.vim b/ale_linters/less/stylelint.vim
index 8e16a098..479808c2 100644
--- a/ale_linters/less/stylelint.vim
+++ b/ale_linters/less/stylelint.vim
@@ -4,24 +4,17 @@ call ale#Set('less_stylelint_executable', 'stylelint')
call ale#Set('less_stylelint_options', '')
call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#less#stylelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'less_stylelint', [
- \ 'node_modules/.bin/stylelint',
- \])
-endfunction
-
function! ale_linters#less#stylelint#GetCommand(buffer) abort
- let l:executable = ale_linters#less#stylelint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'less_stylelint_options')
- return ale#Escape(l:executable)
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --stdin-filename %s'
+ return '%e' . ale#Pad(l:options) . ' --stdin-filename %s'
endfunction
call ale#linter#Define('less', {
\ 'name': 'stylelint',
-\ 'executable_callback': 'ale_linters#less#stylelint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('less_stylelint', [
+\ 'node_modules/.bin/stylelint',
+\ ]),
\ 'command_callback': 'ale_linters#less#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})
diff --git a/ale_linters/llvm/llc.vim b/ale_linters/llvm/llc.vim
index 15201cbe..044f8c44 100644
--- a/ale_linters/llvm/llc.vim
+++ b/ale_linters/llvm/llc.vim
@@ -3,21 +3,11 @@
call ale#Set('llvm_llc_executable', 'llc')
-function! ale_linters#llvm#llc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'llvm_llc_executable')
-endfunction
-
-function! ale_linters#llvm#llc#GetCommand(buffer) abort
- return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer))
- \ . ' -filetype=null -o=' . g:ale#util#nul_file
-endfunction
-
function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort
" Handle '{path}: {file}:{line}:{col}: error: {message}' format
let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$'
- let l:matches = ale#util#GetMatches(a:lines, l:pattern)
- return map(l:matches, "{
+ return map(ale#util#GetMatches(a:lines, l:pattern), "{
\ 'lnum': str2nr(v:val[1]),
\ 'col': str2nr(v:val[2]),
\ 'text': v:val[3],
@@ -27,8 +17,8 @@ endfunction
call ale#linter#Define('llvm', {
\ 'name': 'llc',
-\ 'executable_callback': 'ale_linters#llvm#llc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('llvm_llc_executable'),
\ 'output_stream': 'stderr',
-\ 'command_callback': 'ale_linters#llvm#llc#GetCommand',
+\ 'command_callback': {-> '%e -filetype=null -o=' . g:ale#util#nul_file},
\ 'callback': 'ale_linters#llvm#llc#HandleErrors',
\})
diff --git a/ale_linters/lua/luac.vim b/ale_linters/lua/luac.vim
index 4a6bb403..bca2cd8d 100644
--- a/ale_linters/lua/luac.vim
+++ b/ale_linters/lua/luac.vim
@@ -3,15 +3,6 @@
call ale#Set('lua_luac_executable', 'luac')
-function! ale_linters#lua#luac#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'lua_luac_executable')
-endfunction
-
-function! ale_linters#lua#luac#GetCommand(buffer) abort
- let l:executable = ale_linters#lua#luac#GetExecutable(a:buffer)
- return ale#Escape(l:executable) . ' -p - '
-endfunction
-
function! ale_linters#lua#luac#Handle(buffer, lines) abort
" Matches patterns line the following:
"
@@ -33,8 +24,8 @@ endfunction
call ale#linter#Define('lua', {
\ 'name': 'luac',
-\ 'executable_callback': 'ale_linters#lua#luac#GetExecutable',
-\ 'command_callback': 'ale_linters#lua#luac#GetCommand',
+\ 'executable_callback': ale#VarFunc('lua_luac_executable'),
+\ 'command': '%e -p -',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#lua#luac#Handle',
\})
diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim
index 725153c6..669103b8 100644
--- a/ale_linters/lua/luacheck.vim
+++ b/ale_linters/lua/luacheck.vim
@@ -1,19 +1,11 @@
" Author: Sol Bekic https://github.com/s-ol
" Description: luacheck linter for lua files
-let g:ale_lua_luacheck_executable =
-\ get(g:, 'ale_lua_luacheck_executable', 'luacheck')
-
-let g:ale_lua_luacheck_options =
-\ get(g:, 'ale_lua_luacheck_options', '')
-
-function! ale_linters#lua#luacheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'lua_luacheck_executable')
-endfunction
+call ale#Set('lua_luacheck_executable', 'luacheck')
+call ale#Set('lua_luacheck_options', '')
function! ale_linters#lua#luacheck#GetCommand(buffer) abort
- return ale#Escape(ale_linters#lua#luacheck#GetExecutable(a:buffer))
- \ . ' ' . ale#Var(a:buffer, 'lua_luacheck_options')
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_luacheck_options'))
\ . ' --formatter plain --codes --filename %s -'
endfunction
@@ -46,7 +38,7 @@ endfunction
call ale#linter#Define('lua', {
\ 'name': 'luacheck',
-\ 'executable_callback': 'ale_linters#lua#luacheck#GetExecutable',
+\ 'executable_callback': ale#VarFunc('lua_luacheck_executable'),
\ 'command_callback': 'ale_linters#lua#luacheck#GetCommand',
\ 'callback': 'ale_linters#lua#luacheck#Handle',
\})
diff --git a/ale_linters/markdown/remark_lint.vim b/ale_linters/markdown/remark_lint.vim
index d9c2efb6..88dfb9dd 100644
--- a/ale_linters/markdown/remark_lint.vim
+++ b/ale_linters/markdown/remark_lint.vim
@@ -5,19 +5,10 @@ call ale#Set('markdown_remark_lint_executable', 'remark')
call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('markdown_remark_lint_options', '')
-function! ale_linters#markdown#remark_lint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [
- \ 'node_modules/.bin/remark',
- \])
-endfunction
-
function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort
- let l:executable = ale_linters#markdown#remark_lint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
- return ale#node#Executable(a:buffer, l:executable)
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --no-stdout --no-color'
+ return '%e' . ale#Pad(l:options) . ' --no-stdout --no-color'
endfunction
function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
@@ -46,7 +37,9 @@ endfunction
call ale#linter#Define('markdown', {
\ 'name': 'remark_lint',
\ 'aliases': ['remark-lint'],
-\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('markdown_remark_lint', [
+\ 'node_modules/.bin/remark',
+\ ]),
\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle',
\ 'output_stream': 'stderr',
diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim
index 32766334..3435045e 100644
--- a/ale_linters/matlab/mlint.vim
+++ b/ale_linters/matlab/mlint.vim
@@ -1,18 +1,7 @@
" Author: awlayton <alex@layton.in>
" Description: mlint for MATLAB files
-let g:ale_matlab_mlint_executable =
-\ get(g:, 'ale_matlab_mlint_executable', 'mlint')
-
-function! ale_linters#matlab#mlint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'matlab_mlint_executable')
-endfunction
-
-function! ale_linters#matlab#mlint#GetCommand(buffer) abort
- let l:executable = ale_linters#matlab#mlint#GetExecutable(a:buffer)
-
- return l:executable . ' -id %t'
-endfunction
+call ale#Set('matlab_mlint_executable', 'mlint')
function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
" Matches patterns like the following:
@@ -48,8 +37,8 @@ endfunction
call ale#linter#Define('matlab', {
\ 'name': 'mlint',
-\ 'executable_callback': 'ale_linters#matlab#mlint#GetExecutable',
-\ 'command_callback': 'ale_linters#matlab#mlint#GetCommand',
+\ 'executable_callback': ale#VarFunc('matlab_mlint_executable'),
+\ 'command': '%e -id %t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#matlab#mlint#Handle',
\})
diff --git a/ale_linters/mercury/mmc.vim b/ale_linters/mercury/mmc.vim
index c7bfc59d..76d357f0 100644
--- a/ale_linters/mercury/mmc.vim
+++ b/ale_linters/mercury/mmc.vim
@@ -4,16 +4,11 @@
call ale#Set('mercury_mmc_executable', 'mmc')
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
-function! ale_linters#mercury#mmc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'mercury_mmc_executable')
-endfunction
-
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
let l:module_name = expand('#' . a:buffer . ':t:r')
return ale#path#BufferCdString(a:buffer)
- \ . ale_linters#mercury#mmc#GetExecutable(a:buffer)
- \ . ' --errorcheck-only '
+ \ . '%e --errorcheck-only '
\ . ale#Var(a:buffer, 'mercury_mmc_options')
\ . ' ' . l:module_name
endfunction
@@ -38,7 +33,7 @@ endfunction
call ale#linter#Define('mercury', {
\ 'name': 'mmc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('mercury_mmc_executable'),
\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand',
\ 'callback': 'ale_linters#mercury#mmc#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/nasm/nasm.vim b/ale_linters/nasm/nasm.vim
index 77d57e18..29d19e62 100644
--- a/ale_linters/nasm/nasm.vim
+++ b/ale_linters/nasm/nasm.vim
@@ -4,25 +4,13 @@
call ale#Set('nasm_nasm_executable', 'nasm')
call ale#Set('nasm_nasm_options', '')
-function! ale_linters#nasm#nasm#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'nasm_nasm_executable')
-endfunction
-
-function! ale_linters#nasm#nasm#GetOptions(buffer) abort
- return ale#Var(a:buffer, 'nasm_nasm_options')
-endfunction
-
function! ale_linters#nasm#nasm#GetCommand(buffer) abort
- " Note that NASM require a trailing slash to the -I option.
- let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer))
+ " Note that NASM requires a trailing slash for the -I option.
let l:separator = has('win32') ? '\' : '/'
- let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator)
- let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer)
+ let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator
- return l:executable
- \ . ' -X gnu'
- \ . ' -I ' . l:path
- \ . ' ' . l:options
+ return '%e -X gnu -I ' . ale#Escape(l:path)
+ \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options'))
\ . ' %s'
endfunction
@@ -30,6 +18,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
" Note that we treat 'fatal' as errors.
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
@@ -37,6 +26,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
\ 'text': l:match[3],
\})
endfor
+
return l:output
endfunction
@@ -44,7 +34,7 @@ call ale#linter#Define('nasm', {
\ 'name': 'nasm',
\ 'output_stream': 'stderr',
\ 'lint_file': 1,
-\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable',
+\ 'executable_callback': ale#VarFunc('nasm_nasm_executable'),
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
\ 'callback': 'ale_linters#nasm#nasm#Handle',
\})
diff --git a/ale_linters/objc/clang.vim b/ale_linters/objc/clang.vim
index f4725a0e..4e80ac5c 100644
--- a/ale_linters/objc/clang.vim
+++ b/ale_linters/objc/clang.vim
@@ -19,5 +19,5 @@ call ale#linter#Define('objc', {
\ 'output_stream': 'stderr',
\ 'executable': 'clang',
\ 'command_callback': 'ale_linters#objc#clang#GetCommand',
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/objcpp/clang.vim b/ale_linters/objcpp/clang.vim
index 0e9cefe9..d1474f17 100644
--- a/ale_linters/objcpp/clang.vim
+++ b/ale_linters/objcpp/clang.vim
@@ -19,5 +19,5 @@ call ale#linter#Define('objcpp', {
\ 'output_stream': 'stderr',
\ 'executable': 'clang++',
\ 'command_callback': 'ale_linters#objcpp#clang#GetCommand',
-\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
+\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})
diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim
index 1b9aa95e..d1dcbc9c 100644
--- a/ale_linters/perl/perl.vim
+++ b/ale_linters/perl/perl.vim
@@ -1,20 +1,11 @@
" Author: Vincent Lequertier <https://github.com/SkySymbol>
" Description: This file adds support for checking perl syntax
-let g:ale_perl_perl_executable =
-\ get(g:, 'ale_perl_perl_executable', 'perl')
-
-let g:ale_perl_perl_options =
-\ get(g:, 'ale_perl_perl_options', '-c -Mwarnings -Ilib')
-
-function! ale_linters#perl#perl#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'perl_perl_executable')
-endfunction
+call ale#Set('perl_perl_executable', 'perl')
+call ale#Set('perl_perl_options', '-c -Mwarnings -Ilib')
function! ale_linters#perl#perl#GetCommand(buffer) abort
- return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer))
- \ . ' ' . ale#Var(a:buffer, 'perl_perl_options')
- \ . ' %t'
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'perl_perl_options')) . ' %t'
endfunction
let s:begin_failed_skip_pattern = '\v' . join([
@@ -61,7 +52,7 @@ endfunction
call ale#linter#Define('perl', {
\ 'name': 'perl',
-\ 'executable_callback': 'ale_linters#perl#perl#GetExecutable',
+\ 'executable_callback': ale#VarFunc('perl_perl_executable'),
\ 'output_stream': 'both',
\ 'command_callback': 'ale_linters#perl#perl#GetCommand',
\ 'callback': 'ale_linters#perl#perl#Handle',
diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim
index e91c8a03..8619a404 100644
--- a/ale_linters/perl/perlcritic.vim
+++ b/ale_linters/perl/perlcritic.vim
@@ -1,21 +1,10 @@
" Author: Vincent Lequertier <https://github.com/SkySymbol>, Chris Weyl <cweyl@alumni.drew.edu>
" Description: This file adds support for checking perl with perl critic
-let g:ale_perl_perlcritic_executable =
-\ get(g:, 'ale_perl_perlcritic_executable', 'perlcritic')
-
-let g:ale_perl_perlcritic_profile =
-\ get(g:, 'ale_perl_perlcritic_profile', '.perlcriticrc')
-
-let g:ale_perl_perlcritic_options =
-\ get(g:, 'ale_perl_perlcritic_options', '')
-
-let g:ale_perl_perlcritic_showrules =
-\ get(g:, 'ale_perl_perlcritic_showrules', 0)
-
-function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'perl_perlcritic_executable')
-endfunction
+call ale#Set('perl_perlcritic_executable', 'perlcritic')
+call ale#Set('perl_perlcritic_profile', '.perlcriticrc')
+call ale#Set('perl_perlcritic_options', '')
+call ale#Set('perl_perlcritic_showrules', 0)
function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
" first see if we've been overridden
@@ -39,11 +28,11 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
let l:options = ale#Var(a:buffer, 'perl_perlcritic_options')
- return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer))
+ return '%e'
\ . ' --verbose ' . ale#Escape(l:critic_verbosity)
\ . ' --nocolor'
\ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '')
- \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ale#Pad(l:options)
endfunction
@@ -66,7 +55,7 @@ endfunction
call ale#linter#Define('perl', {
\ 'name': 'perlcritic',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#perl#perlcritic#GetExecutable',
+\ 'executable_callback': ale#VarFunc('perl_perlcritic_executable'),
\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand',
\ 'callback': 'ale_linters#perl#perlcritic#Handle',
\})
diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim
deleted file mode 100644
index 77d3a588..00000000
--- a/ale_linters/php/hack.vim
+++ /dev/null
@@ -1,28 +0,0 @@
-" Author: Zefei Xuan <https://github.com/zefei>
-" Description: Hack type checking (http://hacklang.org/)
-
-function! ale_linters#php#hack#Handle(buffer, lines) abort
- let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$'
- let l:output = []
-
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
- if a:buffer != bufnr(l:match[1])
- continue
- endif
-
- call add(l:output, {
- \ 'lnum': l:match[2] + 0,
- \ 'col': l:match[3] + 0,
- \ 'text': l:match[5],
- \})
- endfor
-
- return l:output
-endfunction
-
-call ale#linter#Define('php', {
-\ 'name': 'hack',
-\ 'executable': 'hh_client',
-\ 'command': 'hh_client --retries 0 --retry-if-init false',
-\ 'callback': 'ale_linters#php#hack#Handle',
-\})
diff --git a/ale_linters/php/langserver.vim b/ale_linters/php/langserver.vim
index 38b42df9..ca91db4c 100644
--- a/ale_linters/php/langserver.vim
+++ b/ale_linters/php/langserver.vim
@@ -4,16 +4,6 @@
call ale#Set('php_langserver_executable', 'php-language-server.php')
call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#php#langserver#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'php_langserver', [
- \ 'vendor/bin/php-language-server.php',
- \])
-endfunction
-
-function! ale_linters#php#langserver#GetCommand(buffer) abort
- return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer))
-endfunction
-
function! ale_linters#php#langserver#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
@@ -23,7 +13,9 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'langserver',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable',
-\ 'command_callback': 'ale_linters#php#langserver#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('php_langserver', [
+\ 'vendor/bin/php-language-server.php',
+\ ]),
+\ 'command': 'php %e',
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
\})
diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim
index faf8ad55..25e53714 100644
--- a/ale_linters/php/phpcs.vim
+++ b/ale_linters/php/phpcs.vim
@@ -6,23 +6,13 @@ let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '')
call ale#Set('php_phpcs_executable', 'phpcs')
call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#php#phpcs#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'php_phpcs', [
- \ 'vendor/bin/phpcs',
- \ 'phpcs'
- \])
-endfunction
-
function! ale_linters#php#phpcs#GetCommand(buffer) abort
- let l:executable = ale_linters#php#phpcs#GetExecutable(a:buffer)
-
let l:standard = ale#Var(a:buffer, 'php_phpcs_standard')
let l:standard_option = !empty(l:standard)
\ ? '--standard=' . l:standard
\ : ''
- return ale#Escape(l:executable)
- \ . ' -s --report=emacs --stdin-path=%s ' . l:standard_option
+ return '%e -s --report=emacs --stdin-path=%s' . ale#Pad(l:standard_option)
endfunction
function! ale_linters#php#phpcs#Handle(buffer, lines) abort
@@ -50,7 +40,10 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpcs',
-\ 'executable_callback': 'ale_linters#php#phpcs#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('php_phpcs', [
+\ 'vendor/bin/phpcs',
+\ 'phpcs'
+\ ]),
\ 'command_callback': 'ale_linters#php#phpcs#GetCommand',
\ 'callback': 'ale_linters#php#phpcs#Handle',
\})
diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim
index e9450752..65f1cc3c 100644
--- a/ale_linters/php/phpmd.vim
+++ b/ale_linters/php/phpmd.vim
@@ -6,16 +6,9 @@ let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
" Set to change the ruleset
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode')
-function! ale_linters#php#phpmd#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'php_phpmd_executable')
-endfunction
-
function! ale_linters#php#phpmd#GetCommand(buffer) abort
- let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer)
-
- return ale#Escape(l:executable)
- \ . ' %s text '
- \ . ale#Var(a:buffer, 'php_phpmd_ruleset')
+ return '%e %s text'
+ \ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset'))
\ . ' --ignore-violations-on-exit %t'
endfunction
@@ -39,7 +32,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpmd',
-\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable',
+\ 'executable_callback': ale#VarFunc('php_phpmd_executable'),
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
\ 'callback': 'ale_linters#php#phpmd#Handle',
\})
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim
index 24762086..b3875216 100644
--- a/ale_linters/php/phpstan.vim
+++ b/ale_linters/php/phpstan.vim
@@ -6,20 +6,13 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
-function! ale_linters#php#phpstan#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'php_phpstan_executable')
-endfunction
-
function! ale_linters#php#phpstan#GetCommand(buffer) abort
- let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
-
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
let l:configuration_option = !empty(l:configuration)
\ ? ' -c ' . l:configuration
\ : ''
- return ale#Escape(l:executable)
- \ . ' analyze -l'
+ return '%e analyze -l'
\ . ale#Var(a:buffer, 'php_phpstan_level')
\ . ' --errorFormat raw'
\ . l:configuration_option
@@ -47,7 +40,7 @@ endfunction
call ale#linter#Define('php', {
\ 'name': 'phpstan',
-\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable',
+\ 'executable_callback': ale#VarFunc('php_phpstan_executable'),
\ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
\ 'callback': 'ale_linters#php#phpstan#Handle',
\})
diff --git a/ale_linters/pony/ponyc.vim b/ale_linters/pony/ponyc.vim
index b3329053..19e7e828 100644
--- a/ale_linters/pony/ponyc.vim
+++ b/ale_linters/pony/ponyc.vim
@@ -3,19 +3,14 @@
call ale#Set('pony_ponyc_executable', 'ponyc')
call ale#Set('pony_ponyc_options', '--pass paint')
-function! ale_linters#pony#ponyc#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'pony_ponyc_executable')
-endfunction
-
function! ale_linters#pony#ponyc#GetCommand(buffer) abort
- return ale#Escape(ale_linters#pony#ponyc#GetExecutable(a:buffer))
- \ . ' ' . ale#Var(a:buffer, 'pony_ponyc_options')
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'pony_ponyc_options'))
endfunction
call ale#linter#Define('pony', {
\ 'name': 'ponyc',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#pony#ponyc#GetExecutable',
+\ 'executable_callback': ale#VarFunc('pony_ponyc_executable'),
\ 'command_callback': 'ale_linters#pony#ponyc#GetCommand',
\ 'callback': 'ale#handlers#pony#HandlePonycFormat',
\})
diff --git a/ale_linters/pug/puglint.vim b/ale_linters/pug/puglint.vim
index 165e68b7..63208986 100644
--- a/ale_linters/pug/puglint.vim
+++ b/ale_linters/pug/puglint.vim
@@ -5,12 +5,6 @@ call ale#Set('pug_puglint_options', '')
call ale#Set('pug_puglint_executable', 'pug-lint')
call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#pug#puglint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'pug_puglint', [
- \ 'node_modules/.bin/pug-lint',
- \])
-endfunction
-
function! s:FindConfig(buffer) abort
for l:filename in [
\ '.pug-lintrc',
@@ -29,19 +23,19 @@ function! s:FindConfig(buffer) abort
endfunction
function! ale_linters#pug#puglint#GetCommand(buffer) abort
- let l:executable = ale_linters#pug#puglint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'pug_puglint_options')
let l:config = s:FindConfig(a:buffer)
- return ale#Escape(l:executable)
- \ . (!empty(l:options) ? ' ' . l:options : '')
+ return '%e' . ale#Pad(l:options)
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
\ . ' -r inline %t'
endfunction
call ale#linter#Define('pug', {
\ 'name': 'puglint',
-\ 'executable_callback': 'ale_linters#pug#puglint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('pug_puglint', [
+\ 'node_modules/.bin/pug-lint',
+\ ]),
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#pug#puglint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError',
diff --git a/ale_linters/puppet/languageserver.vim b/ale_linters/puppet/languageserver.vim
index 52880f32..a08b7653 100644
--- a/ale_linters/puppet/languageserver.vim
+++ b/ale_linters/puppet/languageserver.vim
@@ -3,16 +3,6 @@
call ale#Set('puppet_languageserver_executable', 'puppet-languageserver')
-function! ale_linters#puppet#languageserver#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'puppet_languageserver_executable')
-endfunction
-
-function! ale_linters#puppet#languageserver#GetCommand(buffer) abort
- let l:exe = ale#Escape(ale_linters#puppet#languageserver#GetExecutable(a:buffer))
-
- return l:exe . ' --stdio'
-endfunction
-
function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
" Note: The metadata.json file is recommended for Puppet 4+ modules, but
" there's no requirement to have it, so fall back to the other possible
@@ -38,8 +28,8 @@ endfunction
call ale#linter#Define('puppet', {
\ 'name': 'languageserver',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#puppet#languageserver#GetExecutable',
-\ 'command_callback': 'ale_linters#puppet#languageserver#GetCommand',
+\ 'executable_callback': ale#VarFunc('puppet_languageserver_executable'),
+\ 'command': '%e --stdio',
\ 'language': 'puppet',
\ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot',
\})
diff --git a/ale_linters/puppet/puppetlint.vim b/ale_linters/puppet/puppetlint.vim
index 13da511b..c9c16f5e 100644
--- a/ale_linters/puppet/puppetlint.vim
+++ b/ale_linters/puppet/puppetlint.vim
@@ -1,26 +1,18 @@
" Author: Alexander Olofsson <alexander.olofsson@liu.se>, Robert Flechtner <flechtner@chemmedia.de>
" Description: puppet-lint for puppet files
-let g:ale_puppet_puppetlint_executable =
-\ get(g:, 'ale_puppet_puppetlint_executable', 'puppet-lint')
-
-let g:ale_puppet_puppetlint_options =
-\ get(g:, 'ale_puppet_puppetlint_options', '--no-autoloader_layout-check')
-
-function! ale_linters#puppet#puppetlint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'puppet_puppetlint_executable')
-endfunction
+call ale#Set('puppet_puppetlint_executable', 'puppet-lint')
+call ale#Set('puppet_puppetlint_options', '--no-autoloader_layout-check')
function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort
- return ale_linters#puppet#puppetlint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'puppet_puppetlint_options')
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'puppet_puppetlint_options'))
\ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"'
\ . ' %t'
endfunction
call ale#linter#Define('puppet', {
\ 'name': 'puppetlint',
-\ 'executable_callback': 'ale_linters#puppet#puppetlint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('puppet_puppetlint_executable'),
\ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})
diff --git a/ale_linters/pyrex/cython.vim b/ale_linters/pyrex/cython.vim
index 9b6b39d7..d260698c 100644
--- a/ale_linters/pyrex/cython.vim
+++ b/ale_linters/pyrex/cython.vim
@@ -5,16 +5,11 @@
call ale#Set('pyrex_cython_executable', 'cython')
call ale#Set('pyrex_cython_options', '--warning-extra')
-function! ale_linters#pyrex#cython#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'pyrex_cython_executable')
-endfunction
-
function! ale_linters#pyrex#cython#GetCommand(buffer) abort
let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
- return ale#Escape(ale_linters#pyrex#cython#GetExecutable(a:buffer))
- \ . ' --working ' . l:local_dir . ' --include-dir ' . l:local_dir
- \ . ' ' . ale#Var(a:buffer, 'pyrex_cython_options')
+ return '%e --working ' . l:local_dir . ' --include-dir ' . l:local_dir
+ \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options'))
\ . ' --output-file ' . g:ale#util#nul_file . ' %t'
endfunction
@@ -37,7 +32,7 @@ endfunction
call ale#linter#Define('pyrex', {
\ 'name': 'cython',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#pyrex#cython#GetExecutable',
+\ 'executable_callback': ale#VarFunc('pyrex_cython_executable'),
\ 'command_callback': 'ale_linters#pyrex#cython#GetCommand',
\ 'callback': 'ale_linters#pyrex#cython#Handle',
\})
diff --git a/ale_linters/qml/qmlfmt.vim b/ale_linters/qml/qmlfmt.vim
index 85b131fd..12f3e97b 100644
--- a/ale_linters/qml/qmlfmt.vim
+++ b/ale_linters/qml/qmlfmt.vim
@@ -1,40 +1,25 @@
" Author: pylipp (www.github.com/pylipp)
" Description: qmlfmt for QML files
-let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt')
-
-function! ale_linters#qml#qmlfmt#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'qml_qmlfmt_executable')
-endfunction
-
-function! ale_linters#qml#qmlfmt#GetCommand(buffer) abort
- return ale#Escape(ale_linters#qml#qmlfmt#GetExecutable(a:buffer))
- \ . ' -e'
-endfunction
+call ale#Set('qml_qmlfmt_executable', 'qmlfmt')
" Find lines like
" Error:11:1: Expected token `}'
function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort
let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$'
- let l:output = []
-
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
- let l:item = {
- \ 'lnum': l:match[2] + 0,
- \ 'col': l:match[3] + 0,
- \ 'text': l:match[4],
- \ 'type': l:match[1] is# 'Warning' ? 'W' : 'E',
- \}
- call add(l:output, l:item)
- endfor
- return l:output
+ return map(ale#util#GetMatches(a:lines, l:pattern), "{
+ \ 'lnum': v:val[2] + 0,
+ \ 'col': v:val[3] + 0,
+ \ 'text': v:val[4],
+ \ 'type': v:val[1] is# 'Warning' ? 'W' : 'E',
+ \}")
endfunction
call ale#linter#Define('qml', {
\ 'name': 'qmlfmt',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable',
-\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand',
+\ 'executable_callback': ale#VarFunc('qml_qmlfmt_executable'),
+\ 'command': '%e -e',
\ 'callback': 'ale_linters#qml#qmlfmt#Handle',
\})
diff --git a/ale_linters/ruby/ruby.vim b/ale_linters/ruby/ruby.vim
index 1aa88851..2bc4ec4b 100644
--- a/ale_linters/ruby/ruby.vim
+++ b/ale_linters/ruby/ruby.vim
@@ -3,20 +3,10 @@
call ale#Set('ruby_ruby_executable', 'ruby')
-function! ale_linters#ruby#ruby#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'ruby_ruby_executable')
-endfunction
-
-function! ale_linters#ruby#ruby#GetCommand(buffer) abort
- let l:executable = ale_linters#ruby#ruby#GetExecutable(a:buffer)
-
- return ale#Escape(l:executable) . ' -w -c -T1 %t'
-endfunction
-
call ale#linter#Define('ruby', {
\ 'name': 'ruby',
-\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable',
-\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand',
+\ 'executable_callback': ale#VarFunc('ruby_ruby_executable'),
+\ 'command': '%e -w -c -T1 %t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})
diff --git a/ale_linters/rust/rls.vim b/ale_linters/rust/rls.vim
index cd13291d..60dd3667 100644
--- a/ale_linters/rust/rls.vim
+++ b/ale_linters/rust/rls.vim
@@ -4,19 +4,10 @@
call ale#Set('rust_rls_executable', 'rls')
call ale#Set('rust_rls_toolchain', 'nightly')
-function! ale_linters#rust#rls#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'rust_rls_executable')
-endfunction
-
function! ale_linters#rust#rls#GetCommand(buffer) abort
- let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer)
let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
- if empty(l:toolchain)
- return ale#Escape(l:executable)
- else
- return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain)
- endif
+ return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
endfunction
function! ale_linters#rust#rls#GetProjectRoot(buffer) abort
@@ -28,7 +19,7 @@ endfunction
call ale#linter#Define('rust', {
\ 'name': 'rls',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable',
+\ 'executable_callback': ale#VarFunc('rust_rls_executable'),
\ 'command_callback': 'ale_linters#rust#rls#GetCommand',
\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot',
\})
diff --git a/ale_linters/sass/stylelint.vim b/ale_linters/sass/stylelint.vim
index fe941d6a..b6286f18 100644
--- a/ale_linters/sass/stylelint.vim
+++ b/ale_linters/sass/stylelint.vim
@@ -3,20 +3,11 @@
call ale#Set('sass_stylelint_executable', 'stylelint')
call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#sass#stylelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'sass_stylelint', [
- \ 'node_modules/.bin/stylelint',
- \])
-endfunction
-
-function! ale_linters#sass#stylelint#GetCommand(buffer) abort
- return ale_linters#sass#stylelint#GetExecutable(a:buffer)
- \ . ' --stdin-filename %s'
-endfunction
-
call ale#linter#Define('sass', {
\ 'name': 'stylelint',
-\ 'executable_callback': 'ale_linters#sass#stylelint#GetExecutable',
-\ 'command_callback': 'ale_linters#sass#stylelint#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('sass_stylelint', [
+\ 'node_modules/.bin/stylelint',
+\ ]),
+\ 'command': '%e --stdin-filename %s',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})
diff --git a/ale_linters/scala/fsc.vim b/ale_linters/scala/fsc.vim
index 17b26f0b..fbdce20e 100644
--- a/ale_linters/scala/fsc.vim
+++ b/ale_linters/scala/fsc.vim
@@ -1,29 +1,14 @@
" Author: Nils Leuzinger - https://github.com/PawkyPenguin
" Description: Basic scala support using fsc
-"
-function! ale_linters#scala#fsc#GetExecutable(buffer) abort
- if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
- " Don't check sbt files
- return ''
- endif
- return 'fsc'
-endfunction
-
-function! ale_linters#scala#fsc#GetCommand(buffer) abort
- let l:executable = ale_linters#scala#fsc#GetExecutable(a:buffer)
-
- if empty(l:executable)
- return ''
- endif
-
- return ale#Escape(l:executable) . ' -Ystop-after:parser %t'
+function! s:IsSbt(buffer) abort
+ return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
endfunction
call ale#linter#Define('scala', {
\ 'name': 'fsc',
-\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable',
-\ 'command_callback': 'ale_linters#scala#fsc#GetCommand',
+\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'fsc'},
+\ 'command': '%e -Ystop-after:parser %t',
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
\ 'output_stream': 'stderr',
\})
diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim
index 551284af..3dbdd925 100644
--- a/ale_linters/scala/scalac.vim
+++ b/ale_linters/scala/scalac.vim
@@ -2,29 +2,14 @@
" w0rp <devw0rp@gmail.com>
" Description: Basic scala support using scalac
-function! ale_linters#scala#scalac#GetExecutable(buffer) abort
- if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
- " Don't check sbt files
- return ''
- endif
-
- return 'scalac'
-endfunction
-
-function! ale_linters#scala#scalac#GetCommand(buffer) abort
- let l:executable = ale_linters#scala#scalac#GetExecutable(a:buffer)
-
- if empty(l:executable)
- return ''
- endif
-
- return ale#Escape(l:executable) . ' -Ystop-after:parser %t'
+function! s:IsSbt(buffer) abort
+ return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
endfunction
call ale#linter#Define('scala', {
\ 'name': 'scalac',
-\ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable',
-\ 'command_callback': 'ale_linters#scala#scalac#GetCommand',
+\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'},
+\ 'command': '%e -Ystop-after:parser %t',
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
\ 'output_stream': 'stderr',
\})
diff --git a/ale_linters/scss/stylelint.vim b/ale_linters/scss/stylelint.vim
index 6bfdd09a..6d183b4a 100644
--- a/ale_linters/scss/stylelint.vim
+++ b/ale_linters/scss/stylelint.vim
@@ -3,20 +3,11 @@
call ale#Set('scss_stylelint_executable', 'stylelint')
call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#scss#stylelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'scss_stylelint', [
- \ 'node_modules/.bin/stylelint',
- \])
-endfunction
-
-function! ale_linters#scss#stylelint#GetCommand(buffer) abort
- return ale_linters#scss#stylelint#GetExecutable(a:buffer)
- \ . ' --stdin-filename %s'
-endfunction
-
call ale#linter#Define('scss', {
\ 'name': 'stylelint',
-\ 'executable_callback': 'ale_linters#scss#stylelint#GetExecutable',
-\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('scss_stylelint', [
+\ 'node_modules/.bin/stylelint',
+\ ]),
+\ 'command': '%e --stdin-filename %s',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})
diff --git a/ale_linters/sh/shellcheck.vim b/ale_linters/sh/shellcheck.vim
index 27c74531..0f68e62c 100644
--- a/ale_linters/sh/shellcheck.vim
+++ b/ale_linters/sh/shellcheck.vim
@@ -6,14 +6,9 @@
" codes to exclude from shellcheck. For example:
"
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
-let g:ale_sh_shellcheck_exclusions =
-\ get(g:, 'ale_sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
-
-let g:ale_sh_shellcheck_executable =
-\ get(g:, 'ale_sh_shellcheck_executable', 'shellcheck')
-
-let g:ale_sh_shellcheck_options =
-\ get(g:, 'ale_sh_shellcheck_options', '')
+call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
+call ale#Set('sh_shellcheck_executable', 'shellcheck')
+call ale#Set('sh_shellcheck_options', '')
function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'sh_shellcheck_executable')
diff --git a/ale_linters/spec/rpmlint.vim b/ale_linters/spec/rpmlint.vim
index f5308af6..486bef1e 100644
--- a/ale_linters/spec/rpmlint.vim
+++ b/ale_linters/spec/rpmlint.vim
@@ -26,19 +26,12 @@
" And this is always output at the end and should just be ignored:
" 0 packages and 1 specfiles checked; 4 errors, 0 warnings.
-let g:ale_spec_rpmlint_executable =
-\ get(g:, 'ale_spec_rpmlint_executable', 'rpmlint')
-
-let g:ale_spec_rpmlint_options =
-\ get(g:, 'ale_spec_rpmlint_options', '')
-
-function! ale_linters#spec#rpmlint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'spec_rpmlint_executable')
-endfunction
+call ale#Set('spec_rpmlint_executable', 'rpmlint')
+call ale#Set('spec_rpmlint_options', '')
function! ale_linters#spec#rpmlint#GetCommand(buffer) abort
- return ale_linters#spec#rpmlint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'spec_rpmlint_options')
+ return '%e'
+ \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options'))
\ . ' -o "NetworkEnabled False"'
\ . ' -v'
\ . ' %t'
@@ -79,7 +72,7 @@ endfunction
call ale#linter#Define('spec', {
\ 'name': 'rpmlint',
-\ 'executable_callback': 'ale_linters#spec#rpmlint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('spec_rpmlint_executable'),
\ 'command_callback': 'ale_linters#spec#rpmlint#GetCommand',
\ 'callback': 'ale_linters#spec#rpmlint#Handle',
\})
diff --git a/ale_linters/stylus/stylelint.vim b/ale_linters/stylus/stylelint.vim
index 1562692a..2256f3c0 100644
--- a/ale_linters/stylus/stylelint.vim
+++ b/ale_linters/stylus/stylelint.vim
@@ -4,21 +4,17 @@ call ale#Set('stylus_stylelint_executable', 'stylelint')
call ale#Set('stylus_stylelint_options', '')
call ale#Set('stylus_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#stylus#stylelint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'stylus_stylelint', [
- \ 'node_modules/.bin/stylelint',
- \])
-endfunction
-
function! ale_linters#stylus#stylelint#GetCommand(buffer) abort
- return ale_linters#stylus#stylelint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'stylus_stylelint_options')
+ return '%e'
+ \ . ale#Pad(ale#Var(a:buffer, 'stylus_stylelint_options'))
\ . ' --stdin-filename %s'
endfunction
call ale#linter#Define('stylus', {
\ 'name': 'stylelint',
-\ 'executable_callback': 'ale_linters#stylus#stylelint#GetExecutable',
+\ 'executable_callback': ale#node#FindExecutableFunc('stylus_stylelint', [
+\ 'node_modules/.bin/stylelint',
+\ ]),
\ 'command_callback': 'ale_linters#stylus#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})
diff --git a/ale_linters/tcl/nagelfar.vim b/ale_linters/tcl/nagelfar.vim
index 13b7a549..183ea9e7 100644
--- a/ale_linters/tcl/nagelfar.vim
+++ b/ale_linters/tcl/nagelfar.vim
@@ -4,16 +4,10 @@
call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl')
call ale#Set('tcl_nagelfar_options', '')
-function! ale_linters#tcl#nagelfar#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'tcl_nagelfar_executable')
-endfunction
-
function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options')
- return ale#Escape(ale_linters#tcl#nagelfar#GetExecutable(a:buffer))
- \ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' %s'
+ return '%e' . ale#Pad(l:options) . ' %s'
endfunction
function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort
@@ -39,7 +33,7 @@ endfunction
call ale#linter#Define('tcl', {
\ 'name': 'nagelfar',
\ 'output_stream': 'stdout',
-\ 'executable_callback': 'ale_linters#tcl#nagelfar#GetExecutable',
+\ 'executable_callback': ale#VarFunc('tcl_nagelfar_executable'),
\ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand',
\ 'callback': 'ale_linters#tcl#nagelfar#Handle',
\ 'lint_file': 1,
diff --git a/ale_linters/terraform/tflint.vim b/ale_linters/terraform/tflint.vim
index 93966ff3..b8e9c96d 100644
--- a/ale_linters/terraform/tflint.vim
+++ b/ale_linters/terraform/tflint.vim
@@ -30,14 +30,11 @@ function! ale_linters#terraform#tflint#Handle(buffer, lines) abort
return l:output
endfunction
-function! ale_linters#terraform#tflint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'terraform_tflint_executable')
-endfunction
-
function! ale_linters#terraform#tflint#GetCommand(buffer) abort
- let l:cmd = ale#Escape(ale#Var(a:buffer, 'terraform_tflint_executable'))
+ let l:cmd = '%e'
let l:config_file = ale#path#FindNearestFile(a:buffer, '.tflint.hcl')
+
if !empty(l:config_file)
let l:cmd .= ' --config ' . ale#Escape(l:config_file)
endif
@@ -54,9 +51,7 @@ endfunction
call ale#linter#Define('terraform', {
\ 'name': 'tflint',
-\ 'executable_callback': 'ale_linters#terraform#tflint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('terraform_tflint_executable'),
\ 'command_callback': 'ale_linters#terraform#tflint#GetCommand',
\ 'callback': 'ale_linters#terraform#tflint#Handle',
\})
-
-" vim:sw=4
diff --git a/ale_linters/tex/lacheck.vim b/ale_linters/tex/lacheck.vim
index e5a9632b..38135b85 100644
--- a/ale_linters/tex/lacheck.vim
+++ b/ale_linters/tex/lacheck.vim
@@ -1,16 +1,7 @@
" Author: Andrew Balmos - <andrew@balmos.org>
" Description: lacheck for LaTeX files
-let g:ale_tex_lacheck_executable =
-\ get(g:, 'ale_tex_lacheck_executable', 'lacheck')
-
-function! ale_linters#tex#lacheck#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'tex_lacheck_executable')
-endfunction
-
-function! ale_linters#tex#lacheck#GetCommand(buffer) abort
- return ale#Var(a:buffer, 'tex_lacheck_executable') . ' %t'
-endfunction
+call ale#Set('tex_lacheck_executable', 'lacheck')
function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
" Mattes lines like:
@@ -41,7 +32,7 @@ endfunction
call ale#linter#Define('tex', {
\ 'name': 'lacheck',
-\ 'executable_callback': 'ale_linters#tex#lacheck#GetExecutable',
-\ 'command_callback': 'ale_linters#tex#lacheck#GetCommand',
+\ 'executable_callback': ale#VarFunc('tex_lacheck_executable'),
+\ 'command': '%e %t',
\ 'callback': 'ale_linters#tex#lacheck#Handle'
\})
diff --git a/ale_linters/thrift/thrift.vim b/ale_linters/thrift/thrift.vim
index a8fe10b6..ac1f69fc 100644
--- a/ale_linters/thrift/thrift.vim
+++ b/ale_linters/thrift/thrift.vim
@@ -5,10 +5,6 @@ call ale#Set('thrift_thrift_generators', ['cpp'])
call ale#Set('thrift_thrift_includes', [])
call ale#Set('thrift_thrift_options', '-strict')
-function! ale_linters#thrift#thrift#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'thrift_thrift_executable')
-endfunction
-
function! ale_linters#thrift#thrift#GetCommand(buffer) abort
let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators')
let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes')
@@ -22,7 +18,7 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort
let l:output_dir = ale#engine#CreateDirectory(a:buffer)
- return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer))
+ return '%e'
\ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val")))
\ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val")))
\ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options'))
@@ -83,7 +79,7 @@ call ale#linter#Define('thrift', {
\ 'name': 'thrift',
\ 'executable': 'thrift',
\ 'output_stream': 'both',
-\ 'executable_callback': 'ale_linters#thrift#thrift#GetExecutable',
+\ 'executable_callback': ale#VarFunc('thrift_thrift_executable'),
\ 'command_callback': 'ale_linters#thrift#thrift#GetCommand',
\ 'callback': 'ale_linters#thrift#thrift#Handle',
\})
diff --git a/ale_linters/typescript/tsserver.vim b/ale_linters/typescript/tsserver.vim
index 08bd0f41..bac63229 100644
--- a/ale_linters/typescript/tsserver.vim
+++ b/ale_linters/typescript/tsserver.vim
@@ -5,22 +5,13 @@ call ale#Set('typescript_tsserver_executable', 'tsserver')
call ale#Set('typescript_tsserver_config_path', '')
call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0))
-" These functions need to be defined just to comply with the API for LSP.
-function! ale_linters#typescript#tsserver#GetProjectRoot(buffer) abort
- return ''
-endfunction
-
-function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'typescript_tsserver', [
- \ 'node_modules/.bin/tsserver',
- \])
-endfunction
-
call ale#linter#Define('typescript', {
\ 'name': 'tsserver',
\ 'lsp': 'tsserver',
-\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable',
-\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable',
-\ 'project_root_callback': 'ale_linters#typescript#tsserver#GetProjectRoot',
+\ 'executable_callback': ale#node#FindExecutableFunc('typescript_tsserver', [
+\ 'node_modules/.bin/tsserver',
+\ ]),
+\ 'command': '%e',
+\ 'project_root_callback': {-> ''},
\ 'language': '',
\})
diff --git a/ale_linters/vim/ale_custom_linting_rules.vim b/ale_linters/vim/ale_custom_linting_rules.vim
new file mode 100644
index 00000000..f4e111ee
--- /dev/null
+++ b/ale_linters/vim/ale_custom_linting_rules.vim
@@ -0,0 +1,57 @@
+" Author: w0rp <devw0rp@gmail.com>
+" Description: A linter for checking ALE project code itself.
+
+function! ale_linters#vim#ale_custom_linting_rules#GetExecutable(buffer) abort
+ let l:filename = expand('#' . a:buffer . ':p')
+ let l:dir_list = []
+
+ for l:dir in split(&runtimepath, ',')
+ if l:filename[:len(l:dir) - 1] is# l:dir
+ call add(l:dir_list, l:dir)
+ endif
+ endfor
+
+ return !empty(l:dir_list)
+ \ ? findfile('test/script/custom-linting-rules', join(l:dir_list, ','))
+ \ : ''
+endfunction
+
+function! s:GetALEProjectDir(buffer) abort
+ let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer)
+
+ return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
+endfunction
+
+function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
+ let l:dir = s:GetALEProjectDir(a:buffer)
+
+ return ale#path#CdString(l:dir) . '%e .'
+endfunction
+
+function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort
+ let l:dir = s:GetALEProjectDir(a:buffer)
+ let l:output = []
+ let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+) (.+)$'
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:filename = ale#path#GetAbsPath(l:dir, l:match[1])
+
+ if bufnr(l:filename) is a:buffer
+ call add(l:output, {
+ \ 'lnum': l:match[2],
+ \ 'text': l:match[3],
+ \ 'type': 'W',
+ \})
+ endif
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('vim', {
+\ 'name': 'ale_custom_linting_rules',
+\ 'executable_callback': 'ale_linters#vim#ale_custom_linting_rules#GetExecutable',
+\ 'command_callback': 'ale_linters#vim#ale_custom_linting_rules#GetCommand',
+\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle',
+\ 'lint_file': 1,
+\})
diff --git a/ale_linters/vue/vls.vim b/ale_linters/vue/vls.vim
index 0d4bf9f6..7116128b 100644
--- a/ale_linters/vue/vls.vim
+++ b/ale_linters/vue/vls.vim
@@ -4,18 +4,6 @@
call ale#Set('vue_vls_executable', 'vls')
call ale#Set('vue_vls_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#vue#vls#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'vue_vls', [
- \ 'node_modules/.bin/vls',
- \])
-endfunction
-
-function! ale_linters#vue#vls#GetCommand(buffer) abort
- let l:exe = ale#Escape(ale_linters#vue#vls#GetExecutable(a:buffer))
-
- return l:exe . ' --stdio'
-endfunction
-
function! ale_linters#vue#vls#GetProjectRoot(buffer) abort
let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json')
@@ -25,8 +13,10 @@ endfunction
call ale#linter#Define('vue', {
\ 'name': 'vls',
\ 'lsp': 'stdio',
-\ 'executable_callback': 'ale_linters#vue#vls#GetExecutable',
-\ 'command_callback': 'ale_linters#vue#vls#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('vue_vls', [
+\ 'node_modules/.bin/vls',
+\ ]),
+\ 'command': '%e --stdio',
\ 'language': 'vue',
\ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot',
\})
diff --git a/ale_linters/xml/xmllint.vim b/ale_linters/xml/xmllint.vim
index 9d79438e..a0f97c3a 100644
--- a/ale_linters/xml/xmllint.vim
+++ b/ale_linters/xml/xmllint.vim
@@ -5,12 +5,8 @@
let g:ale_xml_xmllint_executable = get(g:, 'ale_xml_xmllint_executable', 'xmllint')
let g:ale_xml_xmllint_options = get(g:, 'ale_xml_xmllint_options', '')
-function! ale_linters#xml#xmllint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'xml_xmllint_executable')
-endfunction
-
function! ale_linters#xml#xmllint#GetCommand(buffer) abort
- return ale#Escape(ale_linters#xml#xmllint#GetExecutable(a:buffer))
+ return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options'))
\ . ' --noout -'
endfunction
@@ -63,7 +59,7 @@ endfunction
call ale#linter#Define('xml', {
\ 'name': 'xmllint',
\ 'output_stream': 'stderr',
-\ 'executable_callback': 'ale_linters#xml#xmllint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('xml_xmllint_executable'),
\ 'command_callback': 'ale_linters#xml#xmllint#GetCommand',
\ 'callback': 'ale_linters#xml#xmllint#Handle',
\ })
diff --git a/ale_linters/yaml/swaglint.vim b/ale_linters/yaml/swaglint.vim
index 4a22c70f..7362536e 100644
--- a/ale_linters/yaml/swaglint.vim
+++ b/ale_linters/yaml/swaglint.vim
@@ -4,17 +4,6 @@
call ale#Set('yaml_swaglint_executable', 'swaglint')
call ale#Set('yaml_swaglint_use_global', get(g:, 'ale_use_global_executables', 0))
-function! ale_linters#yaml#swaglint#GetExecutable(buffer) abort
- return ale#node#FindExecutable(a:buffer, 'yaml_swaglint', [
- \ 'node_modules/.bin/swaglint',
- \])
-endfunction
-
-function! ale_linters#yaml#swaglint#GetCommand(buffer) abort
- return ale_linters#yaml#swaglint#GetExecutable(a:buffer)
- \ . ' -r compact --stdin'
-endfunction
-
function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort
let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$'
let l:output = []
@@ -43,7 +32,9 @@ endfunction
call ale#linter#Define('yaml', {
\ 'name': 'swaglint',
-\ 'executable_callback': 'ale_linters#yaml#swaglint#GetExecutable',
-\ 'command_callback': 'ale_linters#yaml#swaglint#GetCommand',
+\ 'executable_callback': ale#node#FindExecutableFunc('yaml_swaglint', [
+\ 'node_modules/.bin/swaglint',
+\ ]),
+\ 'command': '%e -r compact --stdin',
\ 'callback': 'ale_linters#yaml#swaglint#Handle',
\})
diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim
index f100667e..9d2cc7c2 100644
--- a/ale_linters/yaml/yamllint.vim
+++ b/ale_linters/yaml/yamllint.vim
@@ -1,18 +1,10 @@
" Author: KabbAmine <amine.kabb@gmail.com>
-let g:ale_yaml_yamllint_executable =
-\ get(g:, 'ale_yaml_yamllint_executable', 'yamllint')
-
-let g:ale_yaml_yamllint_options =
-\ get(g:, 'ale_yaml_yamllint_options', '')
-
-function! ale_linters#yaml#yamllint#GetExecutable(buffer) abort
- return ale#Var(a:buffer, 'yaml_yamllint_executable')
-endfunction
+call ale#Set('yaml_yamllint_executable', 'yamllint')
+call ale#Set('yaml_yamllint_options', '')
function! ale_linters#yaml#yamllint#GetCommand(buffer) abort
- return ale_linters#yaml#yamllint#GetExecutable(a:buffer)
- \ . ' ' . ale#Var(a:buffer, 'yaml_yamllint_options')
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
\ . ' -f parsable %t'
endfunction
@@ -52,7 +44,7 @@ endfunction
call ale#linter#Define('yaml', {
\ 'name': 'yamllint',
-\ 'executable_callback': 'ale_linters#yaml#yamllint#GetExecutable',
+\ 'executable_callback': ale#VarFunc('yaml_yamllint_executable'),
\ 'command_callback': 'ale_linters#yaml#yamllint#GetCommand',
\ 'callback': 'ale_linters#yaml#yamllint#Handle',
\})
diff --git a/ale_linters/yang/yang_lsp.vim b/ale_linters/yang/yang_lsp.vim
new file mode 100644
index 00000000..a60e9113
--- /dev/null
+++ b/ale_linters/yang/yang_lsp.vim
@@ -0,0 +1,14 @@
+call ale#Set('yang_lsp_executable', 'yang-language-server')
+
+function! ale_linters#yang#yang_lsp#GetProjectRoot(buffer) abort
+ let l:project_root = ale#path#FindNearestFile(a:buffer, 'yang.settings')
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
+endfunction
+
+call ale#linter#Define('yang', {
+\ 'name': 'yang_lsp',
+\ 'lsp': 'stdio',
+\ 'executable_callback': ale#VarFunc('yang_lsp_executable'),
+\ 'project_root_callback': 'ale_linters#yang#yang_lsp#GetProjectRoot',
+\ 'command': '%e',
+\})
diff --git a/autoload/ale.vim b/autoload/ale.vim
index ee32a9a6..51c0ce83 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -197,6 +197,11 @@ function! ale#Var(buffer, variable_name) abort
return get(l:vars, l:full_name, g:[l:full_name])
endfunction
+" As above, but curry the arguments so only the buffer number is required.
+function! ale#VarFunc(variable_name) abort
+ return {buf -> ale#Var(buf, a:variable_name)}
+endfunction
+
" Initialize a variable with a default value, if it isn't already set.
"
" Every variable name will be prefixed with 'ale_'.
diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim
index a6753a1a..87798520 100644
--- a/autoload/ale/assert.vim
+++ b/autoload/ale/assert.vim
@@ -54,9 +54,14 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
endif
else
let l:command = ale#linter#GetCommand(l:buffer, l:linter)
+ endif
+
+ if type(l:command) is v:t_string
" Replace %e with the escaped executable, so tests keep passing after
" linters are changed to use %e.
let l:command = substitute(l:command, '%e', '\=ale#Escape(l:executable)', 'g')
+ else
+ call map(l:command, 'substitute(v:val, ''%e'', ''\=ale#Escape(l:executable)'', ''g'')')
endif
AssertEqual
@@ -126,7 +131,9 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ if !exists('g:dir')
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ endif
command! -nargs=+ WithChainResults :call ale#assert#WithChainResults(<args>)
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>)
@@ -140,14 +147,33 @@ function! ale#assert#TearDownLinterTest() abort
unlet! g:ale_create_dummy_temporary_file
let s:chain_results = []
- delcommand WithChainResults
- delcommand AssertLinter
- delcommand AssertLinterNotExecuted
- delcommand AssertLSPOptions
- delcommand AssertLSPLanguage
- delcommand AssertLSPProject
+ if exists(':WithChainResults')
+ delcommand WithChainResults
+ endif
+
+ if exists(':AssertLinter')
+ delcommand AssertLinter
+ endif
+
+ if exists(':AssertLinterNotExecuted')
+ delcommand AssertLinterNotExecuted
+ endif
+
+ if exists(':AssertLSPOptions')
+ delcommand AssertLSPOptions
+ endif
+
+ if exists(':AssertLSPLanguage')
+ delcommand AssertLSPLanguage
+ endif
+
+ if exists(':AssertLSPProject')
+ delcommand AssertLSPProject
+ endif
- call ale#test#RestoreDirectory()
+ if exists('g:dir')
+ call ale#test#RestoreDirectory()
+ endif
Restore
diff --git a/autoload/ale/c.vim b/autoload/ale/c.vim
index 19bb0d5e..ae428692 100644
--- a/autoload/ale/c.vim
+++ b/autoload/ale/c.vim
@@ -150,12 +150,22 @@ function! s:GetListFromCompileCommandsFile(compile_commands_file) abort
endfunction
function! ale#c#ParseCompileCommandsFlags(buffer, dir, json_list) abort
+ " Search for an exact file match first.
for l:item in a:json_list
if bufnr(l:item.file) is a:buffer
return ale#c#ParseCFlags(a:dir, l:item.command)
endif
endfor
+ " Look for any file in the same directory if we can't find an exact match.
+ let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h'))
+
+ for l:item in a:json_list
+ if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
+ return ale#c#ParseCFlags(a:dir, l:item.command)
+ endif
+ endfor
+
return ''
endfunction
@@ -246,7 +256,7 @@ function! ale#c#IncludeOptions(include_paths) abort
return ''
endif
- return ' ' . join(l:option_list) . ' '
+ return join(l:option_list)
endfunction
let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index dc34e4c5..e60d67b6 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -157,7 +157,7 @@ let s:default_registry = {
\ },
\ 'hackfmt': {
\ 'function': 'ale#fixers#hackfmt#Fix',
-\ 'suggested_filetypes': ['php'],
+\ 'suggested_filetypes': ['hack'],
\ 'description': 'Fix Hack files with hackfmt.',
\ },
\ 'hfmt': {
diff --git a/autoload/ale/fixers/hackfmt.vim b/autoload/ale/fixers/hackfmt.vim
index b5bf0dc5..bf2d4f71 100644
--- a/autoload/ale/fixers/hackfmt.vim
+++ b/autoload/ale/fixers/hackfmt.vim
@@ -1,12 +1,12 @@
" Author: Sam Howie <samhowie@gmail.com>
" Description: Integration of hackfmt with ALE.
-call ale#Set('php_hackfmt_executable', 'hackfmt')
-call ale#Set('php_hackfmt_options', '')
+call ale#Set('hack_hackfmt_executable', 'hackfmt')
+call ale#Set('hack_hackfmt_options', '')
function! ale#fixers#hackfmt#Fix(buffer) abort
- let l:executable = ale#Var(a:buffer, 'php_hackfmt_executable')
- let l:options = ale#Var(a:buffer, 'php_hackfmt_options')
+ let l:executable = ale#Var(a:buffer, 'hack_hackfmt_executable')
+ let l:options = ale#Var(a:buffer, 'hack_hackfmt_options')
return {
\ 'command': ale#Escape(l:executable)
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim
index e8f4e92e..608240a5 100644
--- a/autoload/ale/fixers/prettier.vim
+++ b/autoload/ale/fixers/prettier.vim
@@ -27,6 +27,17 @@ function! ale#fixers#prettier#Fix(buffer) abort
\}
endfunction
+function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort
+ " If the output is an error message, don't use it.
+ for l:line in a:output[:10]
+ if l:line =~# '^\w*Error:'
+ return []
+ endif
+ endfor
+
+ return a:output
+endfunction
+
function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort
let l:executable = ale#fixers#prettier#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_prettier_options')
@@ -36,12 +47,23 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort
" Append the --parser flag depending on the current filetype (unless it's
" already set in g:javascript_prettier_options).
if empty(expand('#' . a:buffer . ':e')) && match(l:options, '--parser') == -1
- let l:prettier_parsers = ['typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue']
- let l:parser = 'babylon'
+ let l:prettier_parsers = {
+ \ 'typescript': 'typescript',
+ \ 'css': 'css',
+ \ 'less': 'less',
+ \ 'scss': 'scss',
+ \ 'json': 'json',
+ \ 'json5': 'json5',
+ \ 'graphql': 'graphql',
+ \ 'markdown': 'markdown',
+ \ 'vue': 'vue',
+ \ 'yaml': 'yaml',
+ \}
+ let l:parser = ''
for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.')
- if index(l:prettier_parsers, l:filetype) > -1
- let l:parser = l:filetype
+ if has_key(l:prettier_parsers, l:filetype)
+ let l:parser = l:prettier_parsers[l:filetype]
break
endif
endfor
@@ -51,6 +73,17 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort
let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--parser ' . l:parser
endif
+ " Special error handling needed for prettier_d
+ if l:executable =~# 'prettier_d$'
+ return {
+ \ 'command': ale#path#BufferCdString(a:buffer)
+ \ . ale#Escape(l:executable)
+ \ . (!empty(l:options) ? ' ' . l:options : '')
+ \ . ' --stdin-filepath %s --stdin',
+ \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput',
+ \}
+ endif
+
" 1.4.0 is the first version with --stdin-filepath
if ale#semver#GTE(l:version, [1, 4, 0])
return {
diff --git a/autoload/ale/handlers/gcc.vim b/autoload/ale/handlers/gcc.vim
index 4b53652a..72d639da 100644
--- a/autoload/ale/handlers/gcc.vim
+++ b/autoload/ale/handlers/gcc.vim
@@ -5,6 +5,13 @@ scriptencoding utf-8
let s:pragma_error = '#pragma once in main file'
+" Look for lines like the following.
+"
+" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
+" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
+" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
+let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
+
function! s:IsHeaderFile(filename) abort
return a:filename =~? '\v\.(h|hpp)$'
endfunction
@@ -18,16 +25,63 @@ function! s:RemoveUnicodeQuotes(text) abort
return l:text
endfunction
+" Report problems inside of header files just for gcc and clang
+function! s:ParseProblemsInHeaders(buffer, lines) abort
+ let l:output = []
+ let l:include_item = {}
+
+ for l:line in a:lines[: -2]
+ let l:include_match = matchlist(l:line, '\v^In file included from')
+
+ if !empty(l:include_item)
+ let l:pattern_match = matchlist(l:line, s:pattern)
+
+ if !empty(l:pattern_match) && l:pattern_match[1] is# '<stdin>'
+ if has_key(l:include_item, 'lnum')
+ call add(l:output, l:include_item)
+ endif
+
+ let l:include_item = {}
+
+ continue
+ endif
+
+ let l:include_item.detail .= "\n" . l:line
+ endif
+
+ if !empty(l:include_match)
+ if empty(l:include_item)
+ let l:include_item = {
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': l:line,
+ \}
+ endif
+ endif
+
+ if !empty(l:include_item)
+ let l:stdin_match = matchlist(l:line, '\vfrom \<stdin\>:(\d+):(\d*):?$')
+
+ if !empty(l:stdin_match)
+ let l:include_item.lnum = str2nr(l:stdin_match[1])
+
+ if str2nr(l:stdin_match[2])
+ let l:include_item.col = str2nr(l:stdin_match[2])
+ endif
+ endif
+ endif
+ endfor
+
+ if !empty(l:include_item) && has_key(l:include_item, 'lnum')
+ call add(l:output, l:include_item)
+ endif
+
+ return l:output
+endfunction
+
function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
- " Look for lines like the following.
- "
- " <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
- " <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
- " -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
- let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
let l:output = []
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ for l:match in ale#util#GetMatches(a:lines, s:pattern)
" Filter out the pragma errors
if s:IsHeaderFile(bufname(bufnr('')))
\&& l:match[5][:len(s:pragma_error) - 1] is# s:pragma_error
@@ -38,9 +92,12 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
" the previous error parsed in output
if l:match[4] is# 'note'
if !empty(l:output)
- let l:output[-1]['detail'] =
- \ get(l:output[-1], 'detail', '')
- \ . s:RemoveUnicodeQuotes(l:match[0]) . "\n"
+ if !has_key(l:output[-1], 'detail')
+ let l:output[-1].detail = l:output[-1].text
+ endif
+
+ let l:output[-1].detail = l:output[-1].detail . "\n"
+ \ . s:RemoveUnicodeQuotes(l:match[0])
endif
continue
@@ -67,3 +124,12 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
return l:output
endfunction
+
+" Handle problems with the GCC format, but report problems inside of headers.
+function! ale#handlers#gcc#HandleGCCFormatWithIncludes(buffer, lines) abort
+ let l:output = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines)
+
+ call extend(l:output, s:ParseProblemsInHeaders(a:buffer, a:lines))
+
+ return l:output
+endfunction
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 683d506a..ab86d77e 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -26,11 +26,13 @@ let s:default_ale_linter_aliases = {
"
" Only cargo is enabled for Rust by default.
" rpmlint is disabled by default because it can result in code execution.
+" hhast is disabled by default because it executes code in the project root.
"
" NOTE: Update the g:ale_linters documentation when modifying this.
let s:default_ale_linters = {
\ 'csh': ['shell'],
\ 'go': ['gofmt', 'golint', 'go vet'],
+\ 'hack': ['hack'],
\ 'help': [],
\ 'perl': ['perlcritic'],
\ 'python': ['flake8', 'mypy', 'pylint'],
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim
index 5d900138..cfc89199 100644
--- a/autoload/ale/lsp.vim
+++ b/autoload/ale/lsp.vim
@@ -300,19 +300,6 @@ function! ale#lsp#HandleMessage(conn, message) abort
endfor
endfunction
-function! s:HandleChannelMessage(channel_id, message) abort
- let l:address = ale#socket#GetAddress(a:channel_id)
- let l:conn = s:FindConnection('id', l:address)
-
- call ale#lsp#HandleMessage(l:conn, a:message)
-endfunction
-
-function! s:HandleCommandMessage(job_id, message) abort
- let l:conn = s:FindConnection('id', a:job_id)
-
- call ale#lsp#HandleMessage(l:conn, a:message)
-endfunction
-
" Given a connection ID, mark it as a tsserver connection, so it will be
" handled that way.
function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort
@@ -373,7 +360,7 @@ function! ale#lsp#StartProgram(executable, command, init_options) abort
if !has_key(l:conn, 'id') || !ale#job#IsRunning(l:conn.id)
let l:options = {
\ 'mode': 'raw',
- \ 'out_cb': function('s:HandleCommandMessage'),
+ \ 'out_cb': {_, message -> ale#lsp#HandleMessage(l:conn, message)},
\}
let l:job_id = ale#job#Start(a:command, l:options)
else
@@ -397,7 +384,7 @@ function! ale#lsp#ConnectToAddress(address, init_options) abort
if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id)
let l:conn.channel_id = ale#socket#Open(a:address, {
- \ 'callback': function('s:HandleChannelMessage'),
+ \ 'callback': {_, message -> ale#lsp#HandleMessage(l:conn, message)},
\})
endif
diff --git a/autoload/ale/lsp/response.vim b/autoload/ale/lsp/response.vim
index 48740ad1..561be62e 100644
--- a/autoload/ale/lsp/response.vim
+++ b/autoload/ale/lsp/response.vim
@@ -47,7 +47,12 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
endif
if has_key(l:diagnostic, 'code')
- let l:loclist_item.nr = l:diagnostic.code
+ if type(l:diagnostic.code) == v:t_string
+ let l:loclist_item.code = l:diagnostic.code
+ elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1
+ let l:loclist_item.code = string(l:diagnostic.code)
+ let l:loclist_item.nr = l:diagnostic.code
+ endif
endif
call add(l:loclist, l:loclist_item)
@@ -70,7 +75,12 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
\}
if has_key(l:diagnostic, 'code')
- let l:loclist_item.nr = l:diagnostic.code
+ if type(l:diagnostic.code) == v:t_string
+ let l:loclist_item.code = l:diagnostic.code
+ elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1
+ let l:loclist_item.code = string(l:diagnostic.code)
+ let l:loclist_item.nr = l:diagnostic.code
+ endif
endif
if get(l:diagnostic, 'category') is# 'warning'
@@ -110,7 +120,7 @@ function! ale#lsp#response#GetErrorMessage(response) abort
if type(l:error_data) is v:t_string
let l:message .= "\n" . l:error_data
- else
+ elseif type(l:error_data) is v:t_dict
let l:traceback = get(l:error_data, 'traceback', [])
if type(l:traceback) is v:t_list && !empty(l:traceback)
diff --git a/autoload/ale/node.vim b/autoload/ale/node.vim
index f75280b7..5c579c75 100644
--- a/autoload/ale/node.vim
+++ b/autoload/ale/node.vim
@@ -23,6 +23,11 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
+" As above, but curry the arguments so only the buffer number is required.
+function! ale#node#FindExecutableFunc(base_var_name, path_list) abort
+ return {buf -> ale#node#FindExecutable(buf, a:base_var_name, a:path_list)}
+endfunction
+
" Create a executable string which executes a Node.js script command with a
" Node.js executable if needed.
"
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index bc1cc980..1f963431 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -24,6 +24,7 @@ function! ale#python#FindProjectRootIni(buffer) abort
\|| filereadable(l:path . '/mypy.ini')
\|| filereadable(l:path . '/pycodestyle.cfg')
\|| filereadable(l:path . '/flake8.cfg')
+ \|| filereadable(l:path . '/.flake8rc')
\|| filereadable(l:path . '/Pipfile')
\|| filereadable(l:path . '/Pipfile.lock')
return l:path
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index be37d1b5..e9b5688d 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -88,10 +88,10 @@ endfunction
function! ale#util#Open(filename, line, column, options) abort
if get(a:options, 'open_in_tab', 0)
- call ale#util#Execute('tabedit ' . fnameescape(a:filename))
+ call ale#util#Execute('tabedit +' . a:line . ' ' . fnameescape(a:filename))
elseif bufnr(a:filename) isnot bufnr('')
" Open another file only if we need to.
- call ale#util#Execute('edit ' . fnameescape(a:filename))
+ call ale#util#Execute('edit +' . a:line . ' ' . fnameescape(a:filename))
else
normal! m`
endif
diff --git a/doc/ale-hack.txt b/doc/ale-hack.txt
new file mode 100644
index 00000000..4776b8cf
--- /dev/null
+++ b/doc/ale-hack.txt
@@ -0,0 +1,51 @@
+===============================================================================
+ALE Hack Integration *ale-hack-options*
+ *ale-integration-hack*
+
+ HHAST is disabled by default, as it executes code in the project root.
+
+ Currently linters must be enabled globally. HHAST can be enabled with:
+
+>
+ let g:ale_linters = {'hack': ['hack', 'hhast']}
+<
+
+===============================================================================
+hack *ale-hack-hack*
+
+g:ale_hack_hack_executable *g:ale_hack_hack_executable*
+ *b:ale_hack_hack_executable*
+
+ Type: |String|
+ Default: `'hh_client'`
+
+ This variable can be set to use a specific executable to interact with the
+ Hack typechecker.
+
+
+===============================================================================
+hackfmt *ale-hack-hackfmt*
+
+g:ale_hack_hackfmt_options *g:ale_hack_hackfmt_options*
+ *b:ale_hack_hackfmt_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to the hackfmt fixer.
+
+
+===============================================================================
+hhast *ale-hack-hhast*
+
+g:ale_hack_hhast_executable *g:ale_hack_hhast_executable*
+ *b:ale_hack_hhast_executable*
+
+ Type: |String|
+ Default: `'vendor/bin/hhast-lint'`
+
+ This variable can be set to use a specific executable to interact with the
+ Hack typechecker.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt
index 15d3ce48..379cd987 100644
--- a/doc/ale-haskell.txt
+++ b/doc/ale-haskell.txt
@@ -80,4 +80,15 @@ g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options*
===============================================================================
+hie *ale-haskell-hie*
+
+g:ale_haskell_hie_executable *g:ale_haskell_hie_executable*
+ *b:ale_haskell_hie_executable*
+ Type: |String|
+ Default: `'hie'`
+
+ This variable can be changed to use a different executable for the haskell
+ ide engine. i.e. `'hie-wrapper'`
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-php.txt b/doc/ale-php.txt
index 33796f7c..ba53db89 100644
--- a/doc/ale-php.txt
+++ b/doc/ale-php.txt
@@ -1,24 +1,6 @@
===============================================================================
ALE PHP Integration *ale-php-options*
-
-===============================================================================
-hack *ale-php-hack*
-
-There are no options for this linter.
-
-
-===============================================================================
-hackfmt *ale-php-hackfmt*
-
-g:ale_php_hackfmt_options *g:ale_php_hackfmt_options*
- *b:ale_php_hackfmt_options*
- Type: |String|
- Default: `''`
-
- This variable can be set to pass additional options to the hackfmt fixer.
-
-
===============================================================================
langserver *ale-php-langserver*
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index 093ea758..b5c469b1 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -22,6 +22,7 @@ ALE will look for configuration files with the following filenames. >
mypy.ini
pycodestyle.cfg
flake8.cfg
+ .flake8rc
Pipfile
Pipfile.lock
<
diff --git a/doc/ale-rust.txt b/doc/ale-rust.txt
index 46e8b2c5..a6bd59ad 100644
--- a/doc/ale-rust.txt
+++ b/doc/ale-rust.txt
@@ -5,8 +5,9 @@ ALE Rust Integration *ale-rust-options*
===============================================================================
Integration Information
- Since Vim does not detect the rust file type out-of-the-box, you need the
- runtime files for rust from here: https://github.com/rust-lang/rust.vim
+ If Vim does not detect the Rust file type out-of-the-box, you need the runtime
+ files for Rust distributed in Vim >=8.0.0501 or upstream:
+ https://github.com/rust-lang/rust.vim
Note that there are three possible linters for Rust files:
diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt
index 1bccf5a3..0cb0a7c2 100644
--- a/doc/ale-typescript.txt
+++ b/doc/ale-typescript.txt
@@ -19,6 +19,16 @@ See |ale-javascript-prettier| for information about the available options.
===============================================================================
tslint *ale-typescript-tslint*
+This linter isn't recommended, because TSLint can't be used for checking for
+problems while you type. You should probably use the tsserver plugin instead.
+
+Follow the instructions on the plugin website for installing it:
+https://github.com/angelozerr/tsserver-plugins
+
+Then disable TSLint in vimrc or any other Vim configuration file. >
+ let g:ale_linters_ignore = {'typescript': ['tslint']}
+<
+
g:ale_typescript_tslint_executable *g:ale_typescript_tslint_executable*
*b:ale_typescript_tslint_executable*
Type: |String|
diff --git a/doc/ale-yaml.txt b/doc/ale-yaml.txt
index 044d0b3d..c9a12ea1 100644
--- a/doc/ale-yaml.txt
+++ b/doc/ale-yaml.txt
@@ -1,7 +1,21 @@
===============================================================================
ALE YAML Integration *ale-yaml-options*
+===============================================================================
+prettier *ale-yaml-prettier*
+
+Website: https://github.com/prettier/prettier
+
+
+Installation
+-------------------------------------------------------------------------------
+Install prettier either globally or locally: >
+
+ npm install prettier -g # global
+ npm install prettier # local
+<
+
===============================================================================
swaglint *ale-yaml-swaglint*
diff --git a/doc/ale-yang.txt b/doc/ale-yang.txt
new file mode 100644
index 00000000..ad619733
--- /dev/null
+++ b/doc/ale-yang.txt
@@ -0,0 +1,17 @@
+===============================================================================
+ALE YANG Integration *ale-yang-options*
+
+
+===============================================================================
+yang-lsp *ale-yang-lsp*
+
+g:ale_yang_lsp_executable *g:ale_yang_lsp_executable*
+ *b:ale_yang_lsp_executable*
+ Type: |String|
+ Default: `'yang-language-server'`
+
+ This variable can be changed to use a different executable for yang-lsp.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index 15a20469..8af4c435 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -96,6 +96,10 @@ CONTENTS *ale-contents*
eslint..............................|ale-graphql-eslint|
gqlint..............................|ale-graphql-gqlint|
prettier............................|ale-graphql-prettier|
+ hack..................................|ale-hack-options|
+ hack................................|ale-hack-hack|
+ hackfmt.............................|ale-hack-hackfmt|
+ hhast...............................|ale-hack-hhast|
handlebars............................|ale-handlebars-options|
ember-template-lint.................|ale-handlebars-embertemplatelint|
haskell...............................|ale-haskell-options|
@@ -105,6 +109,7 @@ CONTENTS *ale-contents*
hdevtools...........................|ale-haskell-hdevtools|
hfmt................................|ale-haskell-hfmt|
stack-build.........................|ale-haskell-stack-build|
+ hie.................................|ale-haskell-hie|
html..................................|ale-html-options|
htmlhint............................|ale-html-htmlhint|
tidy................................|ale-html-tidy|
@@ -171,8 +176,6 @@ CONTENTS *ale-contents*
perlcritic..........................|ale-perl-perlcritic|
perltidy............................|ale-perl-perltidy|
php...................................|ale-php-options|
- hack................................|ale-php-hack|
- hackfmt.............................|ale-php-hackfmt|
langserver..........................|ale-php-langserver|
phan................................|ale-php-phan|
phpcbf..............................|ale-php-phpcbf|
@@ -287,8 +290,11 @@ CONTENTS *ale-contents*
xml...................................|ale-xml-options|
xmllint.............................|ale-xml-xmllint|
yaml..................................|ale-yaml-options|
+ prettier............................|ale-yaml-prettier|
swaglint............................|ale-yaml-swaglint|
yamllint............................|ale-yaml-yamllint|
+ yang..................................|ale-yang-options|
+ yang-lsp............................|ale-yang-lsp|
8. Commands/Keybinds....................|ale-commands|
9. API..................................|ale-api|
10. Special Thanks......................|ale-special-thanks|
@@ -367,9 +373,10 @@ Notes:
* GLSL: glslang, `glslls`
* Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
* GraphQL: `eslint`, `gqlint`, `prettier`
+* Hack: `hack`, `hackfmt`, `hhast`
* Haml: `haml-lint`
* Handlebars: `ember-template-lint`
-* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`
+* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`, `hie`
* HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good`
* Idris: `idris`
* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`
@@ -393,7 +400,7 @@ Notes:
* Objective-C++: `clang`
* OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`
* Perl: `perl -c`, `perl-critic`, `perltidy`
-* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer`
+* PHP: `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer`
* PO: `alex`!!, `msgfmt`, `proselint`, `write-good`
* Pod: `alex`!!, `proselint`, `write-good`
* Pony: `ponyc`
@@ -430,7 +437,8 @@ Notes:
* Vue: `prettier`, `vls`
* XHTML: `alex`!!, `proselint`, `write-good`
* XML: `xmllint`
-* YAML: `swaglint`, `yamllint`
+* YAML: `prettier`, `swaglint`, `yamllint`
+* YANG: `yang-lsp`
===============================================================================
3. Linting *ale-lint*
@@ -646,10 +654,10 @@ servers. LSP linters can be used in combination with any other linter, and
will automatically connect to LSP servers when needed. ALE also supports
`tsserver` for TypeScript, which uses a different but very similar protocol.
-ALE supports the following LSP/tsserver features.
+ALE supports the following LSP/tsserver features:
1. Diagnostics/linting - Enabled via selecting linters as usual.
-2. Completion (Only for tsserver)
+2. Completion
3. Go to definition
@@ -657,7 +665,7 @@ ALE supports the following LSP/tsserver features.
5.1 Completion *ale-completion*
ALE offers limited support for automatic completion of code while you type.
-Completion is only supported while a least one LSP linter is enabled. ALE
+Completion is only supported while at least one LSP linter is enabled. ALE
will only suggest symbols provided by the LSP servers.
Suggestions will be made while you type after completion is enabled.
@@ -669,6 +677,16 @@ items can be controlled with |g:ale_completion_max_suggestions|.
If you don't like some of the suggestions you see, you can filter them out
with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|.
+ *ale-completion-completopt-bug*
+
+ALE implements completion as you type by temporarily adjusting |completeopt|
+before opening the omnicomplete menu with <C-x><C-o>. In some versions of Vim,
+the value set for the option will not be respected. If you experience issues
+with Vim automatically inserting text while you type, set the following option
+in vimrc, and your issues should go away. >
+
+ set completeopt=menu,menuone,preview,noselect,noinsert
+<
-------------------------------------------------------------------------------
5.2 Go To Definition *ale-go-to-definition*
@@ -1201,6 +1219,7 @@ g:ale_linters *g:ale_linters*
{
\ 'csh': ['shell'],
\ 'go': ['gofmt', 'golint', 'go vet'],
+ \ 'hack': ['hack'],
\ 'help': [],
\ 'perl': ['perlcritic'],
\ 'python': ['flake8', 'mypy', 'pylint'],
@@ -2318,6 +2337,13 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
`type` - Defaults to `'E'`.
`nr` - Defaults to `-1`.
+ Numeric error code. If `nr` is not `-1`, `code`
+ likely should contain the string representation of
+ the same value.
+ `code` - No default; may be unset.
+
+ Human-readable |String| error code.
+
`executable` A |String| naming the executable itself which
will be run. This value will be used to check if the
program requested is installed or not.
diff --git a/plugin/ale.vim b/plugin/ale.vim
index f0f90b6b..ffb5da8a 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -14,7 +14,7 @@ let g:loaded_ale_dont_use_this_in_other_plugins_please = 1
" A flag for detecting if the required features are set.
if has('nvim')
- let s:has_features = has('timers')
+ let s:has_features = has('timers') && has('nvim-0.2.0')
else
" Check if Job and Channel functions are available, instead of the
" features. This works better on old MacVim versions.
@@ -24,7 +24,7 @@ endif
if !s:has_features
" Only output a warning if editing some special files.
if index(['', 'gitcommit'], &filetype) == -1
- execute 'echoerr ''ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel'''
+ execute 'echoerr ''ALE requires NeoVim >= 0.2.0 or Vim 8 with +timers +job +channel'''
execute 'echoerr ''Please update your editor appropriately.'''
endif
diff --git a/test/hack_files/testfile.php b/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json
index e69de29b..e69de29b 100644
--- a/test/hack_files/testfile.php
+++ b/test/command_callback/cquery_paths/with_compile_commands_json/compile_commands.json
diff --git a/test/command_callback/cquery_paths/with_cquery/.cquery b/test/command_callback/cquery_paths/with_cquery/.cquery
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/cquery_paths/with_cquery/.cquery
diff --git a/test/command_callback/test_c_cquery_command_callbacks.vader b/test/command_callback/test_c_cquery_command_callbacks.vader
new file mode 100644
index 00000000..13b7a567
--- /dev/null
+++ b/test/command_callback/test_c_cquery_command_callbacks.vader
@@ -0,0 +1,33 @@
+Before:
+ call ale#assert#SetUpLinterTest('c', 'cquery')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The project root should be detected correctly using compile_commands.json file):
+ AssertLSPProject ''
+
+ call ale#test#SetFilename('cquery_paths/with_compile_commands_json/dummy.c')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_compile_commands_json')
+
+Execute(The project root should be detected correctly using .cquery file):
+ AssertLSPProject ''
+
+ call ale#test#SetFilename('cquery_paths/with_cquery/dummy.c')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_cquery')
+
+Execute(The executable should be configurable):
+ AssertLinter 'cquery', ale#Escape('cquery')
+
+ let b:ale_c_cquery_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar')
+
+Execute(The cache directory should be configurable):
+ AssertLSPOptions {'cacheDirectory': expand('$HOME/.cache/cquery')}
+
+ let b:ale_c_cquery_cache_directory = '/foo/bar'
+
+ AssertLSPOptions {'cacheDirectory': '/foo/bar'}
diff --git a/test/command_callback/test_c_flawfinder_command_callbacks.vader b/test/command_callback/test_c_flawfinder_command_callbacks.vader
index 44573ff5..38385e2b 100644
--- a/test/command_callback/test_c_flawfinder_command_callbacks.vader
+++ b/test/command_callback/test_c_flawfinder_command_callbacks.vader
@@ -13,7 +13,7 @@ Execute(The minlevel of flawfinder should be configurable):
AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
Execute(Additional flawfinder options should be configurable):
- let b:ale_c_flawfinder_options = ' --foobar'
+ let b:ale_c_flawfinder_options = '--foobar'
AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'
diff --git a/test/command_callback/test_c_import_paths.vader b/test/command_callback/test_c_import_paths.vader
new file mode 100644
index 00000000..80fff57b
--- /dev/null
+++ b/test/command_callback/test_c_import_paths.vader
@@ -0,0 +1,223 @@
+Before:
+ " Make sure the c.vim file is loaded first.
+ call ale#c#FindProjectRoot(bufnr(''))
+
+ Save g:ale_c_parse_makefile
+ Save g:__ale_c_project_filenames
+
+ let g:original_project_filenames = g:__ale_c_project_filenames
+
+ " Remove the .git/HEAD dir for C import paths for these tests.
+ " The tests run inside of a git repo.
+ let g:__ale_c_project_filenames = filter(
+ \ copy(g:__ale_c_project_filenames),
+ \ 'v:val isnot# ''.git/HEAD'''
+ \)
+
+ let g:ale_c_parse_makefile = 0
+
+After:
+ unlet! g:original_project_filenames
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The C GCC handler should include 'include' directories for projects with a Makefile):
+ call ale#assert#SetUpLinterTest('c', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
+ let g:ale_c_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c -fsyntax-only'
+ \ . ' -iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
+ \ . ' -'
+
+Execute(The C GCC handler should include 'include' directories for projects with a configure file):
+ call ale#assert#SetUpLinterTest('c', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.c')
+ let g:ale_c_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
+ \ . ' -'
+
+Execute(The C GCC handler should include root directories for projects with .h files in them):
+ call ale#assert#SetUpLinterTest('c', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
+ let g:ale_c_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
+ \ . ' -'
+
+Execute(The C GCC handler should include root directories for projects with .hpp files in them):
+ call ale#assert#SetUpLinterTest('c', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
+ let g:ale_c_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
+ \ . ' -'
+
+Execute(The C Clang handler should include 'include' directories for projects with a Makefile):
+ call ale#assert#SetUpLinterTest('c', 'clang')
+ call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
+ let g:ale_c_clang_options = ''
+
+ AssertLinter 'clang',
+ \ ale#Escape('clang')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
+ \ . ' -'
+
+Execute(The C Clang handler should include 'include' directories for projects with a configure file):
+ call ale#assert#SetUpLinterTest('c', 'clang')
+ call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
+ let g:ale_c_clang_options = ''
+
+ AssertLinter 'clang',
+ \ ale#Escape('clang')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
+ \ . ' -'
+
+Execute(The C Clang handler should include root directories for projects with .h files in them):
+ call ale#assert#SetUpLinterTest('c', 'clang')
+ call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
+ let g:ale_c_clang_options = ''
+
+ AssertLinter 'clang',
+ \ ale#Escape('clang')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
+ \ . ' -'
+
+Execute(The C Clang handler should include root directories for projects with .hpp files in them):
+ call ale#assert#SetUpLinterTest('c', 'clang')
+ call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
+ let g:ale_c_clang_options = ''
+
+ AssertLinter 'clang',
+ \ ale#Escape('clang')
+ \ . ' -S -x c -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
+ \ . ' -'
+
+Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile):
+ call ale#assert#SetUpLinterTest('cpp', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
+ let g:ale_cpp_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
+ \ . ' -'
+
+Execute(The C++ GCC handler should include 'include' directories for projects with a configure file):
+ call ale#assert#SetUpLinterTest('cpp', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
+ let g:ale_cpp_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
+ \ . ' -'
+
+Execute(The C++ GCC handler should include root directories for projects with .h files in them):
+ call ale#assert#SetUpLinterTest('cpp', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
+ let g:ale_cpp_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
+ \ . ' -'
+
+Execute(The C++ GCC handler should include root directories for projects with .hpp files in them):
+ call ale#assert#SetUpLinterTest('cpp', 'gcc')
+ call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
+ let g:ale_cpp_gcc_options = ''
+
+ AssertLinter 'gcc',
+ \ ale#Escape('gcc')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
+ \ . ' -'
+
+Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile):
+ call ale#assert#SetUpLinterTest('cpp', 'clang')
+ call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
+ let g:ale_cpp_clang_options = ''
+
+ AssertLinter 'clang++',
+ \ ale#Escape('clang++')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))
+ \ . ' -'
+
+Execute(The C++ Clang handler should include 'include' directories for projects with a configure file):
+ call ale#assert#SetUpLinterTest('cpp', 'clang')
+ call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
+ let g:ale_cpp_clang_options = ''
+
+ AssertLinter 'clang++',
+ \ ale#Escape('clang++')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/configure_project/include'))
+ \ . ' -'
+
+Execute(The C++ Clang handler should include root directories for projects with .h files in them):
+ call ale#assert#SetUpLinterTest('cpp', 'clang')
+ call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
+ let g:ale_cpp_clang_options = ''
+
+ AssertLinter 'clang++',
+ \ ale#Escape('clang++')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/h_file_project'))
+ \ . ' -'
+
+Execute(The C++ Clang handler should include root directories for projects with .hpp files in them):
+ call ale#assert#SetUpLinterTest('cpp', 'clang')
+ call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
+ let g:ale_cpp_clang_options = ''
+
+ AssertLinter 'clang++',
+ \ ale#Escape('clang++')
+ \ . ' -S -x c++ -fsyntax-only '
+ \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project/subdir'))
+ \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project'))
+ \ . ' -'
+
+Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
+ call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
+ call ale#test#SetFilename('../test_c_projects/json_project/subdir/file.cpp')
+
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy')
+ \ . ' -checks=' . ale#Escape('*') . ' %s '
+ \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/json_project/build'))
diff --git a/test/command_callback/test_cpp_cquery_command_callbacks.vader b/test/command_callback/test_cpp_cquery_command_callbacks.vader
index b355d052..682c90d5 100644
--- a/test/command_callback/test_cpp_cquery_command_callbacks.vader
+++ b/test/command_callback/test_cpp_cquery_command_callbacks.vader
@@ -7,6 +7,20 @@ Before:
After:
call ale#assert#TearDownLinterTest()
+Execute(The project root should be detected correctly using compile_commands.json file):
+ AssertLSPProject ''
+
+ call ale#test#SetFilename('cquery_paths/with_compile_commands_json/dummy.cpp')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_compile_commands_json')
+
+Execute(The project root should be detected correctly using .cquery file):
+ AssertLSPProject ''
+
+ call ale#test#SetFilename('cquery_paths/with_cquery/dummy.cpp')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/cquery_paths/with_cquery')
+
Execute(The executable should be configurable):
AssertLinter 'cquery', ale#Escape('cquery')
diff --git a/test/command_callback/test_cuda_nvcc_command_callbacks.vader b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
index 9e2b5ac6..4578d052 100644
--- a/test/command_callback/test_cuda_nvcc_command_callbacks.vader
+++ b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
@@ -12,3 +12,9 @@ Execute(The executable should be configurable):
AssertLinter 'foobar',
\ ale#Escape('foobar') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file
+
+Execute(The options should be configurable):
+ let g:ale_cuda_nvcc_options = '--foobar'
+
+ AssertLinter 'nvcc',
+ \ ale#Escape('nvcc') . ' -cuda --foobar %s -o ' . g:ale#util#nul_file
diff --git a/test/command_callback/test_elm_make_command_callback.vader b/test/command_callback/test_elm_make_command_callback.vader
new file mode 100644
index 00000000..6d95676f
--- /dev/null
+++ b/test/command_callback/test_elm_make_command_callback.vader
@@ -0,0 +1,32 @@
+Before:
+ call ale#assert#SetUpLinterTest('elm', 'make')
+
+After:
+ unlet! g:executable
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(should get valid executable with default params):
+ call ale#test#SetFilename('../elm-test-files/app/testfile.elm')
+
+ let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/app/node_modules/.bin/elm')
+
+ AssertLinter g:executable,
+ \ ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
+
+Execute(should get valid executable with 'use_global' params):
+ let g:ale_elm_make_use_global = 1
+
+ call ale#test#SetFilename('../elm-test-files/app/testfile.elm')
+
+ AssertLinter 'elm',
+ \ ale#Escape('elm') . ' make --report=json --output=/dev/null %t'
+
+Execute(should get valid executable with 'use_global' and 'executable' params):
+ let g:ale_elm_make_executable = 'other-elm'
+ let g:ale_elm_make_use_global = 1
+
+ call ale#test#SetFilename('../elm-test-files/app/testfile.elm')
+
+ AssertLinter 'other-elm',
+ \ ale#Escape('other-elm') . ' make --report=json --output=/dev/null %t'
diff --git a/test/command_callback/test_fsc_command_callback.vader b/test/command_callback/test_fsc_command_callback.vader
index 5fb5e7fa..278e7c16 100644
--- a/test/command_callback/test_fsc_command_callback.vader
+++ b/test/command_callback/test_fsc_command_callback.vader
@@ -10,4 +10,4 @@ Execute(The default executable and command should be correct):
Given scala.sbt(An empty SBT file):
Execute(fsc should not be run for sbt files):
- AssertLinter '', ''
+ AssertLinterNotExecuted
diff --git a/test/command_callback/test_gawk_command_callback.vader b/test/command_callback/test_gawk_command_callback.vader
index 6bc0a438..ba9f59ab 100644
--- a/test/command_callback/test_gawk_command_callback.vader
+++ b/test/command_callback/test_gawk_command_callback.vader
@@ -6,14 +6,14 @@ After:
Execute(The default command should be correct):
AssertLinter 'gawk',
- \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ ale#Escape('gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ' -f %t --lint /dev/null'
Execute(The executable should be configurable):
let b:ale_awk_gawk_executable = '/other/gawk'
AssertLinter '/other/gawk',
- \ ale#Escape('/other/gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ ale#Escape('/other/gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ' -f %t --lint /dev/null'
Execute(The options should be configurable):
@@ -21,5 +21,5 @@ Execute(The options should be configurable):
let b:ale_awk_gawk_options = '--something'
AssertLinter 'gawk',
- \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ ale#Escape('gawk') . ' --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ' --something -f %t --lint /dev/null'
diff --git a/test/command_callback/test_gfortran_command_callback.vader b/test/command_callback/test_gfortran_command_callback.vader
index a6ab50cd..3e6ef951 100644
--- a/test/command_callback/test_gfortran_command_callback.vader
+++ b/test/command_callback/test_gfortran_command_callback.vader
@@ -5,20 +5,20 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The fortran gcc command callback should return the correct default string):
- AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -'
+ AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffree-form -Wall -'
Execute(The fortran gcc command callback should let you set options):
let g:ale_fortran_gcc_options = '-Wotherthings'
- AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -'
+ AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffree-form -Wotherthings -'
Execute(The fortran gcc command callback should let you use -ffixed-form):
let g:ale_fortran_gcc_use_free_form = 0
- AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -'
+ AssertLinter 'gcc', ale#Escape('gcc') . ' -S -x f95 -fsyntax-only -ffixed-form -Wall -'
Execute(The fortran executable should be configurable):
let g:ale_fortran_gcc_executable = 'gfortran'
AssertLinter 'gfortran',
- \ 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -'
+ \ ale#Escape('gfortran') . ' -S -x f95 -fsyntax-only -ffree-form -Wall -'
diff --git a/test/command_callback/test_haskell_hie_callbacks.vader b/test/command_callback/test_haskell_hie_callbacks.vader
new file mode 100644
index 00000000..5bd2794c
--- /dev/null
+++ b/test/command_callback/test_haskell_hie_callbacks.vader
@@ -0,0 +1,27 @@
+Before:
+ call ale#assert#SetUpLinterTest('haskell', 'hie')
+
+ Save &filetype
+ let &filetype = 'haskell'
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The language string should be correct):
+ AssertLSPLanguage 'haskell'
+
+Execute(The default executable should be correct):
+ AssertLinter 'hie',
+ \ ale#Escape('hie') . ' --lsp'
+
+Execute(The project root should be detected correctly):
+ AssertLSPProject g:dir
+
+ call ale#test#SetFilename('hie_paths/file.hs')
+
+ AssertLSPProject ale#path#Simplify(g:dir . '/hie_paths')
+
+Execute(The executable should be configurable):
+ let g:ale_haskell_hie_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --lsp'
diff --git a/test/command_callback/test_javascript_tsserver_command_callback.vader b/test/command_callback/test_javascript_tsserver_command_callback.vader
new file mode 100644
index 00000000..638dd873
--- /dev/null
+++ b/test/command_callback/test_javascript_tsserver_command_callback.vader
@@ -0,0 +1,8 @@
+Before:
+ call ale#assert#SetUpLinterTest('javascript', 'tsserver')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'tsserver', ale#Escape('tsserver')
diff --git a/test/command_callback/test_luac_command_callback.vader b/test/command_callback/test_luac_command_callback.vader
index 8a2345ec..55f39cba 100644
--- a/test/command_callback/test_luac_command_callback.vader
+++ b/test/command_callback/test_luac_command_callback.vader
@@ -5,9 +5,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertLinter 'luac', ale#Escape('luac') . ' -p - '
+ AssertLinter 'luac', ale#Escape('luac') . ' -p -'
Execute(The luac executable should be configurable):
let g:ale_lua_luac_executable = 'luac.sh'
- AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p - '
+ AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p -'
diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader
index 58d0cdc0..f0ef221c 100644
--- a/test/command_callback/test_luacheck_command_callback.vader
+++ b/test/command_callback/test_luacheck_command_callback.vader
@@ -6,7 +6,7 @@ After:
Execute(The lua luacheck command callback should return the correct default string):
AssertLinter 'luacheck',
- \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -'
+ \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -'
Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename'
@@ -20,4 +20,4 @@ Execute(The luacheck executable should be configurable):
let g:ale_lua_luacheck_executable = 'luacheck.sh'
AssertLinter 'luacheck.sh',
- \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -'
+ \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -'
diff --git a/test/command_callback/test_mercury_mmc_command_callback.vader b/test/command_callback/test_mercury_mmc_command_callback.vader
index 2948e799..ab61fddf 100644
--- a/test/command_callback/test_mercury_mmc_command_callback.vader
+++ b/test/command_callback/test_mercury_mmc_command_callback.vader
@@ -8,18 +8,18 @@ After:
Execute(The default command should be correct):
AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy'
+ \ . ale#Escape('mmc') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy'
Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo'
AssertLinter 'foo',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy'
+ \ . ale#Escape('foo') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy'
Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar'
AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'mmc --errorcheck-only --bar dummy'
+ \ . ale#Escape('mmc') . ' --errorcheck-only --bar dummy'
diff --git a/test/command_callback/test_nasm_nasm_command_callbacks.vader b/test/command_callback/test_nasm_nasm_command_callbacks.vader
index 4e0cf608..0d3e572a 100644
--- a/test/command_callback/test_nasm_nasm_command_callbacks.vader
+++ b/test/command_callback/test_nasm_nasm_command_callbacks.vader
@@ -2,7 +2,7 @@ Before:
call ale#assert#SetUpLinterTest('nasm', 'nasm')
let b:command_tail =
- \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s'
+ \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s'
let b:command_tail_opt =
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s'
diff --git a/test/command_callback/test_phpcs_command_callback.vader b/test/command_callback/test_phpcs_command_callback.vader
new file mode 100644
index 00000000..941a92d6
--- /dev/null
+++ b/test/command_callback/test_phpcs_command_callback.vader
@@ -0,0 +1,29 @@
+Before:
+ call ale#assert#SetUpLinterTest('php', 'phpcs')
+
+After:
+ unlet! g:executable
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The local phpcs executable should be used):
+ call ale#test#SetFilename('../phpcs-test-files/project-with-phpcs/foo/test.php')
+
+ let g:executable = ale#path#Simplify(g:dir . '/../phpcs-test-files/project-with-phpcs/vendor/bin/phpcs')
+
+ AssertLinter g:executable,
+ \ ale#Escape(g:executable) . ' -s --report=emacs --stdin-path=%s'
+
+Execute(use_global should override local executable detection):
+ let g:ale_php_phpcs_use_global = 1
+
+ call ale#test#SetFilename('../phpcs-test-files/project-with-phpcs/foo/test.php')
+
+ AssertLinter 'phpcs',
+ \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s'
+
+Execute(Projects without local executables should use the global one):
+ call ale#test#SetFilename('../phpcs-test-files/project-without-phpcs/foo/test.php')
+
+ AssertLinter 'phpcs',
+ \ ale#Escape('phpcs') . ' -s --report=emacs --stdin-path=%s'
diff --git a/test/command_callback/test_scalac_command_callback.vader b/test/command_callback/test_scalac_command_callback.vader
index 115731b3..ea5ae109 100644
--- a/test/command_callback/test_scalac_command_callback.vader
+++ b/test/command_callback/test_scalac_command_callback.vader
@@ -10,4 +10,4 @@ Execute(The default executable and command should be correct):
Given scala.sbt(An empty SBT file):
Execute(scalac should not be run for sbt files):
- AssertLinter '', ''
+ AssertLinterNotExecuted
diff --git a/test/command_callback/test_swaglint_command_callback.vader b/test/command_callback/test_swaglint_command_callback.vader
index fe8fb722..68fb1406 100644
--- a/test/command_callback/test_swaglint_command_callback.vader
+++ b/test/command_callback/test_swaglint_command_callback.vader
@@ -5,25 +5,25 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The yaml swaglint command callback should return the correct default string):
- AssertLinter 'swaglint', 'swaglint -r compact --stdin'
+ AssertLinter 'swaglint', ale#Escape('swaglint') . ' -r compact --stdin'
Execute(The yaml swaglint command callback should be configurable):
let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint'
AssertLinter '~/.local/bin/swaglint',
- \ '~/.local/bin/swaglint -r compact --stdin'
+ \ ale#Escape('~/.local/bin/swaglint') . ' -r compact --stdin'
Execute(The yaml swaglint command callback should allow a global installation to be used):
let g:ale_yaml_swaglint_executable = '/usr/local/bin/swaglint'
let g:ale_yaml_swaglint_use_global = 1
AssertLinter '/usr/local/bin/swaglint',
- \ '/usr/local/bin/swaglint -r compact --stdin'
+ \ ale#Escape('/usr/local/bin/swaglint') . ' -r compact --stdin'
Execute(The yaml swaglint command callback should allow a local installation to be used):
call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml')
AssertLinter
\ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'),
- \ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint')
+ \ ale#Escape(ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'))
\ . ' -r compact --stdin'
diff --git a/test/command_callback/test_terraform_tflint_command_callback.vader b/test/command_callback/test_terraform_tflint_command_callback.vader
index c32d9bcf..0cef0176 100644
--- a/test/command_callback/test_terraform_tflint_command_callback.vader
+++ b/test/command_callback/test_terraform_tflint_command_callback.vader
@@ -17,3 +17,12 @@ Execute(Overriding options should work):
let g:ale_terraform_tflint_options = '--whatever'
AssertLinter 'fnord', ale#Escape('fnord') . ' --whatever -f json %t'
+
+Execute(Configuration files should be found):
+ call ale#test#SetFilename('../tflint-test-files/foo/bar.tf')
+
+ AssertLinter 'tflint',
+ \ ale#Escape('tflint')
+ \ . ' --config '
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/../tflint-test-files/foo/.tflint.hcl'))
+ \ . ' -f json %t'
diff --git a/test/command_callback/test_typescript_tsserver_command_callback.vader b/test/command_callback/test_typescript_tsserver_command_callback.vader
new file mode 100644
index 00000000..719ac184
--- /dev/null
+++ b/test/command_callback/test_typescript_tsserver_command_callback.vader
@@ -0,0 +1,8 @@
+Before:
+ call ale#assert#SetUpLinterTest('typescript', 'tsserver')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command should be correct):
+ AssertLinter 'tsserver', ale#Escape('tsserver')
diff --git a/test/command_callback/test_yang_lsp_command_callbacks.vader b/test/command_callback/test_yang_lsp_command_callbacks.vader
new file mode 100644
index 00000000..5be7501f
--- /dev/null
+++ b/test/command_callback/test_yang_lsp_command_callbacks.vader
@@ -0,0 +1,12 @@
+Before:
+ call ale#assert#SetUpLinterTest('yang', 'yang_lsp')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The executable should be configurable):
+ AssertLinter 'yang-language-server', ale#Escape('yang-language-server')
+
+ let b:ale_yang_lsp_executable = 'foobar'
+
+ AssertLinter 'foobar', ale#Escape('foobar')
diff --git a/test/fixers/test_hackfmt_fixer_callback.vader b/test/fixers/test_hackfmt_fixer_callback.vader
index ed78fc85..d294c15e 100644
--- a/test/fixers/test_hackfmt_fixer_callback.vader
+++ b/test/fixers/test_hackfmt_fixer_callback.vader
@@ -1,10 +1,10 @@
Before:
- Save g:ale_php_hackfmt_executable
- Save g:ale_php_hackfmt_options
+ Save g:ale_hack_hackfmt_executable
+ Save g:ale_hack_hackfmt_options
" Use an invalid global executable, so we don't match it.
- let g:ale_php_hackfmt_executable = 'xxxinvalid'
- let g:ale_php_hackfmt_options = ''
+ let g:ale_hack_hackfmt_executable = 'xxxinvalid'
+ let g:ale_hack_hackfmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
@@ -14,7 +14,7 @@ After:
call ale#test#RestoreDirectory()
Execute(The hackfmt callback should return the correct default values):
- call ale#test#SetFilename('../hack_files/testfile.php')
+ call ale#test#SetFilename('../hack_files/testfile.hack')
AssertEqual
\ {
@@ -25,8 +25,8 @@ Execute(The hackfmt callback should return the correct default values):
\ ale#fixers#hackfmt#Fix(bufnr(''))
Execute(The hackfmt callback should include custom hackfmt options):
- let g:ale_php_hackfmt_options = "--some-option"
- call ale#test#SetFilename('../hack_files/testfile.php')
+ let g:ale_hack_hackfmt_options = "--some-option"
+ call ale#test#SetFilename('../hack_files/testfile.hack')
AssertEqual
\ {
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader
index 2018c3a6..44245630 100644
--- a/test/fixers/test_prettier_fixer_callback.vader
+++ b/test/fixers/test_prettier_fixer_callback.vader
@@ -222,6 +222,20 @@ Execute(Should set --parser based on filetype, Vue):
\ },
\ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0'])
+Execute(Should set --parser based on filetype, YAML):
+ call ale#test#SetFilename('../prettier-test-files/testfile')
+
+ set filetype=yaml
+
+ AssertEqual
+ \ {
+ \ 'command': 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape(g:ale_javascript_prettier_executable)
+ \ . ' --parser yaml'
+ \ . ' --stdin-filepath %s --stdin',
+ \ },
+ \ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0'])
+
Execute(Should set --parser based on first filetype of multiple filetypes):
call ale#test#SetFilename('../prettier-test-files/testfile')
@@ -235,3 +249,21 @@ Execute(Should set --parser based on first filetype of multiple filetypes):
\ . ' --stdin-filepath %s --stdin',
\ },
\ ale#fixers#prettier#ApplyFixForVersion(bufnr(''), ['1.6.0'])
+
+Execute(The prettier_d post-processor should permit regular JavaScript content):
+ AssertEqual
+ \ [
+ \ 'const x = ''Error: foo''',
+ \ 'const y = 3',
+ \ ],
+ \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
+ \ 'const x = ''Error: foo''',
+ \ 'const y = 3',
+ \ ])
+
+Execute(The prettier_d post-processor should handle error messages correctly):
+ AssertEqual
+ \ [],
+ \ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
+ \ 'SyntaxError: Unexpected token, expected "," (36:28)',
+ \ ])
diff --git a/test/handler/test_clang_handler.vader b/test/handler/test_clang_handler.vader
index 278737a8..cc8eabd0 100644
--- a/test/handler/test_clang_handler.vader
+++ b/test/handler/test_clang_handler.vader
@@ -8,9 +8,20 @@ Execute(clang errors from included files should be parsed correctly):
\ 'type': 'E',
\ 'text': 'expected identifier or ''(''',
\ },
+ \ {
+ \ 'lnum': 3,
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': join([
+ \ 'In file included from <stdin>:3:',
+ \ 'In file included from ./a.h:1:',
+ \ './b.h:1:1: error: expected identifier or ''(''',
+ \ '{{{',
+ \ '^',
+ \ ], "\n"),
+ \ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
- \ 'In file included from test.c:3:',
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ 'In file included from <stdin>:3:',
\ 'In file included from ./a.h:1:',
\ './b.h:1:1: error: expected identifier or ''(''',
\ '{{{',
diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader
index 678d3f42..3daa9e60 100644
--- a/test/handler/test_gcc_handler.vader
+++ b/test/handler/test_gcc_handler.vader
@@ -1,7 +1,7 @@
Execute(The GCC handler should ignore other lines of output):
AssertEqual
\ [],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ 'foo',
\ 'bar',
\ 'baz',
@@ -17,12 +17,24 @@ Execute(GCC errors from included files should be parsed correctly):
\ 'type': 'E',
\ 'text': 'expected identifier or ''('' before ''{'' token',
\ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 2,
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': join([
+ \ 'In file included from <stdin>:3:2:',
+ \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token',
+ \ ' {{{',
+ \ ' ^',
+ \ ], "\n"),
+ \ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
- \ 'In file included from <stdin>:3:0:',
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ 'In file included from <stdin>:3:2:',
\ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token',
\ ' {{{',
\ ' ^',
+ \ 'compilation terminated.',
\ ])
AssertEqual
@@ -34,13 +46,25 @@ Execute(GCC errors from included files should be parsed correctly):
\ 'type': 'E',
\ 'text': 'expected identifier or ''('' before ''{'' token',
\ },
+ \ {
+ \ 'lnum': 5,
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': join([
+ \ 'In file included from a.h:1:0,',
+ \ ' from <stdin>:5:',
+ \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token',
+ \ ' {{{',
+ \ ' ^',
+ \ ], "\n"),
+ \ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ 'In file included from a.h:1:0,',
- \ ' from test.c:3:',
+ \ ' from <stdin>:5:',
\ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token',
\ ' {{{',
\ ' ^',
+ \ 'compilation terminated.',
\ ])
AssertEqual
@@ -59,16 +83,31 @@ Execute(GCC errors from included files should be parsed correctly):
\ 'type': 'E',
\ 'text': 'unknown type name ''other_bad_type''',
\ },
+ \ {
+ \ 'lnum': 3,
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': join([
+ \ 'In file included from a.h:1:0,',
+ \ ' from <stdin>:3:',
+ \ 'b.h:1:1: error: unknown type name ‘bad_type’',
+ \ ' bad_type x;',
+ \ ' ^',
+ \ 'b.h:2:1: error: unknown type name ‘other_bad_type’',
+ \ ' other_bad_type y;',
+ \ ' ^',
+ \ ], "\n"),
+ \ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ 'In file included from a.h:1:0,',
- \ ' from test.c:3:',
+ \ ' from <stdin>:3:',
\ 'b.h:1:1: error: unknown type name ‘bad_type’',
\ ' bad_type x;',
\ ' ^',
\ 'b.h:2:1: error: unknown type name ‘other_bad_type’',
\ ' other_bad_type y;',
\ ' ^',
+ \ 'compilation terminated.',
\ ])
Execute(The GCC handler shouldn't complain about #pragma once for headers):
@@ -76,7 +115,7 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers):
AssertEqual
\ [],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
\ ])
@@ -84,7 +123,7 @@ Execute(The GCC handler shouldn't complain about #pragma once for headers):
AssertEqual
\ [],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
\ ])
@@ -119,7 +158,7 @@ Execute(The GCC handler should handle syntax errors):
\ 'text': 'expected '';'' before ''o'''
\ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:6:12: error: invalid suffix "p" on integer constant',
\ '<stdin>:17:5: error: invalid suffix "n" on integer constant',
\ '<stdin>:4: error: variable or field ''foo'' declared void',
@@ -130,11 +169,27 @@ Execute(The GCC handler should handle syntax errors):
Execute(The GCC handler should handle notes with no previous message):
AssertEqual
\ [],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:1:1: note: x',
\ '<stdin>:1:1: note: x',
\ ])
+Execute(The GCC handler should attach notes to previous messages):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 6,
+ \ 'col': 12,
+ \ 'type': 'E',
+ \ 'text': 'Some error',
+ \ 'detail': "Some error\n<stdin>:1:1: note: x",
+ \ },
+ \ ],
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ '-:6:12: error: Some error',
+ \ '<stdin>:1:1: note: x',
+ \ ])
+
Execute(The GCC handler should interpret - as being the current file):
AssertEqual
\ [
@@ -145,7 +200,7 @@ Execute(The GCC handler should interpret - as being the current file):
\ 'text': 'Some error',
\ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '-:6:12: error: Some error',
\ ])
@@ -159,6 +214,6 @@ Execute(The GCC handler should handle fatal error messages due to missing files)
\ 'text': 'foo.h: No such file or directory'
\ },
\ ],
- \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:3:12: fatal error: foo.h: No such file or directory',
\ ])
diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader
index 444272aa..df187a24 100644
--- a/test/lsp/test_read_lsp_diagnostics.vader
+++ b/test/lsp/test_read_lsp_diagnostics.vader
@@ -18,7 +18,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
\ 'col': 11,
\ 'end_lnum': 5,
\ 'end_col': 16,
- \ 'nr': 'some-error',
+ \ 'code': 'some-error',
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -39,7 +39,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
\ 'col': 4,
\ 'end_lnum': 2,
\ 'end_col': 4,
- \ 'nr': 'some-warning',
+ \ 'code': 'some-warning',
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -60,7 +60,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se
\ 'col': 11,
\ 'end_lnum': 5,
\ 'end_col': 16,
- \ 'nr': 'some-error',
+ \ 'code': 'some-error',
\ }
\ ],
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
@@ -89,6 +89,26 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes)
\ },
\ ]}})
+Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code):
+ AssertEqual [
+ \ {
+ \ 'type': 'E',
+ \ 'text': 'Something went wrong!',
+ \ 'lnum': 3,
+ \ 'col': 11,
+ \ 'end_lnum': 5,
+ \ 'end_col': 16,
+ \ }
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
+ \ {
+ \ 'range': Range(2, 10, 4, 15),
+ \ 'message': 'Something went wrong!',
+ \ 'code': -1,
+ \ },
+ \ ]}})
+
+
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
AssertEqual [
\ {
@@ -126,6 +146,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon
\ {
\ 'type': 'E',
\ 'nr': 2365,
+ \ 'code': '2365',
\ 'text': 'Operator ''''+'''' cannot be applied to types ''''3'''' and ''''{}''''.',
\ 'lnum': 1,
\ 'col': 11,
@@ -142,6 +163,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from t
\ 'lnum': 27,
\ 'col': 3,
\ 'nr': 2515,
+ \ 'code': '2515',
\ 'end_lnum': 27,
\ 'type': 'W',
\ 'end_col': 14,
@@ -157,6 +179,7 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions fro
\ 'lnum': 27,
\ 'col': 3,
\ 'nr': 2515,
+ \ 'code': '2515',
\ 'end_lnum': 27,
\ 'type': 'I',
\ 'end_col': 14,
diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader
deleted file mode 100644
index 70b25070..00000000
--- a/test/test_c_import_paths.vader
+++ /dev/null
@@ -1,254 +0,0 @@
-Before:
- " Make sure the c.vim file is loaded first.
- call ale#c#FindProjectRoot(bufnr(''))
-
- Save g:ale_c_parse_makefile
- Save g:ale_c_gcc_options
- Save g:ale_c_clang_options
- Save g:ale_cpp_gcc_options
- Save g:ale_cpp_clang_options
- Save g:__ale_c_project_filenames
-
- let g:original_project_filenames = g:__ale_c_project_filenames
-
- " Remove the .git/HEAD dir for C import paths for these tests.
- " The tests run inside of a git repo.
- let g:__ale_c_project_filenames = filter(
- \ copy(g:__ale_c_project_filenames),
- \ 'v:val isnot# ''.git/HEAD'''
- \)
-
- call ale#test#SetDirectory('/testplugin/test')
-
- let g:ale_c_parse_makefile = 0
- let g:ale_c_gcc_options = ''
- let g:ale_c_clang_options = ''
- let g:ale_cpp_gcc_options = ''
- let g:ale_cpp_clang_options = ''
-
-After:
- Restore
-
- unlet! g:original_project_filenames
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
-Execute(The C GCC handler should include 'include' directories for projects with a Makefile):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C GCC handler should include 'include' directories for projects with a configure file):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C GCC handler should include root directories for projects with .h files in them):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C GCC handler should include root directories for projects with .hpp files in them):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C Clang handler should include 'include' directories for projects with a Makefile):
- runtime! ale_linters/c/clang.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('clang')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#c#clang#GetCommand(bufnr(''), [])
-
-Execute(The C Clang handler should include 'include' directories for projects with a configure file):
- runtime! ale_linters/c/clang.vim
-
- call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('clang')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#c#clang#GetCommand(bufnr(''), [])
-
-Execute(The C Clang handler should include root directories for projects with .h files in them):
- runtime! ale_linters/c/clang.vim
-
- call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('clang')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#c#clang#GetCommand(bufnr(''), [])
-
-Execute(The C Clang handler should include root directories for projects with .hpp files in them):
- runtime! ale_linters/c/clang.vim
-
- call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c')
-
- AssertEqual
- \ ale#Escape('clang')
- \ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#c#clang#GetCommand(bufnr(''), [])
-
-Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile):
- runtime! ale_linters/cpp/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C++ GCC handler should include 'include' directories for projects with a configure file):
- runtime! ale_linters/cpp/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C++ GCC handler should include root directories for projects with .h files in them):
- runtime! ale_linters/cpp/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C++ GCC handler should include root directories for projects with .hpp files in them):
- runtime! ale_linters/cpp/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('gcc')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
-
-Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile):
- runtime! ale_linters/cpp/clang.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('clang++')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#clang#GetCommand(bufnr(''), [])
-
-Execute(The C++ Clang handler should include 'include' directories for projects with a configure file):
- runtime! ale_linters/cpp/clang.vim
-
- call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('clang++')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#clang#GetCommand(bufnr(''), [])
-
-Execute(The C++ Clang handler should include root directories for projects with .h files in them):
- runtime! ale_linters/cpp/clang.vim
-
- call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('clang++')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#clang#GetCommand(bufnr(''), [])
-
-Execute(The C++ Clang handler should include root directories for projects with .hpp files in them):
- runtime! ale_linters/cpp/clang.vim
-
- call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('clang++')
- \ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
- \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
- \ . ' -'
- \ , ale_linters#cpp#clang#GetCommand(bufnr(''), [])
-
-Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
- runtime! ale_linters/cpp/clangtidy.vim
-
- call ale#test#SetFilename('test_c_projects/json_project/subdir/file.cpp')
-
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s '
- \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/json_project/build'))
- \ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
diff --git a/test/test_elm_executable_detection.vader b/test/test_elm_executable_detection.vader
deleted file mode 100644
index 9146eea6..00000000
--- a/test/test_elm_executable_detection.vader
+++ /dev/null
@@ -1,36 +0,0 @@
-Before:
- call ale#test#SetDirectory('/testplugin/test')
- runtime ale_linters/elm/make.vim
-
-After:
- unlet! g:ale_elm_make_use_global
- unlet! g:ale_elm_make_executable
-
- call ale#test#RestoreDirectory()
-
-Execute(should get valid executable with default params):
- call ale#test#SetFilename('elm-test-files/app/testfile.elm')
-
- AssertEqual
- \ ale#path#Simplify(g:dir . '/elm-test-files/app/node_modules/.bin/elm'),
- \ ale_linters#elm#make#GetExecutable(bufnr(''))
-
-Execute(should get valid executable with 'use_global' params):
- let g:ale_elm_make_use_global = 1
-
- call ale#test#SetFilename('elm-test-files/app/testfile.elm')
-
- AssertEqual
- \ 'elm',
- \ ale_linters#elm#make#GetExecutable(bufnr(''))
-
-Execute(should get valid executable with 'use_global' and 'executable' params):
- let g:ale_elm_make_executable = 'other-elm'
- let g:ale_elm_make_use_global = 1
-
- call ale#test#SetFilename('elm-test-files/app/testfile.elm')
-
- AssertEqual
- \ 'other-elm',
- \ ale_linters#elm#make#GetExecutable(bufnr(''))
-
diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader
index 517d82c0..818659db 100644
--- a/test/test_engine_lsp_response_handling.vader
+++ b/test/test_engine_lsp_response_handling.vader
@@ -63,7 +63,7 @@ Execute(tsserver syntax error responses should be handled correctly):
\ 'vcol': 0,
\ 'nr': 1005,
\ 'type': 'E',
- \ 'text': ''','' expected.',
+ \ 'text': '1005: '','' expected.',
\ 'valid': 1,
\ 'pattern': '',
\ },
@@ -136,7 +136,7 @@ Execute(tsserver semantic error responses should be handled correctly):
\ 'vcol': 0,
\ 'nr': 1005,
\ 'type': 'E',
- \ 'text': 'Some semantic error',
+ \ 'text': '1005: Some semantic error',
\ 'valid': 1,
\ 'pattern': '',
\ },
diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader
index 7f0e3fcb..53f566e9 100644
--- a/test/test_go_to_definition.vader
+++ b/test/test_go_to_definition.vader
@@ -111,7 +111,7 @@ Execute(Other files should be jumped to for definition responses):
AssertEqual
\ [
- \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
+ \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
@@ -136,7 +136,7 @@ Execute(Other files should be jumped to for definition responses in tabs too):
AssertEqual
\ [
- \ 'tabedit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
+ \ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
@@ -206,7 +206,7 @@ Execute(Other files should be jumped to for LSP definition responses):
AssertEqual
\ [
- \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
+ \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
@@ -251,7 +251,7 @@ Execute(Other files should be jumped to in tabs for LSP definition responses):
AssertEqual
\ [
- \ 'tabedit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
+ \ 'tabedit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
@@ -282,7 +282,7 @@ Execute(Definition responses with lists should be handled):
AssertEqual
\ [
- \ 'edit ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
+ \ 'edit +3 ' . fnameescape(ale#path#Simplify(g:dir . '/completion_dummy_file')),
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
diff --git a/test/test_ignoring_linters.vader b/test/test_ignoring_linters.vader
index af31fce3..1ddd30e8 100644
--- a/test/test_ignoring_linters.vader
+++ b/test/test_ignoring_linters.vader
@@ -190,6 +190,7 @@ Execute(Buffer ignore lists should be applied for tsserver):
\ 'lnum': 2,
\ 'col': 14,
\ 'nr': 1005,
+ \ 'code': '1005',
\ 'type': 'E',
\ 'end_col': 15,
\ 'end_lnum': 2,
diff --git a/test/test_phpcs_executable_detection.vader b/test/test_phpcs_executable_detection.vader
deleted file mode 100644
index 020bfac3..00000000
--- a/test/test_phpcs_executable_detection.vader
+++ /dev/null
@@ -1,39 +0,0 @@
-Before:
- Save g:ale_php_phpcs_executable
- Save g:ale_php_phpcs_use_global
-
- let g:ale_php_phpcs_executable = 'phpcs_test'
- let g:ale_php_phpcs_use_global = 0
-
- call ale#test#SetDirectory('/testplugin/test')
-
- runtime ale_linters/php/phpcs.vim
-
-After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
-Execute(project with phpcs should use local by default):
- call ale#test#SetFilename('phpcs-test-files/project-with-phpcs/foo/test.php')
-
- AssertEqual
- \ ale#path#Simplify(g:dir . '/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs'),
- \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
-
-Execute(use-global should override local detection):
- let g:ale_php_phpcs_use_global = 1
-
- call ale#test#SetFilename('phpcs-test-files/project-with-phpcs/foo/test.php')
-
- AssertEqual
- \ 'phpcs_test',
- \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
-
-Execute(project without phpcs should use global):
- call ale#test#SetFilename('phpcs-test-files/project-without-phpcs/foo/test.php')
-
- AssertEqual
- \ 'phpcs_test',
- \ ale_linters#php#phpcs#GetExecutable(bufnr(''))
diff --git a/test/test_tflint_config_detection.vader b/test/test_tflint_config_detection.vader
deleted file mode 100644
index 3500869b..00000000
--- a/test/test_tflint_config_detection.vader
+++ /dev/null
@@ -1,18 +0,0 @@
-Before:
- call ale#test#SetDirectory('/testplugin/test')
- runtime ale_linters/terraform/tflint.vim
-
-After:
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
-Execute(adjacent config file should be found):
- call ale#test#SetFilename('tflint-test-files/foo/bar.tf')
- AssertEqual
- \ (
- \ ale#Escape('tflint')
- \ . ' --config '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/tflint-test-files/foo/.tflint.hcl'))
- \ . ' -f json %t'
- \ ),
- \ ale_linters#terraform#tflint#GetCommand(bufnr(''))