Simplify the code for most linters and tests with closures

This commit is contained in:
w0rp 2018-08-02 23:44:12 +01:00
parent 9ef266d050
commit 217284360d
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
102 changed files with 631 additions and 1232 deletions

View File

@ -4,15 +4,10 @@
call ale#Set('asm_gcc_executable', 'gcc') call ale#Set('asm_gcc_executable', 'gcc')
call ale#Set('asm_gcc_options', '-Wall') 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 function! ale_linters#asm#gcc#GetCommand(buffer) abort
return ale#Escape(ale_linters#asm#gcc#GetExecutable(a:buffer)) return '%e -x assembler -fsyntax-only '
\ . ' -x assembler -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
endfunction endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort function! ale_linters#asm#gcc#Handle(buffer, lines) abort
@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('asm', { call ale#linter#Define('asm', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#asm#gcc#GetExecutable', \ 'executable_callback': ale#VarFunc('asm_gcc_executable'),
\ 'command_callback': 'ale_linters#asm#gcc#GetCommand', \ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
\ 'callback': 'ale_linters#asm#gcc#Handle', \ 'callback': 'ale_linters#asm#gcc#Handle',
\}) \})

View File

@ -1,29 +1,21 @@
" Author: kmarc <korondi.mark@gmail.com> " Author: kmarc <korondi.mark@gmail.com>
" Description: This file adds support for using GNU awk with sripts. " Description: This file adds support for using GNU awk with sripts.
let g:ale_awk_gawk_executable = call ale#Set('awk_gawk_executable', 'gawk')
\ get(g:, 'ale_awk_gawk_executable', 'gawk') call ale#Set('awk_gawk_options', '')
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
function! ale_linters#awk#gawk#GetCommand(buffer) abort function! ale_linters#awk#gawk#GetCommand(buffer) abort
" note the --source 'BEGIN ...' is to prevent " note the --source 'BEGIN ...' is to prevent
" gawk from attempting to execute the body of the script " gawk from attempting to execute the body of the script
" it is linting. " it is linting.
return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer)) return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . " --source 'BEGIN { exit } END { exit 1 }'"
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
\ . ' ' . '-f %t --lint /dev/null' \ . ' -f %t --lint /dev/null'
endfunction endfunction
call ale#linter#Define('awk', { call ale#linter#Define('awk', {
\ 'name': 'gawk', \ 'name': 'gawk',
\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable', \ 'executable_callback': ale#VarFunc('awk_gawk_executable'),
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand', \ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat', \ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
\ 'output_stream': 'both' \ 'output_stream': 'both'

View File

@ -4,17 +4,12 @@
call ale#Set('c_clang_executable', 'clang') call ale#Set('c_clang_executable', 'clang')
call ale#Set('c_clang_options', '-std=c11 -Wall') 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 function! ale_linters#c#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for " -iquote with the directory the file is in makes #include work for
" headers in the same directory. " headers in the same directory.
return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer)) return '%e -S -x c -fsyntax-only'
\ . ' -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags) \ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -' \ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
@ -23,7 +18,7 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'clang', \ 'name': 'clang',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#c#clang#GetExecutable', \ 'executable_callback': ale#VarFunc('c_clang_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#clang#GetCommand'} \ {'callback': 'ale_linters#c#clang#GetCommand'}

View File

@ -9,21 +9,14 @@ function! ale_linters#c#clangd#GetProjectRoot(buffer) abort
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction 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 function! ale_linters#c#clangd#GetCommand(buffer) abort
let l:executable = ale_linters#c#clangd#GetExecutable(a:buffer) return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
let l:options = ale#Var(a:buffer, 'c_clangd_options')
return ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '')
endfunction endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'clangd', \ 'name': 'clangd',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#c#clangd#GetExecutable', \ 'executable_callback': ale#VarFunc('c_clangd_executable'),
\ 'command_callback': 'ale_linters#c#clangd#GetCommand', \ 'command_callback': 'ale_linters#c#clangd#GetCommand',
\ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot', \ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot',
\}) \})

View File

@ -16,10 +16,6 @@ call ale#Set('c_clangtidy_checks', ['*'])
call ale#Set('c_clangtidy_options', '') call ale#Set('c_clangtidy_options', '')
call ale#Set('c_build_dir', '') 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 function! s:GetBuildDirectory(buffer) abort
" Don't include build directory for header files, as compile_commands.json " Don't include build directory for header files, as compile_commands.json
" files don't consider headers to be translation units, and provide no " 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') \ ? 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) : '') \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s' \ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
@ -57,7 +53,7 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'clangtidy', \ 'name': 'clangtidy',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#c#clangtidy#GetExecutable', \ 'executable_callback': ale#VarFunc('c_clangtidy_executable'),
\ 'command_callback': 'ale_linters#c#clangtidy#GetCommand', \ 'command_callback': 'ale_linters#c#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -4,10 +4,6 @@
call ale#Set('c_cppcheck_executable', 'cppcheck') call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style') 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 function! ale_linters#c#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json. " 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 return l:cd_command
\ . ale#Escape(ale_linters#c#cppcheck#GetExecutable(a:buffer)) \ . '%e -q --language=c '
\ . ' -q --language=c '
\ . l:compile_commands_option \ . l:compile_commands_option
\ . ale#Var(a:buffer, 'c_cppcheck_options') \ . ale#Var(a:buffer, 'c_cppcheck_options')
\ . ' %t' \ . ' %t'
@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'cppcheck', \ 'name': 'cppcheck',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'executable_callback': 'ale_linters#c#cppcheck#GetExecutable', \ 'executable_callback': ale#VarFunc('c_cppcheck_executable'),
\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand', \ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\}) \})

View File

@ -9,15 +9,6 @@ function! ale_linters#c#cquery#GetProjectRoot(buffer) abort
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction endfunction
function! ale_linters#c#cquery#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'c_cquery_executable')
endfunction
function! ale_linters#c#cquery#GetCommand(buffer) abort
let l:executable = ale_linters#c#cquery#GetExecutable(a:buffer)
return ale#Escape(l:executable)
endfunction
function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort
return {'cacheDirectory': ale#Var(a:buffer, 'c_cquery_cache_directory')} return {'cacheDirectory': ale#Var(a:buffer, 'c_cquery_cache_directory')}
endfunction endfunction
@ -25,8 +16,8 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'cquery', \ 'name': 'cquery',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#c#cquery#GetExecutable', \ 'executable_callback': ale#VarFunc('c_cquery_executable'),
\ 'command_callback': 'ale_linters#c#cquery#GetCommand', \ 'command': '%e',
\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot', \ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions', \ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions',
\}) \})

View File

@ -6,18 +6,12 @@ call ale#Set('c_flawfinder_options', '')
call ale#Set('c_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6) 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 function! ale_linters#c#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with " Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel')
return ale#Escape(ale_linters#c#flawfinder#GetExecutable(a:buffer)) return '%e -CDQS'
\ . ' -CDQS' \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options'))
\ . ale#Var(a:buffer, 'c_flawfinder_options')
\ . l:minlevel \ . l:minlevel
\ . ' %t' \ . ' %t'
endfunction endfunction
@ -25,7 +19,7 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'flawfinder', \ 'name': 'flawfinder',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#c#flawfinder#GetExecutable', \ 'executable_callback': ale#VarFunc('c_flawfinder_executable'),
\ 'command_callback': 'ale_linters#c#flawfinder#GetCommand', \ 'command_callback': 'ale_linters#c#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\}) \})

View File

@ -4,17 +4,12 @@
call ale#Set('c_gcc_executable', 'gcc') call ale#Set('c_gcc_executable', 'gcc')
call ale#Set('c_gcc_options', '-std=c11 -Wall') 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 function! ale_linters#c#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for " -iquote with the directory the file is in makes #include work for
" headers in the same directory. " headers in the same directory.
return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer)) return '%e -S -x c -fsyntax-only'
\ . ' -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags) \ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -' \ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
@ -23,7 +18,7 @@ endfunction
call ale#linter#Define('c', { call ale#linter#Define('c', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable', \ 'executable_callback': ale#VarFunc('c_gcc_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#gcc#GetCommand'} \ {'callback': 'ale_linters#c#gcc#GetCommand'}

View File

@ -6,17 +6,10 @@
call ale#Set('chef_foodcritic_executable', 'foodcritic') call ale#Set('chef_foodcritic_executable', 'foodcritic')
call ale#Set('chef_foodcritic_options', '') 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 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') let l:options = ale#Var(a:buffer, 'chef_foodcritic_options')
return ale#Escape(l:executable) return '%e' . ale#Pad(escape(l:options, '~')) . ' %s'
\ . (!empty(l:options) ? ' ' . escape(l:options, '~') : '')
\ . ' %s'
endfunction endfunction
function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
@ -41,7 +34,7 @@ endfunction
call ale#linter#Define('chef', { call ale#linter#Define('chef', {
\ 'name': 'foodcritic', \ 'name': 'foodcritic',
\ 'executable_callback': 'ale_linters#chef#foodcritic#GetExecutable', \ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'),
\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand', \ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
\ 'callback': 'ale_linters#chef#foodcritic#Handle', \ 'callback': 'ale_linters#chef#foodcritic#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -4,17 +4,12 @@
call ale#Set('cpp_clang_executable', 'clang++') call ale#Set('cpp_clang_executable', 'clang++')
call ale#Set('cpp_clang_options', '-std=c++14 -Wall') 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 function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for " -iquote with the directory the file is in makes #include work for
" headers in the same directory. " headers in the same directory.
return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer)) return '%e -S -x c++ -fsyntax-only'
\ . ' -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags) \ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -' \ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -'
@ -23,7 +18,7 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clang', \ 'name': 'clang',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_clang_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#clang#GetCommand'}, \ {'callback': 'ale_linters#cpp#clang#GetCommand'},

View File

@ -5,10 +5,6 @@ call ale#Set('cpp_clangcheck_executable', 'clang-check')
call ale#Set('cpp_clangcheck_options', '') call ale#Set('cpp_clangcheck_options', '')
call ale#Set('c_build_dir', '') 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 function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options') 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 " 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 " being generated. These are only added if no build directory can be
" detected. " detected.
return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer)) return '%e -analyze %s'
\ . ' -analyze %s'
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '') \ . (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) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clangcheck', \ 'name': 'clangcheck',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand', \ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -10,10 +10,6 @@ call ale#Set('cpp_clangtidy_checks', ['*'])
call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_options', '')
call ale#Set('c_build_dir', '') 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 function! s:GetBuildDirectory(buffer) abort
" Don't include build directory for header files, as compile_commands.json " Don't include build directory for header files, as compile_commands.json
" files don't consider headers to be translation units, and provide no " 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') \ ? 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) : '') \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s' \ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
@ -51,7 +47,7 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'clangtidy', \ 'name': 'clangtidy',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#cpp#clangtidy#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'),
\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand', \ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -4,10 +4,6 @@
call ale#Set('cpp_cppcheck_executable', 'cppcheck') call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style') 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 function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json. " 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 return l:cd_command
\ . ale#Escape(ale_linters#cpp#cppcheck#GetExecutable(a:buffer)) \ . '%e -q --language=c++ '
\ . ' -q --language=c++ '
\ . l:compile_commands_option \ . l:compile_commands_option
\ . ale#Var(a:buffer, 'cpp_cppcheck_options') \ . ale#Var(a:buffer, 'cpp_cppcheck_options')
\ . ' %t' \ . ' %t'
@ -33,7 +28,7 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cppcheck', \ 'name': 'cppcheck',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'executable_callback': 'ale_linters#cpp#cppcheck#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand', \ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\}) \})

View File

@ -4,22 +4,16 @@
call ale#Set('cpp_cpplint_executable', 'cpplint') call ale#Set('cpp_cpplint_executable', 'cpplint')
call ale#Set('cpp_cpplint_options', '') 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 function! ale_linters#cpp#cpplint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'cpp_cpplint_options') let l:options = ale#Var(a:buffer, 'cpp_cpplint_options')
return ale#Escape(ale_linters#cpp#cpplint#GetExecutable(a:buffer)) return '%e' . ale#Pad(l:options) . ' %s'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %s'
endfunction endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cpplint', \ 'name': 'cpplint',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#cpp#cpplint#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'),
\ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand', \ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', \ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -10,15 +10,6 @@ function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction endfunction
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)
endfunction
function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort
return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')} return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')}
endfunction endfunction
@ -26,8 +17,8 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'cquery', \ 'name': 'cquery',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#cpp#cquery#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_cquery_executable'),
\ 'command_callback': 'ale_linters#cpp#cquery#GetCommand', \ 'command': '%e',
\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot', \ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions', \ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions',
\}) \})

View File

@ -6,17 +6,11 @@ call ale#Set('cpp_flawfinder_options', '')
call ale#Set('cpp_flawfinder_minlevel', 1) call ale#Set('cpp_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6) 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 function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with " Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel')
return ale#Escape(ale_linters#cpp#flawfinder#GetExecutable(a:buffer)) return '%e -CDQS'
\ . ' -CDQS'
\ . ale#Var(a:buffer, 'cpp_flawfinder_options') \ . ale#Var(a:buffer, 'cpp_flawfinder_options')
\ . l:minlevel \ . l:minlevel
\ . ' %t' \ . ' %t'
@ -25,7 +19,7 @@ endfunction
call ale#linter#Define('cpp', { call ale#linter#Define('cpp', {
\ 'name': 'flawfinder', \ 'name': 'flawfinder',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#cpp#flawfinder#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'),
\ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand', \ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\}) \})

View File

@ -4,17 +4,12 @@
call ale#Set('cpp_gcc_executable', 'gcc') call ale#Set('cpp_gcc_executable', 'gcc')
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall') 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 function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output) let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for " -iquote with the directory the file is in makes #include work for
" headers in the same directory. " headers in the same directory.
return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer)) return '%e -S -x c++ -fsyntax-only'
\ . ' -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags) \ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -' \ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
@ -24,7 +19,7 @@ call ale#linter#Define('cpp', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'aliases': ['g++'], \ 'aliases': ['g++'],
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable', \ 'executable_callback': ale#VarFunc('cpp_gcc_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#gcc#GetCommand'}, \ {'callback': 'ale_linters#cpp#gcc#GetCommand'},

View File

@ -4,21 +4,16 @@ call ale#Set('css_stylelint_executable', 'stylelint')
call ale#Set('css_stylelint_options', '') call ale#Set('css_stylelint_options', '')
call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#css#stylelint#GetCommand(buffer) abort
return ale_linters#css#stylelint#GetExecutable(a:buffer) return '%e ' . ale#Pad(ale#Var(a:buffer, 'css_stylelint_options'))
\ . ' ' . ale#Var(a:buffer, 'css_stylelint_options')
\ . ' --stdin-filename %s' \ . ' --stdin-filename %s'
endfunction endfunction
call ale#linter#Define('css', { call ale#linter#Define('css', {
\ 'name': 'stylelint', \ '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', \ 'command_callback': 'ale_linters#css#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@ -4,20 +4,15 @@
call ale#Set('cuda_nvcc_executable', 'nvcc') call ale#Set('cuda_nvcc_executable', 'nvcc')
call ale#Set('cuda_nvcc_options', '-std=c++11') 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 function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
" Unused: use ale#util#nul_file " Unused: use ale#util#nul_file
" let l:output_file = ale#util#Tempname() . '.ii' " let l:output_file = ale#util#Tempname() . '.ii'
" call ale#engine#ManageFile(a:buffer, l:output_file) " call ale#engine#ManageFile(a:buffer, l:output_file)
return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer)) return '%e -cuda'
\ . ' -cuda ' \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
\ . ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options'))
\ . ale#Var(a:buffer, 'cuda_nvcc_options') . ' %s' \ . ' %s -o ' . g:ale#util#nul_file
\ . ' -o ' . g:ale#util#nul_file
endfunction endfunction
function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
@ -49,7 +44,7 @@ endfunction
call ale#linter#Define('cuda', { call ale#linter#Define('cuda', {
\ 'name': 'nvcc', \ 'name': 'nvcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#cuda#nvcc#GetExecutable', \ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'),
\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand', \ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat', \ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -3,15 +3,10 @@
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer') 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 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') let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
return ale#Escape(l:executable) return '%e'
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '') \ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
\ . ' %s' \ . ' %s'
endfunction endfunction
@ -34,7 +29,7 @@ endfunction
call ale#linter#Define('dart', { call ale#linter#Define('dart', {
\ 'name': 'dartanalyzer', \ 'name': 'dartanalyzer',
\ 'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable', \ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'),
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand', \ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle', \ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -3,10 +3,6 @@
call ale#Set('dart_language_server_executable', 'dart_language_server') 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 function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort
" Note: pub only looks for pubspec.yaml, there's no point in adding " Note: pub only looks for pubspec.yaml, there's no point in adding
" support for pubspec.yml " support for pubspec.yml
@ -18,7 +14,7 @@ endfunction
call ale#linter#Define('dart', { call ale#linter#Define('dart', {
\ 'name': 'language_server', \ 'name': 'language_server',
\ 'lsp': 'stdio', \ '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', \ 'command_callback': 'ale_linters#dart#language_server#GetExecutable',
\ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot', \ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot',
\}) \})

View File

@ -4,12 +4,6 @@
call ale#Set('elm_make_executable', 'elm') call ale#Set('elm_make_executable', 'elm')
call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#elm#make#Handle(buffer, lines) abort
let l:output = [] let l:output = []
let l:unparsed_lines = [] let l:unparsed_lines = []
@ -147,7 +141,6 @@ endfunction
" If it doesn't, then this will fail when imports are needed. " If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') 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) if empty(l:elm_json)
" Fallback to Elm 0.18 " 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, " a sort of flag to tell the compiler not to generate an output file,
" which is why this is hard coded here. " which is why this is hard coded here.
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 " 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) return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t'
\ . ' make'
\ . ' --report=json'
\ . ' --output=/dev/null'
return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t'
endfunction endfunction
call ale#linter#Define('elm', { call ale#linter#Define('elm', {
\ 'name': 'make', \ 'name': 'make',
\ 'executable_callback': 'ale_linters#elm#make#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [
\ 'output_stream': 'both', \ 'node_modules/.bin/elm',
\ 'command_callback': 'ale_linters#elm#make#GetCommand', \ ]),
\ 'callback': 'ale_linters#elm#make#Handle' \ 'output_stream': 'both',
\ 'command_callback': 'ale_linters#elm#make#GetCommand',
\ 'callback': 'ale_linters#elm#make#Handle'
\}) \})

View File

@ -3,24 +3,12 @@
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') 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 function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1 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 endfunction
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
let l:pattern = '\v\C:(\d+):( warning:)? (.+)' let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
let l:loclist = [] let l:loclist = []
@ -36,17 +24,11 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
return l:loclist return l:loclist
endfunction endfunction
function! s:GetEscapedExecutable(buffer) abort
return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer))
endfunction
call ale#linter#Define('erlang', { call ale#linter#Define('erlang', {
\ 'name': 'syntaxerl', \ 'name': 'syntaxerl',
\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable', \ 'executable_callback': ale#VarFunc('erlang_syntaxerl_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'}, \ {'callback': {-> '%e -h'}},
\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'}, \ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
\ ], \ ],
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle', \ 'callback': 'ale_linters#erlang#syntaxerl#Handle',

View File

@ -2,18 +2,10 @@
" Description: gcc for Fortran files " Description: gcc for Fortran files
" This option can be set to 0 to use -ffixed-form " This option can be set to 0 to use -ffixed-form
if !exists('g:ale_fortran_gcc_use_free_form') call ale#Set('fortran_gcc_use_free_form', 1)
let g:ale_fortran_gcc_use_free_form = 1 call ale#Set('fortran_gcc_executable', 'gcc')
endif
if !exists('g:ale_fortran_gcc_executable')
let g:ale_fortran_gcc_executable = 'gcc'
endif
" Set this option to change the GCC options for warnings for Fortran. " Set this option to change the GCC options for warnings for Fortran.
if !exists('g:ale_fortran_gcc_options') call ale#Set('fortran_gcc_options', '-Wall')
let g:ale_fortran_gcc_options = '-Wall'
endif
function! ale_linters#fortran#gcc#Handle(buffer, lines) abort function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
" We have to match a starting line and a later ending line together, " 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 return l:output
endfunction 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 function! ale_linters#fortran#gcc#GetCommand(buffer) abort
let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form') let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form')
\ ? '-ffree-form' \ ? '-ffree-form'
\ : '-ffixed-form' \ : '-ffixed-form'
return ale_linters#fortran#gcc#GetExecutable(a:buffer) return '%e -S -x f95 -fsyntax-only ' . l:layout_option
\ . ' -S -x f95 -fsyntax-only ' \ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options'))
\ . l:layout_option . ' ' \ . ' -'
\ . ale#Var(a:buffer, 'fortran_gcc_options') . ' '
\ . '-'
endfunction endfunction
call ale#linter#Define('fortran', { call ale#linter#Define('fortran', {
\ 'name': 'gcc', \ 'name': 'gcc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#fortran#gcc#GetExecutable', \ 'executable_callback': ale#VarFunc('fortran_gcc_executable'),
\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand', \ 'command_callback': 'ale_linters#fortran#gcc#GetCommand',
\ 'callback': 'ale_linters#fortran#gcc#Handle', \ 'callback': 'ale_linters#fortran#gcc#Handle',
\}) \})

View File

@ -4,14 +4,6 @@
call ale#Set('fortran_language_server_executable', 'fortls') call ale#Set('fortran_language_server_executable', 'fortls')
call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort
let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls') let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls')
@ -21,7 +13,7 @@ endfunction
call ale#linter#Define('fortran', { call ale#linter#Define('fortran', {
\ 'name': 'language_server', \ 'name': 'language_server',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#fortran#language_server#GetExecutable', \ 'executable_callback': ale#VarFunc('fortran_language_server_executable'),
\ 'command_callback': 'ale_linters#fortran#language_server#GetCommand', \ 'command': '%e',
\ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot', \ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot',
\}) \})

View File

@ -4,13 +4,8 @@
call ale#Set('fuse_fusionlint_executable', 'fusion-lint') call ale#Set('fuse_fusionlint_executable', 'fusion-lint')
call ale#Set('fuse_fusionlint_options', '') 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 function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort
return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer)) return '%e' . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
\ . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
\ . ' --filename %s -i' \ . ' --filename %s -i'
endfunction endfunction
@ -32,7 +27,7 @@ endfunction
call ale#linter#Define('fuse', { call ale#linter#Define('fuse', {
\ 'name': 'fusionlint', \ 'name': 'fusionlint',
\ 'executable_callback': 'ale_linters#fuse#fusionlint#GetExecutable', \ 'executable_callback': ale#VarFunc('fuse_fusionlint_executable'),
\ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand', \ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand',
\ 'callback': 'ale_linters#fuse#fusionlint#Handle', \ 'callback': 'ale_linters#fuse#fusionlint#Handle',
\}) \})

View File

@ -1,11 +1,9 @@
" Author: Nick Yamane <nick.diego@gmail.com> " Author: Nick Yamane <nick.diego@gmail.com>
" Description: gitlint for git commit message files " Description: gitlint for git commit message files
let g:ale_gitcommit_gitlint_executable = call ale#Set('gitcommit_gitlint_executable', 'gitlint')
\ get(g:, 'ale_gitcommit_gitlint_executable', 'gitlint') call ale#Set('gitcommit_gitlint_options', '')
let g:ale_gitcommit_gitlint_options = get(g:, 'ale_gitcommit_gitlint_options', '') call ale#Set('gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint']) return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint'])
@ -13,12 +11,9 @@ endfunction
function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options') 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 function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
" Matches patterns line the following: " Matches patterns line the following:
@ -45,7 +40,6 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
return l:output return l:output
endfunction endfunction
call ale#linter#Define('gitcommit', { call ale#linter#Define('gitcommit', {
\ 'name': 'gitlint', \ 'name': 'gitlint',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
@ -53,4 +47,3 @@ call ale#linter#Define('gitcommit', {
\ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand', \ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand',
\ 'callback': 'ale_linters#gitcommit#gitlint#Handle', \ 'callback': 'ale_linters#gitcommit#gitlint#Handle',
\}) \})

View File

@ -4,17 +4,11 @@
" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted, " TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
" we can use stdin. " we can use stdin.
let g:ale_glsl_glslang_executable = call ale#Set('glsl_glslang_executable', 'glslangValidator')
\ get(g:, 'ale_glsl_glslang_executable', 'glslangValidator') call ale#Set('glsl_glslang_options', '')
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
function! ale_linters#glsl#glslang#GetCommand(buffer) abort 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')) \ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
\ . ' -C %t' \ . ' -C %t'
endfunction endfunction
@ -40,7 +34,7 @@ endfunction
call ale#linter#Define('glsl', { call ale#linter#Define('glsl', {
\ 'name': 'glslang', \ 'name': 'glslang',
\ 'executable_callback': 'ale_linters#glsl#glslang#GetExecutable', \ 'executable_callback': ale#VarFunc('glsl_glslang_executable'),
\ 'command_callback': 'ale_linters#glsl#glslang#GetCommand', \ 'command_callback': 'ale_linters#glsl#glslang#GetCommand',
\ 'callback': 'ale_linters#glsl#glslang#Handle', \ 'callback': 'ale_linters#glsl#glslang#Handle',
\}) \})

View File

@ -4,18 +4,15 @@
call ale#Set('glsl_glslls_executable', 'glslls') call ale#Set('glsl_glslls_executable', 'glslls')
call ale#Set('glsl_glslls_logfile', '') 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 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 = ale#Var(a:buffer, 'glsl_glslls_logfile')
let l:logfile_args = '' let l:logfile_args = ''
if l:logfile isnot# '' if l:logfile isnot# ''
let l:logfile_args = ' --verbose -l ' . l:logfile let l:logfile_args = ' --verbose -l ' . l:logfile
endif endif
return ale#Escape(l:executable) . l:logfile_args . ' --stdin'
return '%e' . l:logfile_args . ' --stdin'
endfunction endfunction
function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort
@ -27,7 +24,7 @@ endfunction
call ale#linter#Define('glsl', { call ale#linter#Define('glsl', {
\ 'name': 'glslls', \ 'name': 'glslls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable', \ 'executable_callback': ale#VarFunc('glsl_glslls_executable'),
\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand', \ 'command_callback': 'ale_linters#glsl#glslls#GetCommand',
\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot', \ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot',
\}) \})

View File

@ -5,12 +5,7 @@ call ale#Set('go_gometalinter_options', '')
call ale#Set('go_gometalinter_executable', 'gometalinter') call ale#Set('go_gometalinter_executable', 'gometalinter')
call ale#Set('go_gometalinter_lint_package', 0) 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 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:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_gometalinter_options') let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package') 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 " be calculated to absolute paths in the Handler
if l:lint_package if l:lint_package
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale#Escape(l:executable) \ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif endif
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale#Escape(l:executable) \ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename)) \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endfunction endfunction
@ -55,7 +50,7 @@ endfunction
call ale#linter#Define('go', { call ale#linter#Define('go', {
\ 'name': 'gometalinter', \ 'name': 'gometalinter',
\ 'executable_callback': 'ale_linters#go#gometalinter#GetExecutable', \ 'executable_callback': ale#VarFunc('go_gometalinter_executable'),
\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand', \ 'command_callback': 'ale_linters#go#gometalinter#GetCommand',
\ 'callback': 'ale_linters#go#gometalinter#Handler', \ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -4,17 +4,6 @@
call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
let l:output = [] let l:output = []
let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
@ -42,7 +31,9 @@ endfunction
call ale#linter#Define('handlebars', { call ale#linter#Define('handlebars', {
\ 'name': 'ember-template-lint', \ 'name': 'ember-template-lint',
\ 'executable_callback': 'ale_linters#handlebars#embertemplatelint#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('handlebars_embertemplatelint', [
\ 'command_callback': 'ale_linters#handlebars#embertemplatelint#GetCommand', \ 'node_modules/.bin/ember-template-lint',
\ ]),
\ 'command': '%e --json %t',
\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', \ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle',
\}) \})

View File

@ -4,19 +4,14 @@
call ale#Set('haskell_hdevtools_executable', 'hdevtools') call ale#Set('haskell_hdevtools_executable', 'hdevtools')
call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall')) 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 function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort
return ale#Escape(ale_linters#haskell#hdevtools#GetExecutable(a:buffer)) return '%e check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options'))
\ . ' check ' . ale#Var(a:buffer, 'haskell_hdevtools_options') \ . ' -p %s %t'
\ . ' -p %s %t'
endfunction endfunction
call ale#linter#Define('haskell', { call ale#linter#Define('haskell', {
\ 'name': 'hdevtools', \ 'name': 'hdevtools',
\ 'executable_callback': 'ale_linters#haskell#hdevtools#GetExecutable', \ 'executable_callback': ale#VarFunc('haskell_hdevtools_executable'),
\ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand', \ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand',
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
\}) \})

View File

@ -5,12 +5,6 @@ call ale#Set('html_htmlhint_options', '')
call ale#Set('html_htmlhint_executable', 'htmlhint') call ale#Set('html_htmlhint_executable', 'htmlhint')
call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#html#htmlhint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'html_htmlhint_options') let l:options = ale#Var(a:buffer, 'html_htmlhint_options')
let l:config = l:options !~# '--config' 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', '', '') let l:options = substitute(l:options, '--format=unix', '', '')
endif endif
return ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer)) return '%e' . ale#Pad(l:options) . ' --format=unix %t'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --format=unix %t'
endfunction endfunction
call ale#linter#Define('html', { call ale#linter#Define('html', {
\ 'name': 'htmlhint', \ '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', \ 'command_callback': 'ale_linters#html#htmlhint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError', \ 'callback': 'ale#handlers#unix#HandleAsError',
\}) \})

View File

@ -37,10 +37,6 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort
\) \)
endfunction 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 function! ale_linters#html#tidy#Handle(buffer, lines) abort
" Matches patterns lines like the following: " Matches patterns lines like the following:
" line 7 column 5 - Warning: missing </title> before </head> " line 7 column 5 - Warning: missing </title> before </head>
@ -67,7 +63,7 @@ endfunction
call ale#linter#Define('html', { call ale#linter#Define('html', {
\ 'name': 'tidy', \ 'name': 'tidy',
\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable', \ 'executable_callback': ale#VarFunc('html_tidy_executable'),
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#html#tidy#GetCommand', \ 'command_callback': 'ale_linters#html#tidy#GetCommand',
\ 'callback': 'ale_linters#html#tidy#Handle', \ 'callback': 'ale_linters#html#tidy#Handle',

View File

@ -4,16 +4,10 @@
call ale#Set('idris_idris_executable', 'idris') call ale#Set('idris_idris_executable', 'idris')
call ale#Set('idris_idris_options', '--total --warnpartial --warnreach --warnipkg') 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 function! ale_linters#idris#idris#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'idris_idris_options') let l:options = ale#Var(a:buffer, 'idris_idris_options')
return ale#Escape(ale_linters#idris#idris#GetExecutable(a:buffer)) return '%e' . ale#Pad(l:options) . ' --check %s'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --check %s'
endfunction endfunction
function! ale_linters#idris#idris#Handle(buffer, lines) abort function! ale_linters#idris#idris#Handle(buffer, lines) abort
@ -80,8 +74,7 @@ endfunction
call ale#linter#Define('idris', { call ale#linter#Define('idris', {
\ 'name': 'idris', \ 'name': 'idris',
\ 'executable_callback': 'ale_linters#idris#idris#GetExecutable', \ 'executable_callback': ale#VarFunc('idris_idris_executable'),
\ 'command_callback': 'ale_linters#idris#idris#GetCommand', \ 'command_callback': 'ale_linters#idris#idris#GetCommand',
\ 'callback': 'ale_linters#idris#idris#Handle', \ 'callback': 'ale_linters#idris#idris#Handle',
\}) \})

View File

@ -36,10 +36,6 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : '' \ : ''
endfunction 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 function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths) let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
let l:sp_option = '' 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. " Create .class files in a temporary directory, which we will delete later.
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer) 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 " Always run javac from the directory the file is in, so we can resolve
" relative paths correctly. " relative paths correctly.
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale#Escape(l:executable) \ . '%e -Xlint'
\ . ' -Xlint'
\ . ale#Pad(l:cp_option) \ . ale#Pad(l:cp_option)
\ . ale#Pad(l:sp_option) \ . ale#Pad(l:sp_option)
\ . ' -d ' . ale#Escape(l:class_file_directory) \ . ' -d ' . ale#Escape(l:class_file_directory)
@ -126,7 +120,7 @@ endfunction
call ale#linter#Define('java', { call ale#linter#Define('java', {
\ 'name': 'javac', \ 'name': 'javac',
\ 'executable_callback': 'ale_linters#java#javac#GetExecutable', \ 'executable_callback': ale#VarFunc('java_javac_executable'),
\ 'command_chain': [ \ 'command_chain': [
\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'}, \ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},

View File

@ -6,18 +6,6 @@ call ale#Set('javascript_flow_ls_use_global',
\ get(g:, 'ale_use_global_executables', 0) \ 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 function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort
let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig')
@ -31,8 +19,10 @@ endfunction
call ale#linter#Define('javascript', { call ale#linter#Define('javascript', {
\ 'name': 'flow-language-server', \ 'name': 'flow-language-server',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#javascript#flow_ls#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('javascript_flow_ls', [
\ 'command_callback': 'ale_linters#javascript#flow_ls#GetCommand', \ 'node_modules/.bin/flow',
\ ]),
\ 'command': '%e lsp --from ale-lsp',
\ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot', \ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot',
\ 'language': 'javascript', \ 'language': 'javascript',
\}) \})

View File

@ -4,12 +4,6 @@
call ale#Set('javascript_jscs_executable', 'jscs') call ale#Set('javascript_jscs_executable', 'jscs')
call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#javascript#jscs#GetCommand(buffer) abort
" Search for a local JShint config locaation, and default to a global one. " Search for a local JShint config locaation, and default to a global one.
let l:jscs_config = ale#path#ResolveLocalPath( 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', '') \ get(g:, 'ale_jscs_config_loc', '')
\) \)
let l:command = ale#Escape(ale_linters#javascript#jscs#GetExecutable(a:buffer)) let l:command = '%e --reporter inline --no-colors'
let l:command .= ' --reporter inline --no-colors'
if !empty(l:jscs_config) if !empty(l:jscs_config)
let l:command .= ' --config ' . ale#Escape(l:jscs_config) let l:command .= ' --config ' . ale#Escape(l:jscs_config)
@ -60,8 +53,9 @@ endfunction
call ale#linter#Define('javascript', { call ale#linter#Define('javascript', {
\ 'name': 'jscs', \ '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', \ 'command_callback': 'ale_linters#javascript#jscs#GetCommand',
\ 'callback': 'ale_linters#javascript#jscs#Handle', \ 'callback': 'ale_linters#javascript#jscs#Handle',
\}) \})

View File

@ -4,12 +4,6 @@
call ale#Set('javascript_jshint_executable', 'jshint') call ale#Set('javascript_jshint_executable', 'jshint')
call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#javascript#jshint#GetCommand(buffer) abort
" Search for a local JShint config locaation, and default to a global one. " Search for a local JShint config locaation, and default to a global one.
let l:jshint_config = ale#path#ResolveLocalPath( 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', '') \ get(g:, 'ale_jshint_config_loc', '')
\) \)
let l:command = ale#Escape(ale_linters#javascript#jshint#GetExecutable(a:buffer)) let l:command = '%e --reporter unix --extract auto'
let l:command .= ' --reporter unix --extract auto'
if !empty(l:jshint_config) if !empty(l:jshint_config)
let l:command .= ' --config ' . ale#Escape(l:jshint_config) let l:command .= ' --config ' . ale#Escape(l:jshint_config)
@ -32,7 +25,9 @@ endfunction
call ale#linter#Define('javascript', { call ale#linter#Define('javascript', {
\ 'name': 'jshint', \ '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', \ 'command_callback': 'ale_linters#javascript#jshint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError', \ 'callback': 'ale#handlers#unix#HandleAsError',
\}) \})

View File

@ -3,15 +3,6 @@
call ale#Set('kotlin_languageserver_executable', 'kotlin-language-server') 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 function! ale_linters#kotlin#languageserver#GetProjectRoot(buffer) abort
let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer)
@ -31,8 +22,8 @@ endfunction
call ale#linter#Define('kotlin', { call ale#linter#Define('kotlin', {
\ 'name': 'languageserver', \ 'name': 'languageserver',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#kotlin#languageserver#GetExecutable', \ 'executable_callback': ale#VarFunc('kotlin_languageserver_executable'),
\ 'command_callback': 'ale_linters#kotlin#languageserver#GetCommand', \ 'command_callback': '%e',
\ 'language': 'kotlin', \ 'language': 'kotlin',
\ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot', \ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot',
\}) \})

View File

@ -5,21 +5,10 @@ call ale#Set('less_lessc_executable', 'lessc')
call ale#Set('less_lessc_options', '') call ale#Set('less_lessc_options', '')
call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#less#lessc#GetCommand(buffer) abort
let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer) return '%e --no-color --lint'
let l:dir = expand('#' . a:buffer . ':p:h') \ . ' --include-path=' . ale#Escape(expand('#' . a:buffer . ':p:h'))
let l:options = ale#Var(a:buffer, 'less_lessc_options') \ . ale#Pad(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 : '')
\ . ' -' \ . ' -'
endfunction endfunction
@ -49,7 +38,9 @@ endfunction
call ale#linter#Define('less', { call ale#linter#Define('less', {
\ 'name': 'lessc', \ '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', \ 'command_callback': 'ale_linters#less#lessc#GetCommand',
\ 'callback': 'ale_linters#less#lessc#Handle', \ 'callback': 'ale_linters#less#lessc#Handle',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',

View File

@ -4,24 +4,17 @@ call ale#Set('less_stylelint_executable', 'stylelint')
call ale#Set('less_stylelint_options', '') call ale#Set('less_stylelint_options', '')
call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 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') let l:options = ale#Var(a:buffer, 'less_stylelint_options')
return ale#Escape(l:executable) return '%e' . ale#Pad(l:options) . ' --stdin-filename %s'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --stdin-filename %s'
endfunction endfunction
call ale#linter#Define('less', { call ale#linter#Define('less', {
\ 'name': 'stylelint', \ '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', \ 'command_callback': 'ale_linters#less#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@ -3,21 +3,11 @@
call ale#Set('llvm_llc_executable', 'llc') 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 function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort
" Handle '{path}: {file}:{line}:{col}: error: {message}' format " Handle '{path}: {file}:{line}:{col}: error: {message}' format
let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$' 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]), \ 'lnum': str2nr(v:val[1]),
\ 'col': str2nr(v:val[2]), \ 'col': str2nr(v:val[2]),
\ 'text': v:val[3], \ 'text': v:val[3],
@ -27,8 +17,8 @@ endfunction
call ale#linter#Define('llvm', { call ale#linter#Define('llvm', {
\ 'name': 'llc', \ 'name': 'llc',
\ 'executable_callback': 'ale_linters#llvm#llc#GetExecutable', \ 'executable_callback': ale#VarFunc('llvm_llc_executable'),
\ 'output_stream': 'stderr', \ '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', \ 'callback': 'ale_linters#llvm#llc#HandleErrors',
\}) \})

View File

@ -3,15 +3,6 @@
call ale#Set('lua_luac_executable', 'luac') 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 function! ale_linters#lua#luac#Handle(buffer, lines) abort
" Matches patterns line the following: " Matches patterns line the following:
" "
@ -33,8 +24,8 @@ endfunction
call ale#linter#Define('lua', { call ale#linter#Define('lua', {
\ 'name': 'luac', \ 'name': 'luac',
\ 'executable_callback': 'ale_linters#lua#luac#GetExecutable', \ 'executable_callback': ale#VarFunc('lua_luac_executable'),
\ 'command_callback': 'ale_linters#lua#luac#GetCommand', \ 'command': '%e -p -',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#lua#luac#Handle', \ 'callback': 'ale_linters#lua#luac#Handle',
\}) \})

View File

@ -1,19 +1,11 @@
" Author: Sol Bekic https://github.com/s-ol " Author: Sol Bekic https://github.com/s-ol
" Description: luacheck linter for lua files " Description: luacheck linter for lua files
let g:ale_lua_luacheck_executable = call ale#Set('lua_luacheck_executable', 'luacheck')
\ get(g:, 'ale_lua_luacheck_executable', 'luacheck') call ale#Set('lua_luacheck_options', '')
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
function! ale_linters#lua#luacheck#GetCommand(buffer) abort function! ale_linters#lua#luacheck#GetCommand(buffer) abort
return ale#Escape(ale_linters#lua#luacheck#GetExecutable(a:buffer)) return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_luacheck_options'))
\ . ' ' . ale#Var(a:buffer, 'lua_luacheck_options')
\ . ' --formatter plain --codes --filename %s -' \ . ' --formatter plain --codes --filename %s -'
endfunction endfunction
@ -46,7 +38,7 @@ endfunction
call ale#linter#Define('lua', { call ale#linter#Define('lua', {
\ 'name': 'luacheck', \ 'name': 'luacheck',
\ 'executable_callback': 'ale_linters#lua#luacheck#GetExecutable', \ 'executable_callback': ale#VarFunc('lua_luacheck_executable'),
\ 'command_callback': 'ale_linters#lua#luacheck#GetCommand', \ 'command_callback': 'ale_linters#lua#luacheck#GetCommand',
\ 'callback': 'ale_linters#lua#luacheck#Handle', \ 'callback': 'ale_linters#lua#luacheck#Handle',
\}) \})

View File

@ -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_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('markdown_remark_lint_options', '') 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 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') let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options')
return ale#node#Executable(a:buffer, l:executable) return '%e' . ale#Pad(l:options) . ' --no-stdout --no-color'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --no-stdout --no-color'
endfunction endfunction
function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort
@ -46,7 +37,9 @@ endfunction
call ale#linter#Define('markdown', { call ale#linter#Define('markdown', {
\ 'name': 'remark_lint', \ 'name': 'remark_lint',
\ 'aliases': ['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', \ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand',
\ 'callback': 'ale_linters#markdown#remark_lint#Handle', \ 'callback': 'ale_linters#markdown#remark_lint#Handle',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',

View File

@ -1,18 +1,7 @@
" Author: awlayton <alex@layton.in> " Author: awlayton <alex@layton.in>
" Description: mlint for MATLAB files " Description: mlint for MATLAB files
let g:ale_matlab_mlint_executable = call ale#Set('matlab_mlint_executable', 'mlint')
\ 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
function! ale_linters#matlab#mlint#Handle(buffer, lines) abort function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
" Matches patterns like the following: " Matches patterns like the following:
@ -48,8 +37,8 @@ endfunction
call ale#linter#Define('matlab', { call ale#linter#Define('matlab', {
\ 'name': 'mlint', \ 'name': 'mlint',
\ 'executable_callback': 'ale_linters#matlab#mlint#GetExecutable', \ 'executable_callback': ale#VarFunc('matlab_mlint_executable'),
\ 'command_callback': 'ale_linters#matlab#mlint#GetCommand', \ 'command': '%e -id %t',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#matlab#mlint#Handle', \ 'callback': 'ale_linters#matlab#mlint#Handle',
\}) \})

View File

@ -4,16 +4,11 @@
call ale#Set('mercury_mmc_executable', 'mmc') call ale#Set('mercury_mmc_executable', 'mmc')
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') 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 function! ale_linters#mercury#mmc#GetCommand(buffer) abort
let l:module_name = expand('#' . a:buffer . ':t:r') let l:module_name = expand('#' . a:buffer . ':t:r')
return ale#path#BufferCdString(a:buffer) return ale#path#BufferCdString(a:buffer)
\ . ale_linters#mercury#mmc#GetExecutable(a:buffer) \ . '%e --errorcheck-only '
\ . ' --errorcheck-only '
\ . ale#Var(a:buffer, 'mercury_mmc_options') \ . ale#Var(a:buffer, 'mercury_mmc_options')
\ . ' ' . l:module_name \ . ' ' . l:module_name
endfunction endfunction
@ -38,7 +33,7 @@ endfunction
call ale#linter#Define('mercury', { call ale#linter#Define('mercury', {
\ 'name': 'mmc', \ 'name': 'mmc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable', \ 'executable_callback': ale#VarFunc('mercury_mmc_executable'),
\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand', \ 'command_callback': 'ale_linters#mercury#mmc#GetCommand',
\ 'callback': 'ale_linters#mercury#mmc#Handle', \ 'callback': 'ale_linters#mercury#mmc#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -4,25 +4,13 @@
call ale#Set('nasm_nasm_executable', 'nasm') call ale#Set('nasm_nasm_executable', 'nasm')
call ale#Set('nasm_nasm_options', '') 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 function! ale_linters#nasm#nasm#GetCommand(buffer) abort
" Note that NASM require a trailing slash to the -I option. " Note that NASM requires a trailing slash for the -I option.
let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer))
let l:separator = has('win32') ? '\' : '/' let l:separator = has('win32') ? '\' : '/'
let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator) let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator
let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer)
return l:executable return '%e -X gnu -I ' . ale#Escape(l:path)
\ . ' -X gnu' \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options'))
\ . ' -I ' . l:path
\ . ' ' . l:options
\ . ' %s' \ . ' %s'
endfunction endfunction
@ -30,6 +18,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
" Note that we treat 'fatal' as errors. " Note that we treat 'fatal' as errors.
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = [] let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern) for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, { call add(l:output, {
\ 'lnum': l:match[1] + 0, \ 'lnum': l:match[1] + 0,
@ -37,6 +26,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
\ 'text': l:match[3], \ 'text': l:match[3],
\}) \})
endfor endfor
return l:output return l:output
endfunction endfunction
@ -44,7 +34,7 @@ call ale#linter#Define('nasm', {
\ 'name': 'nasm', \ 'name': 'nasm',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'lint_file': 1, \ 'lint_file': 1,
\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable', \ 'executable_callback': ale#VarFunc('nasm_nasm_executable'),
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', \ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
\ 'callback': 'ale_linters#nasm#nasm#Handle', \ 'callback': 'ale_linters#nasm#nasm#Handle',
\}) \})

View File

@ -1,20 +1,11 @@
" Author: Vincent Lequertier <https://github.com/SkySymbol> " Author: Vincent Lequertier <https://github.com/SkySymbol>
" Description: This file adds support for checking perl syntax " Description: This file adds support for checking perl syntax
let g:ale_perl_perl_executable = call ale#Set('perl_perl_executable', 'perl')
\ get(g:, 'ale_perl_perl_executable', 'perl') call ale#Set('perl_perl_options', '-c -Mwarnings -Ilib')
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
function! ale_linters#perl#perl#GetCommand(buffer) abort function! ale_linters#perl#perl#GetCommand(buffer) abort
return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer)) return '%e' . ale#Pad(ale#Var(a:buffer, 'perl_perl_options')) . ' %t'
\ . ' ' . ale#Var(a:buffer, 'perl_perl_options')
\ . ' %t'
endfunction endfunction
let s:begin_failed_skip_pattern = '\v' . join([ let s:begin_failed_skip_pattern = '\v' . join([
@ -61,7 +52,7 @@ endfunction
call ale#linter#Define('perl', { call ale#linter#Define('perl', {
\ 'name': 'perl', \ 'name': 'perl',
\ 'executable_callback': 'ale_linters#perl#perl#GetExecutable', \ 'executable_callback': ale#VarFunc('perl_perl_executable'),
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'command_callback': 'ale_linters#perl#perl#GetCommand', \ 'command_callback': 'ale_linters#perl#perl#GetCommand',
\ 'callback': 'ale_linters#perl#perl#Handle', \ 'callback': 'ale_linters#perl#perl#Handle',

View File

@ -1,21 +1,10 @@
" Author: Vincent Lequertier <https://github.com/SkySymbol>, Chris Weyl <cweyl@alumni.drew.edu> " Author: Vincent Lequertier <https://github.com/SkySymbol>, Chris Weyl <cweyl@alumni.drew.edu>
" Description: This file adds support for checking perl with perl critic " Description: This file adds support for checking perl with perl critic
let g:ale_perl_perlcritic_executable = call ale#Set('perl_perlcritic_executable', 'perlcritic')
\ get(g:, 'ale_perl_perlcritic_executable', 'perlcritic') call ale#Set('perl_perlcritic_profile', '.perlcriticrc')
call ale#Set('perl_perlcritic_options', '')
let g:ale_perl_perlcritic_profile = call ale#Set('perl_perlcritic_showrules', 0)
\ 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
function! ale_linters#perl#perlcritic#GetProfile(buffer) abort function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
" first see if we've been overridden " 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:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') 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) \ . ' --verbose ' . ale#Escape(l:critic_verbosity)
\ . ' --nocolor' \ . ' --nocolor'
\ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '') \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '')
\ . (!empty(l:options) ? ' ' . l:options : '') \ . ale#Pad(l:options)
endfunction endfunction
@ -66,7 +55,7 @@ endfunction
call ale#linter#Define('perl', { call ale#linter#Define('perl', {
\ 'name': 'perlcritic', \ 'name': 'perlcritic',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#perl#perlcritic#GetExecutable', \ 'executable_callback': ale#VarFunc('perl_perlcritic_executable'),
\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand', \ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand',
\ 'callback': 'ale_linters#perl#perlcritic#Handle', \ 'callback': 'ale_linters#perl#perlcritic#Handle',
\}) \})

View File

@ -4,16 +4,6 @@
call ale#Set('php_langserver_executable', 'php-language-server.php') call ale#Set('php_langserver_executable', 'php-language-server.php')
call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#php#langserver#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
@ -23,7 +13,9 @@ endfunction
call ale#linter#Define('php', { call ale#linter#Define('php', {
\ 'name': 'langserver', \ 'name': 'langserver',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('php_langserver', [
\ 'command_callback': 'ale_linters#php#langserver#GetCommand', \ 'vendor/bin/php-language-server.php',
\ ]),
\ 'command': 'php %e',
\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot', \ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot',
\}) \})

View File

@ -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_executable', 'phpcs')
call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0)) 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 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 = ale#Var(a:buffer, 'php_phpcs_standard')
let l:standard_option = !empty(l:standard) let l:standard_option = !empty(l:standard)
\ ? '--standard=' . l:standard \ ? '--standard=' . l:standard
\ : '' \ : ''
return ale#Escape(l:executable) return '%e -s --report=emacs --stdin-path=%s' . ale#Pad(l:standard_option)
\ . ' -s --report=emacs --stdin-path=%s ' . l:standard_option
endfunction endfunction
function! ale_linters#php#phpcs#Handle(buffer, lines) abort function! ale_linters#php#phpcs#Handle(buffer, lines) abort
@ -50,7 +40,10 @@ endfunction
call ale#linter#Define('php', { call ale#linter#Define('php', {
\ 'name': 'phpcs', \ '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', \ 'command_callback': 'ale_linters#php#phpcs#GetCommand',
\ 'callback': 'ale_linters#php#phpcs#Handle', \ 'callback': 'ale_linters#php#phpcs#Handle',
\}) \})

View File

@ -6,16 +6,9 @@ let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd')
" Set to change the ruleset " Set to change the ruleset
let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode') 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 function! ale_linters#php#phpmd#GetCommand(buffer) abort
let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer) return '%e %s text'
\ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset'))
return ale#Escape(l:executable)
\ . ' %s text '
\ . ale#Var(a:buffer, 'php_phpmd_ruleset')
\ . ' --ignore-violations-on-exit %t' \ . ' --ignore-violations-on-exit %t'
endfunction endfunction
@ -39,7 +32,7 @@ endfunction
call ale#linter#Define('php', { call ale#linter#Define('php', {
\ 'name': 'phpmd', \ 'name': 'phpmd',
\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable', \ 'executable_callback': ale#VarFunc('php_phpmd_executable'),
\ 'command_callback': 'ale_linters#php#phpmd#GetCommand', \ 'command_callback': 'ale_linters#php#phpmd#GetCommand',
\ 'callback': 'ale_linters#php#phpmd#Handle', \ 'callback': 'ale_linters#php#phpmd#Handle',
\}) \})

View File

@ -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_level = get(g:, 'ale_php_phpstan_level', '4')
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') 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 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 = ale#Var(a:buffer, 'php_phpstan_configuration')
let l:configuration_option = !empty(l:configuration) let l:configuration_option = !empty(l:configuration)
\ ? ' -c ' . l:configuration \ ? ' -c ' . l:configuration
\ : '' \ : ''
return ale#Escape(l:executable) return '%e analyze -l'
\ . ' analyze -l'
\ . ale#Var(a:buffer, 'php_phpstan_level') \ . ale#Var(a:buffer, 'php_phpstan_level')
\ . ' --errorFormat raw' \ . ' --errorFormat raw'
\ . l:configuration_option \ . l:configuration_option
@ -47,7 +40,7 @@ endfunction
call ale#linter#Define('php', { call ale#linter#Define('php', {
\ 'name': 'phpstan', \ 'name': 'phpstan',
\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable', \ 'executable_callback': ale#VarFunc('php_phpstan_executable'),
\ 'command_callback': 'ale_linters#php#phpstan#GetCommand', \ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
\ 'callback': 'ale_linters#php#phpstan#Handle', \ 'callback': 'ale_linters#php#phpstan#Handle',
\}) \})

View File

@ -3,19 +3,14 @@
call ale#Set('pony_ponyc_executable', 'ponyc') call ale#Set('pony_ponyc_executable', 'ponyc')
call ale#Set('pony_ponyc_options', '--pass paint') 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 function! ale_linters#pony#ponyc#GetCommand(buffer) abort
return ale#Escape(ale_linters#pony#ponyc#GetExecutable(a:buffer)) return '%e' . ale#Pad(ale#Var(a:buffer, 'pony_ponyc_options'))
\ . ' ' . ale#Var(a:buffer, 'pony_ponyc_options')
endfunction endfunction
call ale#linter#Define('pony', { call ale#linter#Define('pony', {
\ 'name': 'ponyc', \ 'name': 'ponyc',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#pony#ponyc#GetExecutable', \ 'executable_callback': ale#VarFunc('pony_ponyc_executable'),
\ 'command_callback': 'ale_linters#pony#ponyc#GetCommand', \ 'command_callback': 'ale_linters#pony#ponyc#GetCommand',
\ 'callback': 'ale#handlers#pony#HandlePonycFormat', \ 'callback': 'ale#handlers#pony#HandlePonycFormat',
\}) \})

View File

@ -5,12 +5,6 @@ call ale#Set('pug_puglint_options', '')
call ale#Set('pug_puglint_executable', 'pug-lint') call ale#Set('pug_puglint_executable', 'pug-lint')
call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! s:FindConfig(buffer) abort
for l:filename in [ for l:filename in [
\ '.pug-lintrc', \ '.pug-lintrc',
@ -29,19 +23,19 @@ function! s:FindConfig(buffer) abort
endfunction endfunction
function! ale_linters#pug#puglint#GetCommand(buffer) abort 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:options = ale#Var(a:buffer, 'pug_puglint_options')
let l:config = s:FindConfig(a:buffer) let l:config = s:FindConfig(a:buffer)
return ale#Escape(l:executable) return '%e' . ale#Pad(l:options)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '')
\ . ' -r inline %t' \ . ' -r inline %t'
endfunction endfunction
call ale#linter#Define('pug', { call ale#linter#Define('pug', {
\ 'name': 'puglint', \ 'name': 'puglint',
\ 'executable_callback': 'ale_linters#pug#puglint#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('pug_puglint', [
\ 'node_modules/.bin/pug-lint',
\ ]),
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#pug#puglint#GetCommand', \ 'command_callback': 'ale_linters#pug#puglint#GetCommand',
\ 'callback': 'ale#handlers#unix#HandleAsError', \ 'callback': 'ale#handlers#unix#HandleAsError',

View File

@ -3,16 +3,6 @@
call ale#Set('puppet_languageserver_executable', 'puppet-languageserver') 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 function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort
" Note: The metadata.json file is recommended for Puppet 4+ modules, but " 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 " there's no requirement to have it, so fall back to the other possible
@ -38,8 +28,8 @@ endfunction
call ale#linter#Define('puppet', { call ale#linter#Define('puppet', {
\ 'name': 'languageserver', \ 'name': 'languageserver',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#puppet#languageserver#GetExecutable', \ 'executable_callback': ale#VarFunc('puppet_languageserver_executable'),
\ 'command_callback': 'ale_linters#puppet#languageserver#GetCommand', \ 'command': '%e --stdio',
\ 'language': 'puppet', \ 'language': 'puppet',
\ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot', \ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot',
\}) \})

View File

@ -1,26 +1,18 @@
" Author: Alexander Olofsson <alexander.olofsson@liu.se>, Robert Flechtner <flechtner@chemmedia.de> " Author: Alexander Olofsson <alexander.olofsson@liu.se>, Robert Flechtner <flechtner@chemmedia.de>
" Description: puppet-lint for puppet files " Description: puppet-lint for puppet files
let g:ale_puppet_puppetlint_executable = call ale#Set('puppet_puppetlint_executable', 'puppet-lint')
\ get(g:, 'ale_puppet_puppetlint_executable', 'puppet-lint') call ale#Set('puppet_puppetlint_options', '--no-autoloader_layout-check')
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
function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort
return ale_linters#puppet#puppetlint#GetExecutable(a:buffer) return '%e' . ale#Pad(ale#Var(a:buffer, 'puppet_puppetlint_options'))
\ . ' ' . ale#Var(a:buffer, 'puppet_puppetlint_options')
\ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"' \ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"'
\ . ' %t' \ . ' %t'
endfunction endfunction
call ale#linter#Define('puppet', { call ale#linter#Define('puppet', {
\ 'name': 'puppetlint', \ 'name': 'puppetlint',
\ 'executable_callback': 'ale_linters#puppet#puppetlint#GetExecutable', \ 'executable_callback': ale#VarFunc('puppet_puppetlint_executable'),
\ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand', \ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\}) \})

View File

@ -5,16 +5,11 @@
call ale#Set('pyrex_cython_executable', 'cython') call ale#Set('pyrex_cython_executable', 'cython')
call ale#Set('pyrex_cython_options', '--warning-extra') 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 function! ale_linters#pyrex#cython#GetCommand(buffer) abort
let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
return ale#Escape(ale_linters#pyrex#cython#GetExecutable(a:buffer)) return '%e --working ' . l:local_dir . ' --include-dir ' . l:local_dir
\ . ' --working ' . l:local_dir . ' --include-dir ' . l:local_dir \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options'))
\ . ' ' . ale#Var(a:buffer, 'pyrex_cython_options')
\ . ' --output-file ' . g:ale#util#nul_file . ' %t' \ . ' --output-file ' . g:ale#util#nul_file . ' %t'
endfunction endfunction
@ -37,7 +32,7 @@ endfunction
call ale#linter#Define('pyrex', { call ale#linter#Define('pyrex', {
\ 'name': 'cython', \ 'name': 'cython',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#pyrex#cython#GetExecutable', \ 'executable_callback': ale#VarFunc('pyrex_cython_executable'),
\ 'command_callback': 'ale_linters#pyrex#cython#GetCommand', \ 'command_callback': 'ale_linters#pyrex#cython#GetCommand',
\ 'callback': 'ale_linters#pyrex#cython#Handle', \ 'callback': 'ale_linters#pyrex#cython#Handle',
\}) \})

View File

@ -1,40 +1,25 @@
" Author: pylipp (www.github.com/pylipp) " Author: pylipp (www.github.com/pylipp)
" Description: qmlfmt for QML files " Description: qmlfmt for QML files
let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt') call ale#Set('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
" Find lines like " Find lines like
" Error:11:1: Expected token `}' " Error:11:1: Expected token `}'
function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort
let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$' let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern) return map(ale#util#GetMatches(a:lines, l:pattern), "{
let l:item = { \ 'lnum': v:val[2] + 0,
\ 'lnum': l:match[2] + 0, \ 'col': v:val[3] + 0,
\ 'col': l:match[3] + 0, \ 'text': v:val[4],
\ 'text': l:match[4], \ 'type': v:val[1] is# 'Warning' ? 'W' : 'E',
\ 'type': l:match[1] is# 'Warning' ? 'W' : 'E', \}")
\}
call add(l:output, l:item)
endfor
return l:output
endfunction endfunction
call ale#linter#Define('qml', { call ale#linter#Define('qml', {
\ 'name': 'qmlfmt', \ 'name': 'qmlfmt',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable', \ 'executable_callback': ale#VarFunc('qml_qmlfmt_executable'),
\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand', \ 'command': '%e -e',
\ 'callback': 'ale_linters#qml#qmlfmt#Handle', \ 'callback': 'ale_linters#qml#qmlfmt#Handle',
\}) \})

View File

@ -3,20 +3,10 @@
call ale#Set('ruby_ruby_executable', 'ruby') 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', { call ale#linter#Define('ruby', {
\ 'name': 'ruby', \ 'name': 'ruby',
\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable', \ 'executable_callback': ale#VarFunc('ruby_ruby_executable'),
\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand', \ 'command': '%e -w -c -T1 %t',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', \ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\}) \})

View File

@ -4,19 +4,10 @@
call ale#Set('rust_rls_executable', 'rls') call ale#Set('rust_rls_executable', 'rls')
call ale#Set('rust_rls_toolchain', 'nightly') 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 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') let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain')
if empty(l:toolchain) return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '')
return ale#Escape(l:executable)
else
return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain)
endif
endfunction endfunction
function! ale_linters#rust#rls#GetProjectRoot(buffer) abort function! ale_linters#rust#rls#GetProjectRoot(buffer) abort
@ -28,7 +19,7 @@ endfunction
call ale#linter#Define('rust', { call ale#linter#Define('rust', {
\ 'name': 'rls', \ 'name': 'rls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable', \ 'executable_callback': ale#VarFunc('rust_rls_executable'),
\ 'command_callback': 'ale_linters#rust#rls#GetCommand', \ 'command_callback': 'ale_linters#rust#rls#GetCommand',
\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot', \ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot',
\}) \})

View File

@ -3,20 +3,11 @@
call ale#Set('sass_stylelint_executable', 'stylelint') call ale#Set('sass_stylelint_executable', 'stylelint')
call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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', { call ale#linter#Define('sass', {
\ 'name': 'stylelint', \ 'name': 'stylelint',
\ 'executable_callback': 'ale_linters#sass#stylelint#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('sass_stylelint', [
\ 'command_callback': 'ale_linters#sass#stylelint#GetCommand', \ 'node_modules/.bin/stylelint',
\ ]),
\ 'command': '%e --stdin-filename %s',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@ -1,29 +1,14 @@
" Author: Nils Leuzinger - https://github.com/PawkyPenguin " Author: Nils Leuzinger - https://github.com/PawkyPenguin
" Description: Basic scala support using fsc " 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' function! s:IsSbt(buffer) abort
endfunction return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
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'
endfunction endfunction
call ale#linter#Define('scala', { call ale#linter#Define('scala', {
\ 'name': 'fsc', \ 'name': 'fsc',
\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable', \ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'fsc'},
\ 'command_callback': 'ale_linters#scala#fsc#GetCommand', \ 'command': '%e -Ystop-after:parser %t',
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\}) \})

View File

@ -2,29 +2,14 @@
" w0rp <devw0rp@gmail.com> " w0rp <devw0rp@gmail.com>
" Description: Basic scala support using scalac " Description: Basic scala support using scalac
function! ale_linters#scala#scalac#GetExecutable(buffer) abort function! s:IsSbt(buffer) abort
if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 return 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'
endfunction endfunction
call ale#linter#Define('scala', { call ale#linter#Define('scala', {
\ 'name': 'scalac', \ 'name': 'scalac',
\ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable', \ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'},
\ 'command_callback': 'ale_linters#scala#scalac#GetCommand', \ 'command': '%e -Ystop-after:parser %t',
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\}) \})

View File

@ -3,20 +3,11 @@
call ale#Set('scss_stylelint_executable', 'stylelint') call ale#Set('scss_stylelint_executable', 'stylelint')
call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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', { call ale#linter#Define('scss', {
\ 'name': 'stylelint', \ 'name': 'stylelint',
\ 'executable_callback': 'ale_linters#scss#stylelint#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('scss_stylelint', [
\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', \ 'node_modules/.bin/stylelint',
\ ]),
\ 'command': '%e --stdin-filename %s',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@ -6,14 +6,9 @@
" codes to exclude from shellcheck. For example: " codes to exclude from shellcheck. For example:
" "
" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004'
let g:ale_sh_shellcheck_exclusions = call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', ''))
\ get(g:, 'ale_sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) call ale#Set('sh_shellcheck_executable', 'shellcheck')
call ale#Set('sh_shellcheck_options', '')
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', '')
function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'sh_shellcheck_executable') return ale#Var(a:buffer, 'sh_shellcheck_executable')

View File

@ -26,19 +26,12 @@
" And this is always output at the end and should just be ignored: " And this is always output at the end and should just be ignored:
" 0 packages and 1 specfiles checked; 4 errors, 0 warnings. " 0 packages and 1 specfiles checked; 4 errors, 0 warnings.
let g:ale_spec_rpmlint_executable = call ale#Set('spec_rpmlint_executable', 'rpmlint')
\ get(g:, 'ale_spec_rpmlint_executable', 'rpmlint') call ale#Set('spec_rpmlint_options', '')
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
function! ale_linters#spec#rpmlint#GetCommand(buffer) abort function! ale_linters#spec#rpmlint#GetCommand(buffer) abort
return ale_linters#spec#rpmlint#GetExecutable(a:buffer) return '%e'
\ . ' ' . ale#Var(a:buffer, 'spec_rpmlint_options') \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options'))
\ . ' -o "NetworkEnabled False"' \ . ' -o "NetworkEnabled False"'
\ . ' -v' \ . ' -v'
\ . ' %t' \ . ' %t'
@ -79,7 +72,7 @@ endfunction
call ale#linter#Define('spec', { call ale#linter#Define('spec', {
\ 'name': 'rpmlint', \ 'name': 'rpmlint',
\ 'executable_callback': 'ale_linters#spec#rpmlint#GetExecutable', \ 'executable_callback': ale#VarFunc('spec_rpmlint_executable'),
\ 'command_callback': 'ale_linters#spec#rpmlint#GetCommand', \ 'command_callback': 'ale_linters#spec#rpmlint#GetCommand',
\ 'callback': 'ale_linters#spec#rpmlint#Handle', \ 'callback': 'ale_linters#spec#rpmlint#Handle',
\}) \})

View File

@ -4,21 +4,17 @@ call ale#Set('stylus_stylelint_executable', 'stylelint')
call ale#Set('stylus_stylelint_options', '') call ale#Set('stylus_stylelint_options', '')
call ale#Set('stylus_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#stylus#stylelint#GetCommand(buffer) abort
return ale_linters#stylus#stylelint#GetExecutable(a:buffer) return '%e'
\ . ' ' . ale#Var(a:buffer, 'stylus_stylelint_options') \ . ale#Pad(ale#Var(a:buffer, 'stylus_stylelint_options'))
\ . ' --stdin-filename %s' \ . ' --stdin-filename %s'
endfunction endfunction
call ale#linter#Define('stylus', { call ale#linter#Define('stylus', {
\ 'name': 'stylelint', \ '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', \ 'command_callback': 'ale_linters#stylus#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\}) \})

View File

@ -4,16 +4,10 @@
call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl') call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl')
call ale#Set('tcl_nagelfar_options', '') 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 function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options') let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options')
return ale#Escape(ale_linters#tcl#nagelfar#GetExecutable(a:buffer)) return '%e' . ale#Pad(l:options) . ' %s'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %s'
endfunction endfunction
function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort
@ -39,7 +33,7 @@ endfunction
call ale#linter#Define('tcl', { call ale#linter#Define('tcl', {
\ 'name': 'nagelfar', \ 'name': 'nagelfar',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ 'executable_callback': 'ale_linters#tcl#nagelfar#GetExecutable', \ 'executable_callback': ale#VarFunc('tcl_nagelfar_executable'),
\ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand', \ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand',
\ 'callback': 'ale_linters#tcl#nagelfar#Handle', \ 'callback': 'ale_linters#tcl#nagelfar#Handle',
\ 'lint_file': 1, \ 'lint_file': 1,

View File

@ -30,14 +30,11 @@ function! ale_linters#terraform#tflint#Handle(buffer, lines) abort
return l:output return l:output
endfunction 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 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') let l:config_file = ale#path#FindNearestFile(a:buffer, '.tflint.hcl')
if !empty(l:config_file) if !empty(l:config_file)
let l:cmd .= ' --config ' . ale#Escape(l:config_file) let l:cmd .= ' --config ' . ale#Escape(l:config_file)
endif endif
@ -54,9 +51,7 @@ endfunction
call ale#linter#Define('terraform', { call ale#linter#Define('terraform', {
\ 'name': 'tflint', \ 'name': 'tflint',
\ 'executable_callback': 'ale_linters#terraform#tflint#GetExecutable', \ 'executable_callback': ale#VarFunc('terraform_tflint_executable'),
\ 'command_callback': 'ale_linters#terraform#tflint#GetCommand', \ 'command_callback': 'ale_linters#terraform#tflint#GetCommand',
\ 'callback': 'ale_linters#terraform#tflint#Handle', \ 'callback': 'ale_linters#terraform#tflint#Handle',
\}) \})
" vim:sw=4

View File

@ -1,16 +1,7 @@
" Author: Andrew Balmos - <andrew@balmos.org> " Author: Andrew Balmos - <andrew@balmos.org>
" Description: lacheck for LaTeX files " Description: lacheck for LaTeX files
let g:ale_tex_lacheck_executable = call ale#Set('tex_lacheck_executable', 'lacheck')
\ 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
function! ale_linters#tex#lacheck#Handle(buffer, lines) abort function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
" Mattes lines like: " Mattes lines like:
@ -41,7 +32,7 @@ endfunction
call ale#linter#Define('tex', { call ale#linter#Define('tex', {
\ 'name': 'lacheck', \ 'name': 'lacheck',
\ 'executable_callback': 'ale_linters#tex#lacheck#GetExecutable', \ 'executable_callback': ale#VarFunc('tex_lacheck_executable'),
\ 'command_callback': 'ale_linters#tex#lacheck#GetCommand', \ 'command': '%e %t',
\ 'callback': 'ale_linters#tex#lacheck#Handle' \ 'callback': 'ale_linters#tex#lacheck#Handle'
\}) \})

View File

@ -5,10 +5,6 @@ call ale#Set('thrift_thrift_generators', ['cpp'])
call ale#Set('thrift_thrift_includes', []) call ale#Set('thrift_thrift_includes', [])
call ale#Set('thrift_thrift_options', '-strict') 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 function! ale_linters#thrift#thrift#GetCommand(buffer) abort
let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators') let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators')
let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes') 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) 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:generators), "'--gen ' . v:val")))
\ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val"))) \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val")))
\ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options')) \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options'))
@ -83,7 +79,7 @@ call ale#linter#Define('thrift', {
\ 'name': 'thrift', \ 'name': 'thrift',
\ 'executable': 'thrift', \ 'executable': 'thrift',
\ 'output_stream': 'both', \ 'output_stream': 'both',
\ 'executable_callback': 'ale_linters#thrift#thrift#GetExecutable', \ 'executable_callback': ale#VarFunc('thrift_thrift_executable'),
\ 'command_callback': 'ale_linters#thrift#thrift#GetCommand', \ 'command_callback': 'ale_linters#thrift#thrift#GetCommand',
\ 'callback': 'ale_linters#thrift#thrift#Handle', \ 'callback': 'ale_linters#thrift#thrift#Handle',
\}) \})

View File

@ -5,22 +5,13 @@ call ale#Set('typescript_tsserver_executable', 'tsserver')
call ale#Set('typescript_tsserver_config_path', '') call ale#Set('typescript_tsserver_config_path', '')
call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) 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', { call ale#linter#Define('typescript', {
\ 'name': 'tsserver', \ 'name': 'tsserver',
\ 'lsp': 'tsserver', \ 'lsp': 'tsserver',
\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('typescript_tsserver', [
\ 'node_modules/.bin/tsserver',
\ ]),
\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable', \ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable',
\ 'project_root_callback': 'ale_linters#typescript#tsserver#GetProjectRoot', \ 'project_root_callback': {-> ''},
\ 'language': '', \ 'language': '',
\}) \})

View File

@ -4,18 +4,6 @@
call ale#Set('vue_vls_executable', 'vls') call ale#Set('vue_vls_executable', 'vls')
call ale#Set('vue_vls_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#vue#vls#GetProjectRoot(buffer) abort
let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json')
@ -25,8 +13,10 @@ endfunction
call ale#linter#Define('vue', { call ale#linter#Define('vue', {
\ 'name': 'vls', \ 'name': 'vls',
\ 'lsp': 'stdio', \ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#vue#vls#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('vue_vls', [
\ 'command_callback': 'ale_linters#vue#vls#GetCommand', \ 'node_modules/.bin/vls',
\ ]),
\ 'command': '%e --stdio',
\ 'language': 'vue', \ 'language': 'vue',
\ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot', \ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot',
\}) \})

View File

@ -5,12 +5,8 @@
let g:ale_xml_xmllint_executable = get(g:, 'ale_xml_xmllint_executable', 'xmllint') 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', '') 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 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')) \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options'))
\ . ' --noout -' \ . ' --noout -'
endfunction endfunction
@ -63,7 +59,7 @@ endfunction
call ale#linter#Define('xml', { call ale#linter#Define('xml', {
\ 'name': 'xmllint', \ 'name': 'xmllint',
\ 'output_stream': 'stderr', \ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#xml#xmllint#GetExecutable', \ 'executable_callback': ale#VarFunc('xml_xmllint_executable'),
\ 'command_callback': 'ale_linters#xml#xmllint#GetCommand', \ 'command_callback': 'ale_linters#xml#xmllint#GetCommand',
\ 'callback': 'ale_linters#xml#xmllint#Handle', \ 'callback': 'ale_linters#xml#xmllint#Handle',
\ }) \ })

View File

@ -4,17 +4,6 @@
call ale#Set('yaml_swaglint_executable', 'swaglint') call ale#Set('yaml_swaglint_executable', 'swaglint')
call ale#Set('yaml_swaglint_use_global', get(g:, 'ale_use_global_executables', 0)) 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 function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort
let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$' let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$'
let l:output = [] let l:output = []
@ -43,7 +32,9 @@ endfunction
call ale#linter#Define('yaml', { call ale#linter#Define('yaml', {
\ 'name': 'swaglint', \ 'name': 'swaglint',
\ 'executable_callback': 'ale_linters#yaml#swaglint#GetExecutable', \ 'executable_callback': ale#node#FindExecutableFunc('yaml_swaglint', [
\ 'command_callback': 'ale_linters#yaml#swaglint#GetCommand', \ 'node_modules/.bin/swaglint',
\ ]),
\ 'command': '%e -r compact --stdin',
\ 'callback': 'ale_linters#yaml#swaglint#Handle', \ 'callback': 'ale_linters#yaml#swaglint#Handle',
\}) \})

View File

@ -1,18 +1,10 @@
" Author: KabbAmine <amine.kabb@gmail.com> " Author: KabbAmine <amine.kabb@gmail.com>
let g:ale_yaml_yamllint_executable = call ale#Set('yaml_yamllint_executable', 'yamllint')
\ get(g:, 'ale_yaml_yamllint_executable', 'yamllint') call ale#Set('yaml_yamllint_options', '')
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
function! ale_linters#yaml#yamllint#GetCommand(buffer) abort function! ale_linters#yaml#yamllint#GetCommand(buffer) abort
return ale_linters#yaml#yamllint#GetExecutable(a:buffer) return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
\ . ' ' . ale#Var(a:buffer, 'yaml_yamllint_options')
\ . ' -f parsable %t' \ . ' -f parsable %t'
endfunction endfunction
@ -52,7 +44,7 @@ endfunction
call ale#linter#Define('yaml', { call ale#linter#Define('yaml', {
\ 'name': 'yamllint', \ 'name': 'yamllint',
\ 'executable_callback': 'ale_linters#yaml#yamllint#GetExecutable', \ 'executable_callback': ale#VarFunc('yaml_yamllint_executable'),
\ 'command_callback': 'ale_linters#yaml#yamllint#GetCommand', \ 'command_callback': 'ale_linters#yaml#yamllint#GetCommand',
\ 'callback': 'ale_linters#yaml#yamllint#Handle', \ 'callback': 'ale_linters#yaml#yamllint#Handle',
\}) \})

View File

@ -197,6 +197,11 @@ function! ale#Var(buffer, variable_name) abort
return get(l:vars, l:full_name, g:[l:full_name]) return get(l:vars, l:full_name, g:[l:full_name])
endfunction 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. " Initialize a variable with a default value, if it isn't already set.
" "
" Every variable name will be prefixed with 'ale_'. " Every variable name will be prefixed with 'ale_'.

View File

@ -54,9 +54,14 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
endif endif
else else
let l:command = ale#linter#GetCommand(l:buffer, l:linter) 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 " Replace %e with the escaped executable, so tests keep passing after
" linters are changed to use %e. " linters are changed to use %e.
let l:command = substitute(l:command, '%e', '\=ale#Escape(l:executable)', 'g') 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 endif
AssertEqual AssertEqual
@ -126,7 +131,9 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim' 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=+ WithChainResults :call ale#assert#WithChainResults(<args>)
command! -nargs=+ AssertLinter :call ale#assert#Linter(<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 unlet! g:ale_create_dummy_temporary_file
let s:chain_results = [] let s:chain_results = []
delcommand WithChainResults if exists(':WithChainResults')
delcommand AssertLinter delcommand WithChainResults
delcommand AssertLinterNotExecuted endif
delcommand AssertLSPOptions
delcommand AssertLSPLanguage
delcommand AssertLSPProject
call ale#test#RestoreDirectory() 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
if exists('g:dir')
call ale#test#RestoreDirectory()
endif
Restore Restore

View File

@ -256,7 +256,7 @@ function! ale#c#IncludeOptions(include_paths) abort
return '' return ''
endif endif
return ' ' . join(l:option_list) . ' ' return join(l:option_list)
endfunction endfunction
let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [

View File

@ -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') return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction 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 " Create a executable string which executes a Node.js script command with a
" Node.js executable if needed. " Node.js executable if needed.
" "

View File

@ -13,7 +13,7 @@ Execute(The minlevel of flawfinder should be configurable):
AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t' AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
Execute(Additional flawfinder options should be configurable): Execute(Additional flawfinder options should be configurable):
let b:ale_c_flawfinder_options = ' --foobar' let b:ale_c_flawfinder_options = '--foobar'
AssertLinter 'flawfinder', AssertLinter 'flawfinder',
\ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t' \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'

View File

@ -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'))

View File

@ -12,3 +12,9 @@ Execute(The executable should be configurable):
AssertLinter 'foobar', AssertLinter 'foobar',
\ ale#Escape('foobar') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file \ 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

View File

@ -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'

View File

@ -10,4 +10,4 @@ Execute(The default executable and command should be correct):
Given scala.sbt(An empty SBT file): Given scala.sbt(An empty SBT file):
Execute(fsc should not be run for sbt files): Execute(fsc should not be run for sbt files):
AssertLinter '', '' AssertLinterNotExecuted

View File

@ -5,20 +5,20 @@ After:
call ale#assert#TearDownLinterTest() call ale#assert#TearDownLinterTest()
Execute(The fortran gcc command callback should return the correct default string): 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): Execute(The fortran gcc command callback should let you set options):
let g:ale_fortran_gcc_options = '-Wotherthings' 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): Execute(The fortran gcc command callback should let you use -ffixed-form):
let g:ale_fortran_gcc_use_free_form = 0 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): Execute(The fortran executable should be configurable):
let g:ale_fortran_gcc_executable = 'gfortran' let g:ale_fortran_gcc_executable = 'gfortran'
AssertLinter 'gfortran', AssertLinter 'gfortran',
\ 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -' \ ale#Escape('gfortran') . ' -S -x f95 -fsyntax-only -ffree-form -Wall -'

View File

@ -5,9 +5,9 @@ After:
call ale#assert#TearDownLinterTest() call ale#assert#TearDownLinterTest()
Execute(The default command should be correct): 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): Execute(The luac executable should be configurable):
let g:ale_lua_luac_executable = 'luac.sh' let g:ale_lua_luac_executable = 'luac.sh'
AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p - ' AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p -'

View File

@ -6,7 +6,7 @@ After:
Execute(The lua luacheck command callback should return the correct default string): Execute(The lua luacheck command callback should return the correct default string):
AssertLinter 'luacheck', 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): Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename' 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' let g:ale_lua_luacheck_executable = 'luacheck.sh'
AssertLinter 'luacheck.sh', AssertLinter 'luacheck.sh',
\ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -' \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -'

View File

@ -8,18 +8,18 @@ After:
Execute(The default command should be correct): Execute(The default command should be correct):
AssertLinter 'mmc', AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr('')) \ 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): Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo' let b:ale_mercury_mmc_executable = 'foo'
AssertLinter 'foo', AssertLinter 'foo',
\ ale#path#BufferCdString(bufnr('')) \ 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): Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar' let b:ale_mercury_mmc_options = '--bar'
AssertLinter 'mmc', AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr('')) \ ale#path#BufferCdString(bufnr(''))
\ . 'mmc --errorcheck-only --bar dummy' \ . ale#Escape('mmc') . ' --errorcheck-only --bar dummy'

View File

@ -2,7 +2,7 @@ Before:
call ale#assert#SetUpLinterTest('nasm', 'nasm') call ale#assert#SetUpLinterTest('nasm', 'nasm')
let b:command_tail = 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 = let b:command_tail_opt =
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s' \ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s'

View File

@ -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'

View File

@ -10,4 +10,4 @@ Execute(The default executable and command should be correct):
Given scala.sbt(An empty SBT file): Given scala.sbt(An empty SBT file):
Execute(scalac should not be run for sbt files): Execute(scalac should not be run for sbt files):
AssertLinter '', '' AssertLinterNotExecuted

View File

@ -5,25 +5,25 @@ After:
call ale#assert#TearDownLinterTest() call ale#assert#TearDownLinterTest()
Execute(The yaml swaglint command callback should return the correct default string): 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): Execute(The yaml swaglint command callback should be configurable):
let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint' let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint'
AssertLinter '~/.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): 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_executable = '/usr/local/bin/swaglint'
let g:ale_yaml_swaglint_use_global = 1 let g:ale_yaml_swaglint_use_global = 1
AssertLinter '/usr/local/bin/swaglint', 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): Execute(The yaml swaglint command callback should allow a local installation to be used):
call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml') call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml')
AssertLinter AssertLinter
\ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'), \ 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' \ . ' -r compact --stdin'

View File

@ -17,3 +17,12 @@ Execute(Overriding options should work):
let g:ale_terraform_tflint_options = '--whatever' let g:ale_terraform_tflint_options = '--whatever'
AssertLinter 'fnord', ale#Escape('fnord') . ' --whatever -f json %t' 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'

View File

@ -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(''))

View File

@ -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(''))

Some files were not shown because too many files have changed in this diff Show More