diff --git a/sources_non_forked/ale/ale_linters/asm/gcc.vim b/sources_non_forked/ale/ale_linters/asm/gcc.vim index 4ac876f8..fdd0ee83 100644 --- a/sources_non_forked/ale/ale_linters/asm/gcc.vim +++ b/sources_non_forked/ale/ale_linters/asm/gcc.vim @@ -4,15 +4,10 @@ call ale#Set('asm_gcc_executable', 'gcc') call ale#Set('asm_gcc_options', '-Wall') -function! ale_linters#asm#gcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'asm_gcc_executable') -endfunction - function! ale_linters#asm#gcc#GetCommand(buffer) abort - return ale#Escape(ale_linters#asm#gcc#GetExecutable(a:buffer)) - \ . ' -x assembler -fsyntax-only ' - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' + return '%e -x assembler -fsyntax-only ' + \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' endfunction function! ale_linters#asm#gcc#Handle(buffer, lines) abort @@ -33,7 +28,7 @@ endfunction call ale#linter#Define('asm', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#asm#gcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('asm_gcc_executable'), \ 'command_callback': 'ale_linters#asm#gcc#GetCommand', \ 'callback': 'ale_linters#asm#gcc#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/awk/gawk.vim b/sources_non_forked/ale/ale_linters/awk/gawk.vim index 8b60815f..eb92e45e 100644 --- a/sources_non_forked/ale/ale_linters/awk/gawk.vim +++ b/sources_non_forked/ale/ale_linters/awk/gawk.vim @@ -1,29 +1,21 @@ " Author: kmarc " Description: This file adds support for using GNU awk with sripts. -let g:ale_awk_gawk_executable = -\ get(g:, 'ale_awk_gawk_executable', 'gawk') - -let g:ale_awk_gawk_options = -\ get(g:, 'ale_awk_gawk_options', '') - -function! ale_linters#awk#gawk#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'awk_gawk_executable') -endfunction +call ale#Set('awk_gawk_executable', 'gawk') +call ale#Set('awk_gawk_options', '') function! ale_linters#awk#gawk#GetCommand(buffer) abort " note the --source 'BEGIN ...' is to prevent " gawk from attempting to execute the body of the script " it is linting. - return ale#Escape(ale_linters#awk#gawk#GetExecutable(a:buffer)) - \ . " --source 'BEGIN { exit } END { exit 1 }'" + return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) - \ . ' ' . '-f %t --lint /dev/null' + \ . ' -f %t --lint /dev/null' endfunction call ale#linter#Define('awk', { \ 'name': 'gawk', -\ 'executable_callback': 'ale_linters#awk#gawk#GetExecutable', +\ 'executable_callback': ale#VarFunc('awk_gawk_executable'), \ 'command_callback': 'ale_linters#awk#gawk#GetCommand', \ 'callback': 'ale#handlers#gawk#HandleGawkFormat', \ 'output_stream': 'both' diff --git a/sources_non_forked/ale/ale_linters/c/clang.vim b/sources_non_forked/ale/ale_linters/c/clang.vim index 9d49fabb..f1bd675b 100644 --- a/sources_non_forked/ale/ale_linters/c/clang.vim +++ b/sources_non_forked/ale/ale_linters/c/clang.vim @@ -4,17 +4,12 @@ call ale#Set('c_clang_executable', 'clang') call ale#Set('c_clang_options', '-std=c11 -Wall') -function! ale_linters#c#clang#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_clang_executable') -endfunction - function! ale_linters#c#clang#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. - return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer)) - \ . ' -S -x c -fsyntax-only' + return '%e -S -x c -fsyntax-only' \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) \ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -' @@ -23,7 +18,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'clang', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#c#clang#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_clang_executable'), \ 'command_chain': [ \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#c#clang#GetCommand'} diff --git a/sources_non_forked/ale/ale_linters/c/clangd.vim b/sources_non_forked/ale/ale_linters/c/clangd.vim index 5aa2e221..2c7c5c13 100644 --- a/sources_non_forked/ale/ale_linters/c/clangd.vim +++ b/sources_non_forked/ale/ale_linters/c/clangd.vim @@ -9,21 +9,14 @@ function! ale_linters#c#clangd#GetProjectRoot(buffer) abort return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' endfunction -function! ale_linters#c#clangd#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_clangd_executable') -endfunction - function! ale_linters#c#clangd#GetCommand(buffer) abort - let l:executable = ale_linters#c#clangd#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'c_clangd_options') - - return ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') + return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) endfunction call ale#linter#Define('c', { \ 'name': 'clangd', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#c#clangd#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_clangd_executable'), \ 'command_callback': 'ale_linters#c#clangd#GetCommand', \ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/c/clangtidy.vim b/sources_non_forked/ale/ale_linters/c/clangtidy.vim index d456a5a2..54137480 100644 --- a/sources_non_forked/ale/ale_linters/c/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/c/clangtidy.vim @@ -16,38 +16,16 @@ call ale#Set('c_clangtidy_checks', ['*']) call ale#Set('c_clangtidy_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#c#clangtidy#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_clangtidy_executable') -endfunction - -function! s:GetBuildDirectory(buffer) abort - " Don't include build directory for header files, as compile_commands.json - " files don't consider headers to be translation units, and provide no - " commands for compiling header files. - if expand('#' . a:buffer) =~# '\v\.(h|hpp)$' - return '' - endif - - let l:build_dir = ale#Var(a:buffer, 'c_build_dir') - - " c_build_dir has the priority if defined - if !empty(l:build_dir) - return l:build_dir - endif - - return ale#path#Dirname(ale#c#FindCompileCommands(a:buffer)) -endfunction - function! ale_linters#c#clangtidy#GetCommand(buffer) abort let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') - let l:build_dir = s:GetBuildDirectory(a:buffer) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) " Get the extra options if we couldn't find a build directory. let l:options = empty(l:build_dir) \ ? ale#Var(a:buffer, 'c_clangtidy_options') \ : '' - return ale#Escape(ale_linters#c#clangtidy#GetExecutable(a:buffer)) + return '%e' \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') \ . ' %s' \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') @@ -57,7 +35,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#c#clangtidy#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_clangtidy_executable'), \ 'command_callback': 'ale_linters#c#clangtidy#GetCommand', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/c/cppcheck.vim b/sources_non_forked/ale/ale_linters/c/cppcheck.vim index 4db93f74..5e8c7936 100644 --- a/sources_non_forked/ale/ale_linters/c/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -4,10 +4,6 @@ call ale#Set('c_cppcheck_executable', 'cppcheck') call ale#Set('c_cppcheck_options', '--enable=style') -function! ale_linters#c#cppcheck#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_cppcheck_executable') -endfunction - function! ale_linters#c#cppcheck#GetCommand(buffer) abort " Search upwards from the file for compile_commands.json. " @@ -23,8 +19,7 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort \ : '' return l:cd_command - \ . ale#Escape(ale_linters#c#cppcheck#GetExecutable(a:buffer)) - \ . ' -q --language=c ' + \ . '%e -q --language=c ' \ . l:compile_commands_option \ . ale#Var(a:buffer, 'c_cppcheck_options') \ . ' %t' @@ -33,7 +28,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable_callback': 'ale_linters#c#cppcheck#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_cppcheck_executable'), \ 'command_callback': 'ale_linters#c#cppcheck#GetCommand', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/c/cquery.vim b/sources_non_forked/ale/ale_linters/c/cquery.vim index 208c226f..a20782a2 100644 --- a/sources_non_forked/ale/ale_linters/c/cquery.vim +++ b/sources_non_forked/ale/ale_linters/c/cquery.vim @@ -6,18 +6,14 @@ call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery')) function! ale_linters#c#cquery#GetProjectRoot(buffer) abort let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery') + endif + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' endfunction -function! ale_linters#c#cquery#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_cquery_executable') -endfunction - -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 return {'cacheDirectory': ale#Var(a:buffer, 'c_cquery_cache_directory')} endfunction @@ -25,8 +21,8 @@ endfunction call ale#linter#Define('c', { \ 'name': 'cquery', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#c#cquery#GetExecutable', -\ 'command_callback': 'ale_linters#c#cquery#GetCommand', +\ 'executable_callback': ale#VarFunc('c_cquery_executable'), +\ 'command': '%e', \ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot', \ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions', \}) diff --git a/sources_non_forked/ale/ale_linters/c/flawfinder.vim b/sources_non_forked/ale/ale_linters/c/flawfinder.vim index df6fbebe..7e1f6769 100644 --- a/sources_non_forked/ale/ale_linters/c/flawfinder.vim +++ b/sources_non_forked/ale/ale_linters/c/flawfinder.vim @@ -6,18 +6,12 @@ call ale#Set('c_flawfinder_options', '') call ale#Set('c_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) -function! ale_linters#c#flawfinder#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_flawfinder_executable') -endfunction - function! ale_linters#c#flawfinder#GetCommand(buffer) abort - " Set the minimum vulnerability level for flawfinder to bother with let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') - return ale#Escape(ale_linters#c#flawfinder#GetExecutable(a:buffer)) - \ . ' -CDQS' - \ . ale#Var(a:buffer, 'c_flawfinder_options') + return '%e -CDQS' + \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) \ . l:minlevel \ . ' %t' endfunction @@ -25,7 +19,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'flawfinder', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#c#flawfinder#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_flawfinder_executable'), \ 'command_callback': 'ale_linters#c#flawfinder#GetCommand', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/c/gcc.vim b/sources_non_forked/ale/ale_linters/c/gcc.vim index e2dff65d..60ecb712 100644 --- a/sources_non_forked/ale/ale_linters/c/gcc.vim +++ b/sources_non_forked/ale/ale_linters/c/gcc.vim @@ -4,17 +4,12 @@ call ale#Set('c_gcc_executable', 'gcc') call ale#Set('c_gcc_options', '-std=c11 -Wall') -function! ale_linters#c#gcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'c_gcc_executable') -endfunction - function! ale_linters#c#gcc#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. - return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer)) - \ . ' -S -x c -fsyntax-only' + return '%e -S -x c -fsyntax-only' \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) \ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -' @@ -23,7 +18,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#c#gcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('c_gcc_executable'), \ 'command_chain': [ \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#c#gcc#GetCommand'} diff --git a/sources_non_forked/ale/ale_linters/chef/foodcritic.vim b/sources_non_forked/ale/ale_linters/chef/foodcritic.vim index 2c28246c..c86336d6 100644 --- a/sources_non_forked/ale/ale_linters/chef/foodcritic.vim +++ b/sources_non_forked/ale/ale_linters/chef/foodcritic.vim @@ -6,17 +6,10 @@ call ale#Set('chef_foodcritic_executable', 'foodcritic') call ale#Set('chef_foodcritic_options', '') -function! ale_linters#chef#foodcritic#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'chef_foodcritic_executable') -endfunction - function! ale_linters#chef#foodcritic#GetCommand(buffer) abort - let l:executable = ale_linters#chef#foodcritic#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'chef_foodcritic_options') - return ale#Escape(l:executable) - \ . (!empty(l:options) ? ' ' . escape(l:options, '~') : '') - \ . ' %s' + return '%e' . ale#Pad(escape(l:options, '~')) . ' %s' endfunction function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort @@ -41,7 +34,7 @@ endfunction call ale#linter#Define('chef', { \ 'name': 'foodcritic', -\ 'executable_callback': 'ale_linters#chef#foodcritic#GetExecutable', +\ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'), \ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand', \ 'callback': 'ale_linters#chef#foodcritic#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/cpp/clang.vim b/sources_non_forked/ale/ale_linters/cpp/clang.vim index 72793a71..649c5993 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clang.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clang.vim @@ -4,17 +4,12 @@ call ale#Set('cpp_clang_executable', 'clang++') call ale#Set('cpp_clang_options', '-std=c++14 -Wall') -function! ale_linters#cpp#clang#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_clang_executable') -endfunction - function! ale_linters#cpp#clang#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. - return ale#Escape(ale_linters#cpp#clang#GetExecutable(a:buffer)) - \ . ' -S -x c++ -fsyntax-only' + return '%e -S -x c++ -fsyntax-only' \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) \ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -' @@ -23,7 +18,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'clang', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#cpp#clang#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_clang_executable'), \ 'command_chain': [ \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#cpp#clang#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim index 687991bd..c66d6702 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim @@ -5,10 +5,6 @@ call ale#Set('cpp_clangcheck_executable', 'clang-check') call ale#Set('cpp_clangcheck_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangcheck#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_clangcheck_executable') -endfunction - function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options') @@ -22,17 +18,16 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort " The extra arguments in the command are used to prevent .plist files from " being generated. These are only added if no build directory can be " detected. - return ale#Escape(ale_linters#cpp#clangcheck#GetExecutable(a:buffer)) - \ . ' -analyze %s' + return '%e -analyze %s' \ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '') - \ . (!empty(l:user_options) ? ' ' . l:user_options : '') + \ . ale#Pad(l:user_options) \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('cpp', { \ 'name': 'clangcheck', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#cpp#clangcheck#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'), \ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/cpp/clangd.vim b/sources_non_forked/ale/ale_linters/cpp/clangd.vim new file mode 100644 index 00000000..1d716c33 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clangd.vim @@ -0,0 +1,22 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('cpp_clangd_executable', 'clangd') +call ale#Set('cpp_clangd_options', '') + +function! ale_linters#cpp#clangd#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +function! ale_linters#cpp#clangd#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('cpp_clangd_executable'), +\ 'command_callback': 'ale_linters#cpp#clangd#GetCommand', +\ 'project_root_callback': 'ale_linters#cpp#clangd#GetProjectRoot', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim index d683327f..2f3089b4 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -10,38 +10,16 @@ call ale#Set('cpp_clangtidy_checks', ['*']) call ale#Set('cpp_clangtidy_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangtidy#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_clangtidy_executable') -endfunction - -function! s:GetBuildDirectory(buffer) abort - " Don't include build directory for header files, as compile_commands.json - " files don't consider headers to be translation units, and provide no - " commands for compiling header files. - if expand('#' . a:buffer) =~# '\v\.(h|hpp)$' - return '' - endif - - let l:build_dir = ale#Var(a:buffer, 'c_build_dir') - - " c_build_dir has the priority if defined - if !empty(l:build_dir) - return l:build_dir - endif - - return ale#path#Dirname(ale#c#FindCompileCommands(a:buffer)) -endfunction - function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') - let l:build_dir = s:GetBuildDirectory(a:buffer) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) " Get the extra options if we couldn't find a build directory. let l:options = empty(l:build_dir) \ ? ale#Var(a:buffer, 'cpp_clangtidy_options') \ : '' - return ale#Escape(ale_linters#cpp#clangtidy#GetExecutable(a:buffer)) + return '%e' \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') \ . ' %s' \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') @@ -51,7 +29,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#cpp#clangtidy#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'), \ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/cpp/clazy.vim b/sources_non_forked/ale/ale_linters/cpp/clazy.vim new file mode 100644 index 00000000..cbbd0ccf --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clazy.vim @@ -0,0 +1,32 @@ +" Description: clazy linter for cpp files (clang-based and Qt-oriented) + +call ale#Set('cpp_clazy_executable', 'clazy-standalone') +" Set this option to check the checks clazy will apply. +call ale#Set('cpp_clazy_checks', ['level1']) +" Set this option to manually set some options for clazy. +" This will disable compile_commands.json detection. +call ale#Set('cpp_clazy_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cpp#clazy#GetCommand(buffer) abort + let l:checks = join(ale#Var(a:buffer, 'cpp_clazy_checks'), ',') + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + " Get the extra options if we couldn't find a build directory. + let l:options = ale#Var(a:buffer, 'cpp_clazy_options') + + return '%e' + \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clazy', +\ 'output_stream': 'stderr', +\ 'executable_callback': ale#VarFunc('cpp_clazy_executable'), +\ 'command_callback': 'ale_linters#cpp#clazy#GetCommand', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim index 8b2aa802..229d6133 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -4,10 +4,6 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck') call ale#Set('cpp_cppcheck_options', '--enable=style') -function! ale_linters#cpp#cppcheck#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_cppcheck_executable') -endfunction - function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort " Search upwards from the file for compile_commands.json. " @@ -23,8 +19,7 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort \ : '' return l:cd_command - \ . ale#Escape(ale_linters#cpp#cppcheck#GetExecutable(a:buffer)) - \ . ' -q --language=c++ ' + \ . '%e -q --language=c++ ' \ . l:compile_commands_option \ . ale#Var(a:buffer, 'cpp_cppcheck_options') \ . ' %t' @@ -33,7 +28,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable_callback': 'ale_linters#cpp#cppcheck#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'), \ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand', \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cpplint.vim b/sources_non_forked/ale/ale_linters/cpp/cpplint.vim index 346ac815..d135fa79 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cpplint.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cpplint.vim @@ -4,22 +4,16 @@ call ale#Set('cpp_cpplint_executable', 'cpplint') call ale#Set('cpp_cpplint_options', '') -function! ale_linters#cpp#cpplint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_cpplint_executable') -endfunction - function! ale_linters#cpp#cpplint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'cpp_cpplint_options') - return ale#Escape(ale_linters#cpp#cpplint#GetExecutable(a:buffer)) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' %s' + return '%e' . ale#Pad(l:options) . ' %s' endfunction call ale#linter#Define('cpp', { \ 'name': 'cpplint', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#cpp#cpplint#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'), \ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand', \ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/cpp/cquery.vim b/sources_non_forked/ale/ale_linters/cpp/cquery.vim index 7997c843..b1c81989 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cquery.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cquery.vim @@ -7,18 +7,13 @@ call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery')) function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + if empty(l:project_root) + let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery') + endif + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' 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 return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')} endfunction @@ -26,8 +21,8 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cquery', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#cpp#cquery#GetExecutable', -\ 'command_callback': 'ale_linters#cpp#cquery#GetCommand', +\ 'executable_callback': ale#VarFunc('cpp_cquery_executable'), +\ 'command': '%e', \ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot', \ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim index 5a7092cf..4f669bff 100644 --- a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim +++ b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim @@ -6,17 +6,11 @@ call ale#Set('cpp_flawfinder_options', '') call ale#Set('cpp_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) -function! ale_linters#cpp#flawfinder#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_flawfinder_executable') -endfunction - function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort - " Set the minimum vulnerability level for flawfinder to bother with let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') - return ale#Escape(ale_linters#cpp#flawfinder#GetExecutable(a:buffer)) - \ . ' -CDQS' + return '%e -CDQS' \ . ale#Var(a:buffer, 'cpp_flawfinder_options') \ . l:minlevel \ . ' %t' @@ -25,7 +19,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'flawfinder', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#cpp#flawfinder#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'), \ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand', \ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/gcc.vim b/sources_non_forked/ale/ale_linters/cpp/gcc.vim index 17f5acf5..9935b0bb 100644 --- a/sources_non_forked/ale/ale_linters/cpp/gcc.vim +++ b/sources_non_forked/ale/ale_linters/cpp/gcc.vim @@ -4,17 +4,12 @@ call ale#Set('cpp_gcc_executable', 'gcc') call ale#Set('cpp_gcc_options', '-std=c++14 -Wall') -function! ale_linters#cpp#gcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cpp_gcc_executable') -endfunction - function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort let l:cflags = ale#c#GetCFlags(a:buffer, a:output) " -iquote with the directory the file is in makes #include work for " headers in the same directory. - return ale#Escape(ale_linters#cpp#gcc#GetExecutable(a:buffer)) - \ . ' -S -x c++ -fsyntax-only' + return '%e -S -x c++ -fsyntax-only' \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ale#Pad(l:cflags) \ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -' @@ -24,7 +19,7 @@ call ale#linter#Define('cpp', { \ 'name': 'gcc', \ 'aliases': ['g++'], \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('cpp_gcc_executable'), \ 'command_chain': [ \ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#cpp#gcc#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index a16dfde2..6f8bef68 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -4,21 +4,16 @@ call ale#Set('css_stylelint_executable', 'stylelint') call ale#Set('css_stylelint_options', '') call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#css#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'css_stylelint', [ - \ 'node_modules/.bin/stylelint', - \]) -endfunction - function! ale_linters#css#stylelint#GetCommand(buffer) abort - return ale_linters#css#stylelint#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'css_stylelint_options') + return '%e ' . ale#Pad(ale#Var(a:buffer, 'css_stylelint_options')) \ . ' --stdin-filename %s' endfunction call ale#linter#Define('css', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#css#stylelint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('css_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), \ 'command_callback': 'ale_linters#css#stylelint#GetCommand', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim index 3764fe9d..a3678910 100644 --- a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim +++ b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim @@ -4,20 +4,15 @@ call ale#Set('cuda_nvcc_executable', 'nvcc') call ale#Set('cuda_nvcc_options', '-std=c++11') -function! ale_linters#cuda#nvcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'cuda_nvcc_executable') -endfunction - function! ale_linters#cuda#nvcc#GetCommand(buffer) abort " Unused: use ale#util#nul_file " let l:output_file = ale#util#Tempname() . '.ii' " call ale#engine#ManageFile(a:buffer, l:output_file) - return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer)) - \ . ' -cuda ' - \ . ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) - \ . ale#Var(a:buffer, 'cuda_nvcc_options') . ' %s' - \ . ' -o ' . g:ale#util#nul_file + return '%e -cuda' + \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) + \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) + \ . ' %s -o ' . g:ale#util#nul_file endfunction function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort @@ -49,7 +44,7 @@ endfunction call ale#linter#Define('cuda', { \ 'name': 'nvcc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#cuda#nvcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'), \ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand', \ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim b/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim index ef33c9d4..26817df5 100644 --- a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim +++ b/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim @@ -3,15 +3,10 @@ call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer') -function! ale_linters#dart#dartanalyzer#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'dart_dartanalyzer_executable') -endfunction - function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort - let l:executable = ale_linters#dart#dartanalyzer#GetExecutable(a:buffer) let l:path = ale#path#FindNearestFile(a:buffer, '.packages') - return ale#Escape(l:executable) + return '%e' \ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '') \ . ' %s' endfunction @@ -34,7 +29,7 @@ endfunction call ale#linter#Define('dart', { \ 'name': 'dartanalyzer', -\ 'executable_callback': 'ale_linters#dart#dartanalyzer#GetExecutable', +\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'), \ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand', \ 'callback': 'ale_linters#dart#dartanalyzer#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/dart/language_server.vim b/sources_non_forked/ale/ale_linters/dart/language_server.vim index 2265e37a..14b6ab93 100644 --- a/sources_non_forked/ale/ale_linters/dart/language_server.vim +++ b/sources_non_forked/ale/ale_linters/dart/language_server.vim @@ -3,10 +3,6 @@ call ale#Set('dart_language_server_executable', 'dart_language_server') -function! ale_linters#dart#language_server#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'dart_language_server_executable') -endfunction - function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort " Note: pub only looks for pubspec.yaml, there's no point in adding " support for pubspec.yml @@ -18,7 +14,7 @@ endfunction call ale#linter#Define('dart', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#dart#language_server#GetExecutable', +\ 'executable_callback': ale#VarFunc('dart_language_server_executable'), \ 'command_callback': 'ale_linters#dart#language_server#GetExecutable', \ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index 8231ad47..ddea983f 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -4,12 +4,6 @@ call ale#Set('elm_make_executable', 'elm') call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#elm#make#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'elm_make', [ - \ 'node_modules/.bin/elm', - \]) -endfunction - function! ale_linters#elm#make#Handle(buffer, lines) abort let l:output = [] let l:unparsed_lines = [] @@ -147,7 +141,6 @@ endfunction " If it doesn't, then this will fail when imports are needed. function! ale_linters#elm#make#GetCommand(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') - let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer) if empty(l:elm_json) " Fallback to Elm 0.18 @@ -165,18 +158,15 @@ function! ale_linters#elm#make#GetCommand(buffer) abort " a sort of flag to tell the compiler not to generate an output file, " which is why this is hard coded here. " Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 - let l:elm_cmd = ale#Escape(l:elm_exe) - \ . ' make' - \ . ' --report=json' - \ . ' --output=/dev/null' - - return l:dir_set_cmd . ' ' . l:elm_cmd . ' %t' + return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t' endfunction call ale#linter#Define('elm', { -\ 'name': 'make', -\ 'executable_callback': 'ale_linters#elm#make#GetExecutable', -\ 'output_stream': 'both', -\ 'command_callback': 'ale_linters#elm#make#GetCommand', -\ 'callback': 'ale_linters#elm#make#Handle' +\ 'name': 'make', +\ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [ +\ 'node_modules/.bin/elm', +\ ]), +\ 'output_stream': 'both', +\ 'command_callback': 'ale_linters#elm#make#GetCommand', +\ 'callback': 'ale_linters#elm#make#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim index 46ecdcb7..5b679743 100644 --- a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim +++ b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim @@ -3,24 +3,12 @@ call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') - -function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'erlang_syntaxerl_executable') -endfunction - - -function! ale_linters#erlang#syntaxerl#FeatureCheck(buffer) abort - return s:GetEscapedExecutable(a:buffer) . ' -h' -endfunction - - function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1 - return s:GetEscapedExecutable(a:buffer) . (l:use_b_option ? ' -b %s %t' : ' %t') + return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t') endfunction - function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort let l:pattern = '\v\C:(\d+):( warning:)? (.+)' let l:loclist = [] @@ -36,17 +24,11 @@ function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort return l:loclist endfunction - -function! s:GetEscapedExecutable(buffer) abort - return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer)) -endfunction - - call ale#linter#Define('erlang', { \ 'name': 'syntaxerl', -\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable', +\ 'executable_callback': ale#VarFunc('erlang_syntaxerl_executable'), \ 'command_chain': [ -\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'}, +\ {'callback': {-> '%e -h'}}, \ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'}, \ ], \ 'callback': 'ale_linters#erlang#syntaxerl#Handle', diff --git a/sources_non_forked/ale/ale_linters/fortran/gcc.vim b/sources_non_forked/ale/ale_linters/fortran/gcc.vim index 5f2ac018..f1595789 100644 --- a/sources_non_forked/ale/ale_linters/fortran/gcc.vim +++ b/sources_non_forked/ale/ale_linters/fortran/gcc.vim @@ -2,18 +2,10 @@ " Description: gcc for Fortran files " This option can be set to 0 to use -ffixed-form -if !exists('g:ale_fortran_gcc_use_free_form') - let g:ale_fortran_gcc_use_free_form = 1 -endif - -if !exists('g:ale_fortran_gcc_executable') - let g:ale_fortran_gcc_executable = 'gcc' -endif - +call ale#Set('fortran_gcc_use_free_form', 1) +call ale#Set('fortran_gcc_executable', 'gcc') " Set this option to change the GCC options for warnings for Fortran. -if !exists('g:ale_fortran_gcc_options') - let g:ale_fortran_gcc_options = '-Wall' -endif +call ale#Set('fortran_gcc_options', '-Wall') function! ale_linters#fortran#gcc#Handle(buffer, lines) abort " We have to match a starting line and a later ending line together, @@ -61,26 +53,20 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#fortran#gcc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'fortran_gcc_executable') -endfunction - function! ale_linters#fortran#gcc#GetCommand(buffer) abort let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form') \ ? '-ffree-form' \ : '-ffixed-form' - return ale_linters#fortran#gcc#GetExecutable(a:buffer) - \ . ' -S -x f95 -fsyntax-only ' - \ . l:layout_option . ' ' - \ . ale#Var(a:buffer, 'fortran_gcc_options') . ' ' - \ . '-' + return '%e -S -x f95 -fsyntax-only ' . l:layout_option + \ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options')) + \ . ' -' endfunction call ale#linter#Define('fortran', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#fortran#gcc#GetExecutable', +\ 'executable_callback': ale#VarFunc('fortran_gcc_executable'), \ 'command_callback': 'ale_linters#fortran#gcc#GetCommand', \ 'callback': 'ale_linters#fortran#gcc#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/fortran/language_server.vim b/sources_non_forked/ale/ale_linters/fortran/language_server.vim index fd763fcf..4e5f5dc4 100644 --- a/sources_non_forked/ale/ale_linters/fortran/language_server.vim +++ b/sources_non_forked/ale/ale_linters/fortran/language_server.vim @@ -4,14 +4,6 @@ call ale#Set('fortran_language_server_executable', 'fortls') call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#fortran#language_server#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'fortran_language_server_executable') -endfunction - -function! ale_linters#fortran#language_server#GetCommand(buffer) abort - return ale#Escape(ale_linters#fortran#language_server#GetExecutable(a:buffer)) -endfunction - function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls') @@ -21,7 +13,7 @@ endfunction call ale#linter#Define('fortran', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#fortran#language_server#GetExecutable', -\ 'command_callback': 'ale_linters#fortran#language_server#GetCommand', +\ 'executable_callback': ale#VarFunc('fortran_language_server_executable'), +\ 'command': '%e', \ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim b/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim index cf20e1b4..ab8f143b 100644 --- a/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim +++ b/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim @@ -4,13 +4,8 @@ call ale#Set('fuse_fusionlint_executable', 'fusion-lint') call ale#Set('fuse_fusionlint_options', '') -function! ale_linters#fuse#fusionlint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'fuse_fusionlint_executable') -endfunction - function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort - return ale#Escape(ale_linters#fuse#fusionlint#GetExecutable(a:buffer)) - \ . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options')) + return '%e' . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options')) \ . ' --filename %s -i' endfunction @@ -32,7 +27,7 @@ endfunction call ale#linter#Define('fuse', { \ 'name': 'fusionlint', -\ 'executable_callback': 'ale_linters#fuse#fusionlint#GetExecutable', +\ 'executable_callback': ale#VarFunc('fuse_fusionlint_executable'), \ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand', \ 'callback': 'ale_linters#fuse#fusionlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim index 64731055..ec3bfb0b 100644 --- a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim +++ b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim @@ -1,11 +1,9 @@ " Author: Nick Yamane " Description: gitlint for git commit message files -let g:ale_gitcommit_gitlint_executable = -\ get(g:, 'ale_gitcommit_gitlint_executable', 'gitlint') -let g:ale_gitcommit_gitlint_options = get(g:, 'ale_gitcommit_gitlint_options', '') -let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0)) - +call ale#Set('gitcommit_gitlint_executable', 'gitlint') +call ale#Set('gitcommit_gitlint_options', '') +call ale#Set('gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint']) @@ -13,12 +11,9 @@ endfunction function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options') - let l:executable = ale_linters#gitcommit#gitlint#GetExecutable(a:buffer) - return ale#Escape(l:executable) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' lint' -endfunction + return '%e' . ale#Pad(l:options) . ' lint' +endfunction function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort " Matches patterns line the following: @@ -45,7 +40,6 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort return l:output endfunction - call ale#linter#Define('gitcommit', { \ 'name': 'gitlint', \ 'output_stream': 'stderr', @@ -53,4 +47,3 @@ call ale#linter#Define('gitcommit', { \ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand', \ 'callback': 'ale_linters#gitcommit#gitlint#Handle', \}) - diff --git a/sources_non_forked/ale/ale_linters/glsl/glslang.vim b/sources_non_forked/ale/ale_linters/glsl/glslang.vim index d494df0e..d55a5e7c 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslang.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslang.vim @@ -4,17 +4,11 @@ " TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted, " we can use stdin. -let g:ale_glsl_glslang_executable = -\ get(g:, 'ale_glsl_glslang_executable', 'glslangValidator') - -let g:ale_glsl_glslang_options = get(g:, 'ale_glsl_glslang_options', '') - -function! ale_linters#glsl#glslang#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'glsl_glslang_executable') -endfunction +call ale#Set('glsl_glslang_executable', 'glslangValidator') +call ale#Set('glsl_glslang_options', '') function! ale_linters#glsl#glslang#GetCommand(buffer) abort - return ale#Escape(ale_linters#glsl#glslang#GetExecutable(a:buffer)) + return '%e' \ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options')) \ . ' -C %t' endfunction @@ -40,7 +34,7 @@ endfunction call ale#linter#Define('glsl', { \ 'name': 'glslang', -\ 'executable_callback': 'ale_linters#glsl#glslang#GetExecutable', +\ 'executable_callback': ale#VarFunc('glsl_glslang_executable'), \ 'command_callback': 'ale_linters#glsl#glslang#GetCommand', \ 'callback': 'ale_linters#glsl#glslang#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/glsl/glslls.vim b/sources_non_forked/ale/ale_linters/glsl/glslls.vim index 77e30f9c..8c6d9bd9 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslls.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslls.vim @@ -4,18 +4,15 @@ call ale#Set('glsl_glslls_executable', 'glslls') call ale#Set('glsl_glslls_logfile', '') -function! ale_linters#glsl#glslls#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'glsl_glslls_executable') -endfunction - function! ale_linters#glsl#glslls#GetCommand(buffer) abort - let l:executable = ale_linters#glsl#glslls#GetExecutable(a:buffer) let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile') let l:logfile_args = '' + if l:logfile isnot# '' let l:logfile_args = ' --verbose -l ' . l:logfile endif - return ale#Escape(l:executable) . l:logfile_args . ' --stdin' + + return '%e' . l:logfile_args . ' --stdin' endfunction function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort @@ -27,7 +24,7 @@ endfunction call ale#linter#Define('glsl', { \ 'name': 'glslls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable', +\ 'executable_callback': ale#VarFunc('glsl_glslls_executable'), \ 'command_callback': 'ale_linters#glsl#glslls#GetCommand', \ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/go/gobuild.vim b/sources_non_forked/ale/ale_linters/go/gobuild.vim index c4608071..2d6febdd 100644 --- a/sources_non_forked/ale/ale_linters/go/gobuild.vim +++ b/sources_non_forked/ale/ale_linters/go/gobuild.vim @@ -5,35 +5,11 @@ call ale#Set('go_gobuild_options', '') -function! ale_linters#go#gobuild#ResetEnv() abort - unlet! s:go_env -endfunction - -function! ale_linters#go#gobuild#GoEnv(buffer) abort - if exists('s:go_env') - return '' - endif - - return 'go env GOPATH GOROOT' -endfunction - -function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort +function! ale_linters#go#gobuild#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_gobuild_options') - if !exists('s:go_env') - let s:go_env = { - \ 'GOPATH': a:goenv_output[0], - \ 'GOROOT': a:goenv_output[1], - \} - endif - - let l:gopath_env_command = has('win32') - \ ? 'set GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' && ' - \ : 'GOPATH=' . ale#Escape(s:go_env.GOPATH) . ' ' - " Run go test in local directory with relative path - return l:gopath_env_command - \ . ale#path#BufferCdString(a:buffer) + return ale#path#BufferCdString(a:buffer) \ . 'go test' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -c -o /dev/null ./' @@ -73,10 +49,8 @@ call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], \ 'executable': 'go', -\ 'command_chain': [ -\ {'callback': 'ale_linters#go#gobuild#GoEnv', 'output_stream': 'stdout'}, -\ {'callback': 'ale_linters#go#gobuild#GetCommand', 'output_stream': 'stderr'}, -\ ], +\ 'command_callback': 'ale_linters#go#gobuild#GetCommand', +\ 'output_stream': 'stderr', \ 'callback': 'ale_linters#go#gobuild#Handler', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/go/gometalinter.vim b/sources_non_forked/ale/ale_linters/go/gometalinter.vim index 375a8b0f..d005e1d2 100644 --- a/sources_non_forked/ale/ale_linters/go/gometalinter.vim +++ b/sources_non_forked/ale/ale_linters/go/gometalinter.vim @@ -5,12 +5,7 @@ call ale#Set('go_gometalinter_options', '') call ale#Set('go_gometalinter_executable', 'gometalinter') call ale#Set('go_gometalinter_lint_package', 0) -function! ale_linters#go#gometalinter#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'go_gometalinter_executable') -endfunction - function! ale_linters#go#gometalinter#GetCommand(buffer) abort - let l:executable = ale_linters#go#gometalinter#GetExecutable(a:buffer) let l:filename = expand('#' . a:buffer . ':t') let l:options = ale#Var(a:buffer, 'go_gometalinter_options') let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package') @@ -19,12 +14,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort " be calculated to absolute paths in the Handler if l:lint_package return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endif return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ . '%e' \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename)) \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endfunction @@ -55,7 +50,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gometalinter', -\ 'executable_callback': 'ale_linters#go#gometalinter#GetExecutable', +\ 'executable_callback': ale#VarFunc('go_gometalinter_executable'), \ 'command_callback': 'ale_linters#go#gometalinter#GetCommand', \ 'callback': 'ale_linters#go#gometalinter#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/govet.vim b/sources_non_forked/ale/ale_linters/go/govet.vim index e94e6ecd..59fea499 100644 --- a/sources_non_forked/ale/ale_linters/go/govet.vim +++ b/sources_non_forked/ale/ale_linters/go/govet.vim @@ -4,8 +4,12 @@ " Author: John Eikenberry " Description: updated to work with go1.10 +call ale#Set('go_govet_options', '') + function! ale_linters#go#govet#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_govet_options') return ale#path#BufferCdString(a:buffer) . ' go vet .' + \ . (!empty(l:options) ? ' ' . l:options : '') endfunction call ale#linter#Define('go', { diff --git a/sources_non_forked/ale/ale_linters/hack/hack.vim b/sources_non_forked/ale/ale_linters/hack/hack.vim new file mode 100644 index 00000000..aea428cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/hack/hack.vim @@ -0,0 +1,22 @@ +" Author: Fred Emmott +" Description: Hack support via `hack lsp` + +call ale#Set('hack_hack_executable', 'hh_client') + +function! ale_linters#hack#hack#GetProjectRoot(buffer) abort + let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') + + return !empty(l:hhconfig) ? fnamemodify(l:hhconfig, ':h') : '' +endfunction + +function! ale_linters#hack#hack#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'hack_hack_executable') +endfunction + +call ale#linter#Define('hack', { +\ 'name': 'hack', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable', +\ 'command': '%e lsp --from vim-ale', +\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot', +\}) diff --git a/sources_non_forked/ale/ale_linters/hack/hhast.vim b/sources_non_forked/ale/ale_linters/hack/hhast.vim new file mode 100644 index 00000000..710b7b25 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/hack/hhast.vim @@ -0,0 +1,40 @@ +" Author: Fred Emmott +" Description: Hack support via `hhast lsp` + +call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint') + +function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort + " Find the hack root, then figure out if it's also an HHAST root. + " Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json + let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') + + if empty(l:hhconfig) + return '' + endif + + let l:root = fnamemodify(l:hhconfig, ':h') + let l:hhast_config = findfile('hhast-lint.json', l:root) + + return !empty(l:hhast_config) ? l:root : '' +endfunction + +function! ale_linters#hack#hhast#GetExecutable(buffer) abort + let l:root = ale_linters#hack#hhast#GetProjectRoot(a:buffer) + let l:relative = ale#Var(a:buffer, 'hack_hhast_executable') + let l:absolute = findfile(l:relative, l:root) + + return !empty(l:absolute) ? l:absolute : '' +endfunction + +function! ale_linters#hack#hhast#GetInitializationOptions(buffer) abort + return {'lintMode': 'open-files'} +endfunction + +call ale#linter#Define('hack', { +\ 'name': 'hhast', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable', +\ 'command': '%e --mode lsp --from vim-ale', +\ 'project_root_callback': 'ale_linters#hack#hhast#GetProjectRoot', +\ 'initialization_options_callback': 'ale_linters#hack#hhast#GetInitializationOptions', +\}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 162a033c..4fc0f20d 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -4,17 +4,6 @@ call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ - \ 'node_modules/.bin/ember-template-lint', - \]) -endfunction - -function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer) abort - return ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer) - \ . ' --json %t' -endfunction - function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort let l:output = [] let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) @@ -42,7 +31,9 @@ endfunction call ale#linter#Define('handlebars', { \ 'name': 'ember-template-lint', -\ 'executable_callback': 'ale_linters#handlebars#embertemplatelint#GetExecutable', -\ 'command_callback': 'ale_linters#handlebars#embertemplatelint#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('handlebars_embertemplatelint', [ +\ 'node_modules/.bin/ember-template-lint', +\ ]), +\ 'command': '%e --json %t', \ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim index dc902152..fbd5278e 100644 --- a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim +++ b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim @@ -4,19 +4,14 @@ call ale#Set('haskell_hdevtools_executable', 'hdevtools') call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall')) -function! ale_linters#haskell#hdevtools#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'haskell_hdevtools_executable') -endfunction - function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort - return ale#Escape(ale_linters#haskell#hdevtools#GetExecutable(a:buffer)) - \ . ' check ' . ale#Var(a:buffer, 'haskell_hdevtools_options') - \ . ' -p %s %t' + return '%e check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options')) + \ . ' -p %s %t' endfunction call ale#linter#Define('haskell', { \ 'name': 'hdevtools', -\ 'executable_callback': 'ale_linters#haskell#hdevtools#GetExecutable', +\ 'executable_callback': ale#VarFunc('haskell_hdevtools_executable'), \ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand', \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hie.vim b/sources_non_forked/ale/ale_linters/haskell/hie.vim new file mode 100644 index 00000000..558d36a3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hie.vim @@ -0,0 +1,44 @@ +" Author: Luxed +" Description: A language server for Haskell + +call ale#Set('haskell_hie_executable', 'hie') + +function! ale_linters#haskell#hie#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'haskell_hie_executable') +endfunction + +function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort + " Search for the stack file first + let l:project_file = ale#path#FindNearestFile(a:buffer, 'stack.yaml') + + " If it's empty, search for the cabal file + if empty(l:project_file) + let l:cabal_file = fnamemodify(bufname(a:buffer), ':p:h') + let l:paths = '' + + while empty(matchstr(l:cabal_file, '^\(\/\|\(\w:\\\)\)$')) + let l:cabal_file = fnamemodify(l:cabal_file, ':h') + let l:paths = l:paths . l:cabal_file . ',' + endwhile + + let l:project_file = globpath(l:paths, '*.cabal') + endif + + " Either extract the project directory or take the current working + " directory + if !empty(l:project_file) + let l:project_file = fnamemodify(l:project_file, ':h') + else + let l:project_file = expand('#' . a:buffer . ':p:h') + endif + + return l:project_file +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hie', +\ 'lsp': 'stdio', +\ 'command': '%e --lsp', +\ 'executable_callback': 'ale_linters#haskell#hie#GetExecutable', +\ 'project_root_callback': 'ale_linters#haskell#hie#GetProjectRoot', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim index caa15bbb..234c1176 100644 --- a/sources_non_forked/ale/ale_linters/html/htmlhint.vim +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -5,12 +5,6 @@ call ale#Set('html_htmlhint_options', '') call ale#Set('html_htmlhint_executable', 'htmlhint') call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#html#htmlhint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [ - \ 'node_modules/.bin/htmlhint', - \]) -endfunction - function! ale_linters#html#htmlhint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'html_htmlhint_options') let l:config = l:options !~# '--config' @@ -25,14 +19,14 @@ function! ale_linters#html#htmlhint#GetCommand(buffer) abort let l:options = substitute(l:options, '--format=unix', '', '') endif - return ale#Escape(ale_linters#html#htmlhint#GetExecutable(a:buffer)) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --format=unix %t' + return '%e' . ale#Pad(l:options) . ' --format=unix %t' endfunction call ale#linter#Define('html', { \ 'name': 'htmlhint', -\ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('html_htmlhint', [ +\ 'node_modules/.bin/htmlhint', +\ ]), \ 'command_callback': 'ale_linters#html#htmlhint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/sources_non_forked/ale/ale_linters/html/stylelint.vim b/sources_non_forked/ale/ale_linters/html/stylelint.vim new file mode 100644 index 00000000..908c4b02 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -0,0 +1,27 @@ +" Author: Filipe Kiss http://github.com/filipekiss + +call ale#Set('html_stylelint_executable', 'stylelint') +call ale#Set('html_stylelint_options', '') +call ale#Set('html_stylelint_use_global', 0) + +function! ale_linters#html#stylelint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'html_stylelint', [ + \ 'node_modules/.bin/stylelint', + \]) +endfunction + +function! ale_linters#html#stylelint#GetCommand(buffer) abort + let l:executable = ale_linters#html#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'html_stylelint_options') + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'stylelint', +\ 'executable_callback': 'ale_linters#html#stylelint#GetExecutable', +\ 'command_callback': 'ale_linters#html#stylelint#GetCommand', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/tidy.vim b/sources_non_forked/ale/ale_linters/html/tidy.vim index 913cdade..cab8bc24 100644 --- a/sources_non_forked/ale/ale_linters/html/tidy.vim +++ b/sources_non_forked/ale/ale_linters/html/tidy.vim @@ -37,10 +37,6 @@ function! ale_linters#html#tidy#GetCommand(buffer) abort \) endfunction -function! ale_linters#html#tidy#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'html_tidy_executable') -endfunction - function! ale_linters#html#tidy#Handle(buffer, lines) abort " Matches patterns lines like the following: " line 7 column 5 - Warning: missing before @@ -67,7 +63,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'tidy', -\ 'executable_callback': 'ale_linters#html#tidy#GetExecutable', +\ 'executable_callback': ale#VarFunc('html_tidy_executable'), \ 'output_stream': 'stderr', \ 'command_callback': 'ale_linters#html#tidy#GetCommand', \ 'callback': 'ale_linters#html#tidy#Handle', diff --git a/sources_non_forked/ale/ale_linters/idris/idris.vim b/sources_non_forked/ale/ale_linters/idris/idris.vim index 115d04fc..b3275b40 100644 --- a/sources_non_forked/ale/ale_linters/idris/idris.vim +++ b/sources_non_forked/ale/ale_linters/idris/idris.vim @@ -4,16 +4,10 @@ call ale#Set('idris_idris_executable', 'idris') call ale#Set('idris_idris_options', '--total --warnpartial --warnreach --warnipkg') -function! ale_linters#idris#idris#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'idris_idris_executable') -endfunction - function! ale_linters#idris#idris#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'idris_idris_options') - return ale#Escape(ale_linters#idris#idris#GetExecutable(a:buffer)) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --check %s' + return '%e' . ale#Pad(l:options) . ' --check %s' endfunction function! ale_linters#idris#idris#Handle(buffer, lines) abort @@ -80,8 +74,7 @@ endfunction call ale#linter#Define('idris', { \ 'name': 'idris', -\ 'executable_callback': 'ale_linters#idris#idris#GetExecutable', +\ 'executable_callback': ale#VarFunc('idris_idris_executable'), \ 'command_callback': 'ale_linters#idris#idris#GetCommand', \ 'callback': 'ale_linters#idris#idris#Handle', \}) - diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index d7a39aa7..76445c18 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -36,10 +36,6 @@ function! s:BuildClassPathOption(buffer, import_paths) abort \ : '' endfunction -function! ale_linters#java#javac#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'java_javac_executable') -endfunction - function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths) let l:sp_option = '' @@ -77,13 +73,11 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort " Create .class files in a temporary directory, which we will delete later. let l:class_file_directory = ale#engine#CreateDirectory(a:buffer) - let l:executable = ale_linters#java#javac#GetExecutable(a:buffer) " Always run javac from the directory the file is in, so we can resolve " relative paths correctly. return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) - \ . ' -Xlint' + \ . '%e -Xlint' \ . ale#Pad(l:cp_option) \ . ale#Pad(l:sp_option) \ . ' -d ' . ale#Escape(l:class_file_directory) @@ -126,7 +120,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javac', -\ 'executable_callback': 'ale_linters#java#javac#GetExecutable', +\ 'executable_callback': ale#VarFunc('java_javac_executable'), \ 'command_chain': [ \ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'}, \ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'}, diff --git a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim index 20fc2217..75377183 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim @@ -6,18 +6,6 @@ call ale#Set('javascript_flow_ls_use_global', \ get(g:, 'ale_use_global_executables', 0) \) -function! ale_linters#javascript#flow_ls#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_flow_ls', [ - \ 'node_modules/.bin/flow', - \]) -endfunction - -function! ale_linters#javascript#flow_ls#GetCommand(buffer) abort - let l:executable = ale_linters#javascript#flow_ls#GetExecutable(a:buffer) - - return ale#Escape(l:executable) . ' lsp --from ale-lsp' -endfunction - function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') @@ -31,8 +19,10 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'flow-language-server', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#javascript#flow_ls#GetExecutable', -\ 'command_callback': 'ale_linters#javascript#flow_ls#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('javascript_flow_ls', [ +\ 'node_modules/.bin/flow', +\ ]), +\ 'command': '%e lsp --from ale-lsp', \ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot', \ 'language': 'javascript', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/jscs.vim b/sources_non_forked/ale/ale_linters/javascript/jscs.vim index 60044037..a38766a6 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jscs.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -4,12 +4,6 @@ call ale#Set('javascript_jscs_executable', 'jscs') call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#javascript#jscs#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_jscs', [ - \ 'node_modules/.bin/jscs', - \]) -endfunction - function! ale_linters#javascript#jscs#GetCommand(buffer) abort " Search for a local JShint config locaation, and default to a global one. let l:jscs_config = ale#path#ResolveLocalPath( @@ -18,8 +12,7 @@ function! ale_linters#javascript#jscs#GetCommand(buffer) abort \ get(g:, 'ale_jscs_config_loc', '') \) - let l:command = ale#Escape(ale_linters#javascript#jscs#GetExecutable(a:buffer)) - let l:command .= ' --reporter inline --no-colors' + let l:command = '%e --reporter inline --no-colors' if !empty(l:jscs_config) let l:command .= ' --config ' . ale#Escape(l:jscs_config) @@ -60,8 +53,9 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jscs', -\ 'executable_callback': 'ale_linters#javascript#jscs#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jscs', [ +\ 'node_modules/.bin/jscs', +\ ]), \ 'command_callback': 'ale_linters#javascript#jscs#GetCommand', \ 'callback': 'ale_linters#javascript#jscs#Handle', \}) - diff --git a/sources_non_forked/ale/ale_linters/javascript/jshint.vim b/sources_non_forked/ale/ale_linters/javascript/jshint.vim index 2e9bb9fd..83909fa4 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jshint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -4,12 +4,6 @@ call ale#Set('javascript_jshint_executable', 'jshint') call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#javascript#jshint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [ - \ 'node_modules/.bin/jshint', - \]) -endfunction - function! ale_linters#javascript#jshint#GetCommand(buffer) abort " Search for a local JShint config locaation, and default to a global one. let l:jshint_config = ale#path#ResolveLocalPath( @@ -18,8 +12,7 @@ function! ale_linters#javascript#jshint#GetCommand(buffer) abort \ get(g:, 'ale_jshint_config_loc', '') \) - let l:command = ale#Escape(ale_linters#javascript#jshint#GetExecutable(a:buffer)) - let l:command .= ' --reporter unix --extract auto' + let l:command = '%e --reporter unix --extract auto' if !empty(l:jshint_config) let l:command .= ' --config ' . ale#Escape(l:jshint_config) @@ -32,7 +25,9 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jshint', -\ 'executable_callback': 'ale_linters#javascript#jshint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jshint', [ +\ 'node_modules/.bin/jshint', +\ ]), \ 'command_callback': 'ale_linters#javascript#jshint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim index 62dded10..6cf08dd6 100644 --- a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim @@ -5,22 +5,13 @@ call ale#Set('javascript_tsserver_executable', 'tsserver') call ale#Set('javascript_tsserver_config_path', '') call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) -" These functions need to be defined just to comply with the API for LSP. -function! ale_linters#javascript#tsserver#GetProjectRoot(buffer) abort - return '' -endfunction - -function! ale_linters#javascript#tsserver#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_tsserver', [ - \ 'node_modules/.bin/tsserver', - \]) -endfunction - call ale#linter#Define('javascript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable_callback': 'ale_linters#javascript#tsserver#GetExecutable', -\ 'command_callback': 'ale_linters#javascript#tsserver#GetExecutable', -\ 'project_root_callback': 'ale_linters#javascript#tsserver#GetProjectRoot', +\ 'executable_callback': ale#node#FindExecutableFunc('javascript_tsserver', [ +\ 'node_modules/.bin/tsserver', +\ ]), +\ 'command': '%e', +\ 'project_root_callback': {-> ''}, \ 'language': '', \}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim index 0ab673ec..aea817ba 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim @@ -3,15 +3,6 @@ call ale#Set('kotlin_languageserver_executable', 'kotlin-language-server') -function! ale_linters#kotlin#languageserver#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'kotlin_languageserver_executable') -endfunction - -function! ale_linters#kotlin#languageserver#GetCommand(buffer) abort - let l:executable = ale_linters#kotlin#languageserver#GetExecutable(a:buffer) - return ale#Escape(l:executable) -endfunction - function! ale_linters#kotlin#languageserver#GetProjectRoot(buffer) abort let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) @@ -31,8 +22,8 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#kotlin#languageserver#GetExecutable', -\ 'command_callback': 'ale_linters#kotlin#languageserver#GetCommand', +\ 'executable_callback': ale#VarFunc('kotlin_languageserver_executable'), +\ 'command': '%e', \ 'language': 'kotlin', \ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/less/lessc.vim b/sources_non_forked/ale/ale_linters/less/lessc.vim index 5fd9a383..37600649 100644 --- a/sources_non_forked/ale/ale_linters/less/lessc.vim +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -5,21 +5,10 @@ call ale#Set('less_lessc_executable', 'lessc') call ale#Set('less_lessc_options', '') call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#less#lessc#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'less_lessc', [ - \ 'node_modules/.bin/lessc', - \]) -endfunction - function! ale_linters#less#lessc#GetCommand(buffer) abort - let l:executable = ale_linters#less#lessc#GetExecutable(a:buffer) - let l:dir = expand('#' . a:buffer . ':p:h') - let l:options = ale#Var(a:buffer, 'less_lessc_options') - - return ale#Escape(l:executable) - \ . ' --no-color --lint' - \ . ' --include-path=' . ale#Escape(l:dir) - \ . (!empty(l:options) ? ' ' . l:options : '') + return '%e --no-color --lint' + \ . ' --include-path=' . ale#Escape(expand('#' . a:buffer . ':p:h')) + \ . ale#Pad(ale#Var(a:buffer, 'less_lessc_options')) \ . ' -' endfunction @@ -49,7 +38,9 @@ endfunction call ale#linter#Define('less', { \ 'name': 'lessc', -\ 'executable_callback': 'ale_linters#less#lessc#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('less_lessc', [ +\ 'node_modules/.bin/lessc', +\ ]), \ 'command_callback': 'ale_linters#less#lessc#GetCommand', \ 'callback': 'ale_linters#less#lessc#Handle', \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim index 8e16a098..479808c2 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -4,24 +4,17 @@ call ale#Set('less_stylelint_executable', 'stylelint') call ale#Set('less_stylelint_options', '') call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#less#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'less_stylelint', [ - \ 'node_modules/.bin/stylelint', - \]) -endfunction - function! ale_linters#less#stylelint#GetCommand(buffer) abort - let l:executable = ale_linters#less#stylelint#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'less_stylelint_options') - return ale#Escape(l:executable) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --stdin-filename %s' + return '%e' . ale#Pad(l:options) . ' --stdin-filename %s' endfunction call ale#linter#Define('less', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#less#stylelint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('less_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), \ 'command_callback': 'ale_linters#less#stylelint#GetCommand', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/llvm/llc.vim b/sources_non_forked/ale/ale_linters/llvm/llc.vim index 15201cbe..044f8c44 100644 --- a/sources_non_forked/ale/ale_linters/llvm/llc.vim +++ b/sources_non_forked/ale/ale_linters/llvm/llc.vim @@ -3,21 +3,11 @@ call ale#Set('llvm_llc_executable', 'llc') -function! ale_linters#llvm#llc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'llvm_llc_executable') -endfunction - -function! ale_linters#llvm#llc#GetCommand(buffer) abort - return ale#Escape(ale_linters#llvm#llc#GetExecutable(a:buffer)) - \ . ' -filetype=null -o=' . g:ale#util#nul_file -endfunction - function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort " Handle '{path}: {file}:{line}:{col}: error: {message}' format let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$' - let l:matches = ale#util#GetMatches(a:lines, l:pattern) - return map(l:matches, "{ + return map(ale#util#GetMatches(a:lines, l:pattern), "{ \ 'lnum': str2nr(v:val[1]), \ 'col': str2nr(v:val[2]), \ 'text': v:val[3], @@ -27,8 +17,8 @@ endfunction call ale#linter#Define('llvm', { \ 'name': 'llc', -\ 'executable_callback': 'ale_linters#llvm#llc#GetExecutable', +\ 'executable_callback': ale#VarFunc('llvm_llc_executable'), \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#llvm#llc#GetCommand', +\ 'command_callback': {-> '%e -filetype=null -o=' . g:ale#util#nul_file}, \ 'callback': 'ale_linters#llvm#llc#HandleErrors', \}) diff --git a/sources_non_forked/ale/ale_linters/lua/luac.vim b/sources_non_forked/ale/ale_linters/lua/luac.vim index 4a6bb403..bca2cd8d 100644 --- a/sources_non_forked/ale/ale_linters/lua/luac.vim +++ b/sources_non_forked/ale/ale_linters/lua/luac.vim @@ -3,15 +3,6 @@ call ale#Set('lua_luac_executable', 'luac') -function! ale_linters#lua#luac#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'lua_luac_executable') -endfunction - -function! ale_linters#lua#luac#GetCommand(buffer) abort - let l:executable = ale_linters#lua#luac#GetExecutable(a:buffer) - return ale#Escape(l:executable) . ' -p - ' -endfunction - function! ale_linters#lua#luac#Handle(buffer, lines) abort " Matches patterns line the following: " @@ -33,8 +24,8 @@ endfunction call ale#linter#Define('lua', { \ 'name': 'luac', -\ 'executable_callback': 'ale_linters#lua#luac#GetExecutable', -\ 'command_callback': 'ale_linters#lua#luac#GetCommand', +\ 'executable_callback': ale#VarFunc('lua_luac_executable'), +\ 'command': '%e -p -', \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#lua#luac#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/lua/luacheck.vim b/sources_non_forked/ale/ale_linters/lua/luacheck.vim index 725153c6..669103b8 100644 --- a/sources_non_forked/ale/ale_linters/lua/luacheck.vim +++ b/sources_non_forked/ale/ale_linters/lua/luacheck.vim @@ -1,19 +1,11 @@ " Author: Sol Bekic https://github.com/s-ol " Description: luacheck linter for lua files -let g:ale_lua_luacheck_executable = -\ get(g:, 'ale_lua_luacheck_executable', 'luacheck') - -let g:ale_lua_luacheck_options = -\ get(g:, 'ale_lua_luacheck_options', '') - -function! ale_linters#lua#luacheck#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'lua_luacheck_executable') -endfunction +call ale#Set('lua_luacheck_executable', 'luacheck') +call ale#Set('lua_luacheck_options', '') function! ale_linters#lua#luacheck#GetCommand(buffer) abort - return ale#Escape(ale_linters#lua#luacheck#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'lua_luacheck_options') + return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_luacheck_options')) \ . ' --formatter plain --codes --filename %s -' endfunction @@ -46,7 +38,7 @@ endfunction call ale#linter#Define('lua', { \ 'name': 'luacheck', -\ 'executable_callback': 'ale_linters#lua#luacheck#GetExecutable', +\ 'executable_callback': ale#VarFunc('lua_luacheck_executable'), \ 'command_callback': 'ale_linters#lua#luacheck#GetCommand', \ 'callback': 'ale_linters#lua#luacheck#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim index d9c2efb6..88dfb9dd 100644 --- a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim @@ -5,19 +5,10 @@ call ale#Set('markdown_remark_lint_executable', 'remark') call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('markdown_remark_lint_options', '') -function! ale_linters#markdown#remark_lint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [ - \ 'node_modules/.bin/remark', - \]) -endfunction - function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort - let l:executable = ale_linters#markdown#remark_lint#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options') - return ale#node#Executable(a:buffer, l:executable) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --no-stdout --no-color' + return '%e' . ale#Pad(l:options) . ' --no-stdout --no-color' endfunction function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort @@ -46,7 +37,9 @@ endfunction call ale#linter#Define('markdown', { \ 'name': 'remark_lint', \ 'aliases': ['remark-lint'], -\ 'executable_callback': 'ale_linters#markdown#remark_lint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('markdown_remark_lint', [ +\ 'node_modules/.bin/remark', +\ ]), \ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand', \ 'callback': 'ale_linters#markdown#remark_lint#Handle', \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/matlab/mlint.vim b/sources_non_forked/ale/ale_linters/matlab/mlint.vim index 32766334..3435045e 100644 --- a/sources_non_forked/ale/ale_linters/matlab/mlint.vim +++ b/sources_non_forked/ale/ale_linters/matlab/mlint.vim @@ -1,18 +1,7 @@ " Author: awlayton " Description: mlint for MATLAB files -let g:ale_matlab_mlint_executable = -\ get(g:, 'ale_matlab_mlint_executable', 'mlint') - -function! ale_linters#matlab#mlint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'matlab_mlint_executable') -endfunction - -function! ale_linters#matlab#mlint#GetCommand(buffer) abort - let l:executable = ale_linters#matlab#mlint#GetExecutable(a:buffer) - - return l:executable . ' -id %t' -endfunction +call ale#Set('matlab_mlint_executable', 'mlint') function! ale_linters#matlab#mlint#Handle(buffer, lines) abort " Matches patterns like the following: @@ -48,8 +37,8 @@ endfunction call ale#linter#Define('matlab', { \ 'name': 'mlint', -\ 'executable_callback': 'ale_linters#matlab#mlint#GetExecutable', -\ 'command_callback': 'ale_linters#matlab#mlint#GetCommand', +\ 'executable_callback': ale#VarFunc('matlab_mlint_executable'), +\ 'command': '%e -id %t', \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#matlab#mlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/mercury/mmc.vim b/sources_non_forked/ale/ale_linters/mercury/mmc.vim index c7bfc59d..76d357f0 100644 --- a/sources_non_forked/ale/ale_linters/mercury/mmc.vim +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -4,16 +4,11 @@ call ale#Set('mercury_mmc_executable', 'mmc') call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') -function! ale_linters#mercury#mmc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'mercury_mmc_executable') -endfunction - function! ale_linters#mercury#mmc#GetCommand(buffer) abort let l:module_name = expand('#' . a:buffer . ':t:r') return ale#path#BufferCdString(a:buffer) - \ . ale_linters#mercury#mmc#GetExecutable(a:buffer) - \ . ' --errorcheck-only ' + \ . '%e --errorcheck-only ' \ . ale#Var(a:buffer, 'mercury_mmc_options') \ . ' ' . l:module_name endfunction @@ -38,7 +33,7 @@ endfunction call ale#linter#Define('mercury', { \ 'name': 'mmc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable', +\ 'executable_callback': ale#VarFunc('mercury_mmc_executable'), \ 'command_callback': 'ale_linters#mercury#mmc#GetCommand', \ 'callback': 'ale_linters#mercury#mmc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/nasm/nasm.vim b/sources_non_forked/ale/ale_linters/nasm/nasm.vim index 77d57e18..29d19e62 100644 --- a/sources_non_forked/ale/ale_linters/nasm/nasm.vim +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -4,25 +4,13 @@ call ale#Set('nasm_nasm_executable', 'nasm') call ale#Set('nasm_nasm_options', '') -function! ale_linters#nasm#nasm#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'nasm_nasm_executable') -endfunction - -function! ale_linters#nasm#nasm#GetOptions(buffer) abort - return ale#Var(a:buffer, 'nasm_nasm_options') -endfunction - function! ale_linters#nasm#nasm#GetCommand(buffer) abort - " Note that NASM require a trailing slash to the -I option. - let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer)) + " Note that NASM requires a trailing slash for the -I option. let l:separator = has('win32') ? '\' : '/' - let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator) - let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer) + let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator - return l:executable - \ . ' -X gnu' - \ . ' -I ' . l:path - \ . ' ' . l:options + return '%e -X gnu -I ' . ale#Escape(l:path) + \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options')) \ . ' %s' endfunction @@ -30,6 +18,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort " Note that we treat 'fatal' as errors. let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' let l:output = [] + for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'lnum': l:match[1] + 0, @@ -37,6 +26,7 @@ function! ale_linters#nasm#nasm#Handle(buffer, lines) abort \ 'text': l:match[3], \}) endfor + return l:output endfunction @@ -44,7 +34,7 @@ call ale#linter#Define('nasm', { \ 'name': 'nasm', \ 'output_stream': 'stderr', \ 'lint_file': 1, -\ 'executable_callback': 'ale_linters#nasm#nasm#GetExecutable', +\ 'executable_callback': ale#VarFunc('nasm_nasm_executable'), \ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', \ 'callback': 'ale_linters#nasm#nasm#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/objc/clangd.vim b/sources_non_forked/ale/ale_linters/objc/clangd.vim new file mode 100644 index 00000000..161d2cc7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objc/clangd.vim @@ -0,0 +1,22 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('objc_clangd_executable', 'clangd') +call ale#Set('objc_clangd_options', '') + +function! ale_linters#objc#clangd#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +function! ale_linters#objc#clangd#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'objc_clangd_options')) +endfunction + +call ale#linter#Define('objc', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('objc_clangd_executable'), +\ 'command_callback': 'ale_linters#objc#clangd#GetCommand', +\ 'project_root_callback': 'ale_linters#objc#clangd#GetProjectRoot', +\}) diff --git a/sources_non_forked/ale/ale_linters/objcpp/clangd.vim b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim new file mode 100644 index 00000000..7e06796f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim @@ -0,0 +1,22 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('objcpp_clangd_executable', 'clangd') +call ale#Set('objcpp_clangd_options', '') + +function! ale_linters#objcpp#clangd#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +function! ale_linters#objcpp#clangd#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'objcpp_clangd_options')) +endfunction + +call ale#linter#Define('objcpp', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('objcpp_clangd_executable'), +\ 'command_callback': 'ale_linters#objcpp#clangd#GetCommand', +\ 'project_root_callback': 'ale_linters#objcpp#clangd#GetProjectRoot', +\}) diff --git a/sources_non_forked/ale/ale_linters/perl/perl.vim b/sources_non_forked/ale/ale_linters/perl/perl.vim index 1b9aa95e..d1dcbc9c 100644 --- a/sources_non_forked/ale/ale_linters/perl/perl.vim +++ b/sources_non_forked/ale/ale_linters/perl/perl.vim @@ -1,20 +1,11 @@ " Author: Vincent Lequertier " Description: This file adds support for checking perl syntax -let g:ale_perl_perl_executable = -\ get(g:, 'ale_perl_perl_executable', 'perl') - -let g:ale_perl_perl_options = -\ get(g:, 'ale_perl_perl_options', '-c -Mwarnings -Ilib') - -function! ale_linters#perl#perl#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'perl_perl_executable') -endfunction +call ale#Set('perl_perl_executable', 'perl') +call ale#Set('perl_perl_options', '-c -Mwarnings -Ilib') function! ale_linters#perl#perl#GetCommand(buffer) abort - return ale#Escape(ale_linters#perl#perl#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'perl_perl_options') - \ . ' %t' + return '%e' . ale#Pad(ale#Var(a:buffer, 'perl_perl_options')) . ' %t' endfunction let s:begin_failed_skip_pattern = '\v' . join([ @@ -61,7 +52,7 @@ endfunction call ale#linter#Define('perl', { \ 'name': 'perl', -\ 'executable_callback': 'ale_linters#perl#perl#GetExecutable', +\ 'executable_callback': ale#VarFunc('perl_perl_executable'), \ 'output_stream': 'both', \ 'command_callback': 'ale_linters#perl#perl#GetCommand', \ 'callback': 'ale_linters#perl#perl#Handle', diff --git a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim index e91c8a03..8619a404 100644 --- a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim +++ b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim @@ -1,21 +1,10 @@ " Author: Vincent Lequertier , Chris Weyl " Description: This file adds support for checking perl with perl critic -let g:ale_perl_perlcritic_executable = -\ get(g:, 'ale_perl_perlcritic_executable', 'perlcritic') - -let g:ale_perl_perlcritic_profile = -\ get(g:, 'ale_perl_perlcritic_profile', '.perlcriticrc') - -let g:ale_perl_perlcritic_options = -\ get(g:, 'ale_perl_perlcritic_options', '') - -let g:ale_perl_perlcritic_showrules = -\ get(g:, 'ale_perl_perlcritic_showrules', 0) - -function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'perl_perlcritic_executable') -endfunction +call ale#Set('perl_perlcritic_executable', 'perlcritic') +call ale#Set('perl_perlcritic_profile', '.perlcriticrc') +call ale#Set('perl_perlcritic_options', '') +call ale#Set('perl_perlcritic_showrules', 0) function! ale_linters#perl#perlcritic#GetProfile(buffer) abort " first see if we've been overridden @@ -39,11 +28,11 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer) let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') - return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) + return '%e' \ . ' --verbose ' . ale#Escape(l:critic_verbosity) \ . ' --nocolor' \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '') - \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ale#Pad(l:options) endfunction @@ -66,7 +55,7 @@ endfunction call ale#linter#Define('perl', { \ 'name': 'perlcritic', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#perl#perlcritic#GetExecutable', +\ 'executable_callback': ale#VarFunc('perl_perlcritic_executable'), \ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand', \ 'callback': 'ale_linters#perl#perlcritic#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/hack.vim b/sources_non_forked/ale/ale_linters/php/hack.vim deleted file mode 100644 index 77d3a588..00000000 --- a/sources_non_forked/ale/ale_linters/php/hack.vim +++ /dev/null @@ -1,28 +0,0 @@ -" Author: Zefei Xuan -" Description: Hack type checking (http://hacklang.org/) - -function! ale_linters#php#hack#Handle(buffer, lines) abort - let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - if a:buffer != bufnr(l:match[1]) - continue - endif - - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'text': l:match[5], - \}) - endfor - - return l:output -endfunction - -call ale#linter#Define('php', { -\ 'name': 'hack', -\ 'executable': 'hh_client', -\ 'command': 'hh_client --retries 0 --retry-if-init false', -\ 'callback': 'ale_linters#php#hack#Handle', -\}) diff --git a/sources_non_forked/ale/ale_linters/php/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim index 38b42df9..ca91db4c 100644 --- a/sources_non_forked/ale/ale_linters/php/langserver.vim +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -4,16 +4,6 @@ call ale#Set('php_langserver_executable', 'php-language-server.php') call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#php#langserver#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_langserver', [ - \ 'vendor/bin/php-language-server.php', - \]) -endfunction - -function! ale_linters#php#langserver#GetCommand(buffer) abort - return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer)) -endfunction - function! ale_linters#php#langserver#GetProjectRoot(buffer) abort let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') @@ -23,7 +13,9 @@ endfunction call ale#linter#Define('php', { \ 'name': 'langserver', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#php#langserver#GetExecutable', -\ 'command_callback': 'ale_linters#php#langserver#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('php_langserver', [ +\ 'vendor/bin/php-language-server.php', +\ ]), +\ 'command': 'php %e', \ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index faf8ad55..408c2652 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -3,26 +3,20 @@ let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '') +call ale#Set('php_phpcs_options', '') call ale#Set('php_phpcs_executable', 'phpcs') call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#php#phpcs#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_phpcs', [ - \ 'vendor/bin/phpcs', - \ 'phpcs' - \]) -endfunction - function! ale_linters#php#phpcs#GetCommand(buffer) abort - let l:executable = ale_linters#php#phpcs#GetExecutable(a:buffer) - let l:standard = ale#Var(a:buffer, 'php_phpcs_standard') let l:standard_option = !empty(l:standard) \ ? '--standard=' . l:standard \ : '' + let l:options = ale#Var(a:buffer, 'php_phpcs_options') - return ale#Escape(l:executable) - \ . ' -s --report=emacs --stdin-path=%s ' . l:standard_option + return '%e -s --report=emacs --stdin-path=%s' + \ . ale#Pad(l:standard_option) + \ . ale#Pad(l:options) endfunction function! ale_linters#php#phpcs#Handle(buffer, lines) abort @@ -50,7 +44,10 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpcs', -\ 'executable_callback': 'ale_linters#php#phpcs#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('php_phpcs', [ +\ 'vendor/bin/phpcs', +\ 'phpcs' +\ ]), \ 'command_callback': 'ale_linters#php#phpcs#GetCommand', \ 'callback': 'ale_linters#php#phpcs#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpmd.vim b/sources_non_forked/ale/ale_linters/php/phpmd.vim index e9450752..65f1cc3c 100644 --- a/sources_non_forked/ale/ale_linters/php/phpmd.vim +++ b/sources_non_forked/ale/ale_linters/php/phpmd.vim @@ -6,16 +6,9 @@ let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd') " Set to change the ruleset let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode') -function! ale_linters#php#phpmd#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'php_phpmd_executable') -endfunction - function! ale_linters#php#phpmd#GetCommand(buffer) abort - let l:executable = ale_linters#php#phpmd#GetExecutable(a:buffer) - - return ale#Escape(l:executable) - \ . ' %s text ' - \ . ale#Var(a:buffer, 'php_phpmd_ruleset') + return '%e %s text' + \ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset')) \ . ' --ignore-violations-on-exit %t' endfunction @@ -39,7 +32,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpmd', -\ 'executable_callback': 'ale_linters#php#phpmd#GetExecutable', +\ 'executable_callback': ale#VarFunc('php_phpmd_executable'), \ 'command_callback': 'ale_linters#php#phpmd#GetCommand', \ 'callback': 'ale_linters#php#phpmd#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpstan.vim b/sources_non_forked/ale/ale_linters/php/phpstan.vim index 24762086..b3875216 100644 --- a/sources_non_forked/ale/ale_linters/php/phpstan.vim +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -6,20 +6,13 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4') let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') -function! ale_linters#php#phpstan#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'php_phpstan_executable') -endfunction - function! ale_linters#php#phpstan#GetCommand(buffer) abort - let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer) - let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') let l:configuration_option = !empty(l:configuration) \ ? ' -c ' . l:configuration \ : '' - return ale#Escape(l:executable) - \ . ' analyze -l' + return '%e analyze -l' \ . ale#Var(a:buffer, 'php_phpstan_level') \ . ' --errorFormat raw' \ . l:configuration_option @@ -47,7 +40,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpstan', -\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable', +\ 'executable_callback': ale#VarFunc('php_phpstan_executable'), \ 'command_callback': 'ale_linters#php#phpstan#GetCommand', \ 'callback': 'ale_linters#php#phpstan#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/pony/ponyc.vim b/sources_non_forked/ale/ale_linters/pony/ponyc.vim index b3329053..19e7e828 100644 --- a/sources_non_forked/ale/ale_linters/pony/ponyc.vim +++ b/sources_non_forked/ale/ale_linters/pony/ponyc.vim @@ -3,19 +3,14 @@ call ale#Set('pony_ponyc_executable', 'ponyc') call ale#Set('pony_ponyc_options', '--pass paint') -function! ale_linters#pony#ponyc#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'pony_ponyc_executable') -endfunction - function! ale_linters#pony#ponyc#GetCommand(buffer) abort - return ale#Escape(ale_linters#pony#ponyc#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'pony_ponyc_options') + return '%e' . ale#Pad(ale#Var(a:buffer, 'pony_ponyc_options')) endfunction call ale#linter#Define('pony', { \ 'name': 'ponyc', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#pony#ponyc#GetExecutable', +\ 'executable_callback': ale#VarFunc('pony_ponyc_executable'), \ 'command_callback': 'ale_linters#pony#ponyc#GetCommand', \ 'callback': 'ale#handlers#pony#HandlePonycFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim index 165e68b7..63208986 100644 --- a/sources_non_forked/ale/ale_linters/pug/puglint.vim +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -5,12 +5,6 @@ call ale#Set('pug_puglint_options', '') call ale#Set('pug_puglint_executable', 'pug-lint') call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#pug#puglint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'pug_puglint', [ - \ 'node_modules/.bin/pug-lint', - \]) -endfunction - function! s:FindConfig(buffer) abort for l:filename in [ \ '.pug-lintrc', @@ -29,19 +23,19 @@ function! s:FindConfig(buffer) abort endfunction function! ale_linters#pug#puglint#GetCommand(buffer) abort - let l:executable = ale_linters#pug#puglint#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'pug_puglint_options') let l:config = s:FindConfig(a:buffer) - return ale#Escape(l:executable) - \ . (!empty(l:options) ? ' ' . l:options : '') + return '%e' . ale#Pad(l:options) \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') \ . ' -r inline %t' endfunction call ale#linter#Define('pug', { \ 'name': 'puglint', -\ 'executable_callback': 'ale_linters#pug#puglint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('pug_puglint', [ +\ 'node_modules/.bin/pug-lint', +\ ]), \ 'output_stream': 'stderr', \ 'command_callback': 'ale_linters#pug#puglint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsError', diff --git a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim index 52880f32..a08b7653 100644 --- a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim @@ -3,16 +3,6 @@ call ale#Set('puppet_languageserver_executable', 'puppet-languageserver') -function! ale_linters#puppet#languageserver#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'puppet_languageserver_executable') -endfunction - -function! ale_linters#puppet#languageserver#GetCommand(buffer) abort - let l:exe = ale#Escape(ale_linters#puppet#languageserver#GetExecutable(a:buffer)) - - return l:exe . ' --stdio' -endfunction - function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort " Note: The metadata.json file is recommended for Puppet 4+ modules, but " there's no requirement to have it, so fall back to the other possible @@ -38,8 +28,8 @@ endfunction call ale#linter#Define('puppet', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#puppet#languageserver#GetExecutable', -\ 'command_callback': 'ale_linters#puppet#languageserver#GetCommand', +\ 'executable_callback': ale#VarFunc('puppet_languageserver_executable'), +\ 'command': '%e --stdio', \ 'language': 'puppet', \ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim index 13da511b..c9c16f5e 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim @@ -1,26 +1,18 @@ " Author: Alexander Olofsson , Robert Flechtner " Description: puppet-lint for puppet files -let g:ale_puppet_puppetlint_executable = -\ get(g:, 'ale_puppet_puppetlint_executable', 'puppet-lint') - -let g:ale_puppet_puppetlint_options = -\ get(g:, 'ale_puppet_puppetlint_options', '--no-autoloader_layout-check') - -function! ale_linters#puppet#puppetlint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'puppet_puppetlint_executable') -endfunction +call ale#Set('puppet_puppetlint_executable', 'puppet-lint') +call ale#Set('puppet_puppetlint_options', '--no-autoloader_layout-check') function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort - return ale_linters#puppet#puppetlint#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'puppet_puppetlint_options') + return '%e' . ale#Pad(ale#Var(a:buffer, 'puppet_puppetlint_options')) \ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"' \ . ' %t' endfunction call ale#linter#Define('puppet', { \ 'name': 'puppetlint', -\ 'executable_callback': 'ale_linters#puppet#puppetlint#GetExecutable', +\ 'executable_callback': ale#VarFunc('puppet_puppetlint_executable'), \ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/pyrex/cython.vim b/sources_non_forked/ale/ale_linters/pyrex/cython.vim index 9b6b39d7..d260698c 100644 --- a/sources_non_forked/ale/ale_linters/pyrex/cython.vim +++ b/sources_non_forked/ale/ale_linters/pyrex/cython.vim @@ -5,16 +5,11 @@ call ale#Set('pyrex_cython_executable', 'cython') call ale#Set('pyrex_cython_options', '--warning-extra') -function! ale_linters#pyrex#cython#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'pyrex_cython_executable') -endfunction - function! ale_linters#pyrex#cython#GetCommand(buffer) abort let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - return ale#Escape(ale_linters#pyrex#cython#GetExecutable(a:buffer)) - \ . ' --working ' . l:local_dir . ' --include-dir ' . l:local_dir - \ . ' ' . ale#Var(a:buffer, 'pyrex_cython_options') + return '%e --working ' . l:local_dir . ' --include-dir ' . l:local_dir + \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options')) \ . ' --output-file ' . g:ale#util#nul_file . ' %t' endfunction @@ -37,7 +32,7 @@ endfunction call ale#linter#Define('pyrex', { \ 'name': 'cython', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#pyrex#cython#GetExecutable', +\ 'executable_callback': ale#VarFunc('pyrex_cython_executable'), \ 'command_callback': 'ale_linters#pyrex#cython#GetCommand', \ 'callback': 'ale_linters#pyrex#cython#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim index 85b131fd..12f3e97b 100644 --- a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim +++ b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim @@ -1,40 +1,25 @@ " Author: pylipp (www.github.com/pylipp) " Description: qmlfmt for QML files -let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt') - -function! ale_linters#qml#qmlfmt#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'qml_qmlfmt_executable') -endfunction - -function! ale_linters#qml#qmlfmt#GetCommand(buffer) abort - return ale#Escape(ale_linters#qml#qmlfmt#GetExecutable(a:buffer)) - \ . ' -e' -endfunction +call ale#Set('qml_qmlfmt_executable', 'qmlfmt') " Find lines like " Error:11:1: Expected token `}' function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$' - let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:item = { - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'text': l:match[4], - \ 'type': l:match[1] is# 'Warning' ? 'W' : 'E', - \} - call add(l:output, l:item) - endfor - - return l:output + return map(ale#util#GetMatches(a:lines, l:pattern), "{ + \ 'lnum': v:val[2] + 0, + \ 'col': v:val[3] + 0, + \ 'text': v:val[4], + \ 'type': v:val[1] is# 'Warning' ? 'W' : 'E', + \}") endfunction call ale#linter#Define('qml', { \ 'name': 'qmlfmt', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable', -\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand', +\ 'executable_callback': ale#VarFunc('qml_qmlfmt_executable'), +\ 'command': '%e -e', \ 'callback': 'ale_linters#qml#qmlfmt#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/ruby.vim b/sources_non_forked/ale/ale_linters/ruby/ruby.vim index 1aa88851..2bc4ec4b 100644 --- a/sources_non_forked/ale/ale_linters/ruby/ruby.vim +++ b/sources_non_forked/ale/ale_linters/ruby/ruby.vim @@ -3,20 +3,10 @@ call ale#Set('ruby_ruby_executable', 'ruby') -function! ale_linters#ruby#ruby#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'ruby_ruby_executable') -endfunction - -function! ale_linters#ruby#ruby#GetCommand(buffer) abort - let l:executable = ale_linters#ruby#ruby#GetExecutable(a:buffer) - - return ale#Escape(l:executable) . ' -w -c -T1 %t' -endfunction - call ale#linter#Define('ruby', { \ 'name': 'ruby', -\ 'executable_callback': 'ale_linters#ruby#ruby#GetExecutable', -\ 'command_callback': 'ale_linters#ruby#ruby#GetCommand', +\ 'executable_callback': ale#VarFunc('ruby_ruby_executable'), +\ 'command': '%e -w -c -T1 %t', \ 'output_stream': 'stderr', \ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', \}) diff --git a/sources_non_forked/ale/ale_linters/rust/rls.vim b/sources_non_forked/ale/ale_linters/rust/rls.vim index cd13291d..60dd3667 100644 --- a/sources_non_forked/ale/ale_linters/rust/rls.vim +++ b/sources_non_forked/ale/ale_linters/rust/rls.vim @@ -4,19 +4,10 @@ call ale#Set('rust_rls_executable', 'rls') call ale#Set('rust_rls_toolchain', 'nightly') -function! ale_linters#rust#rls#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'rust_rls_executable') -endfunction - function! ale_linters#rust#rls#GetCommand(buffer) abort - let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer) let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain') - if empty(l:toolchain) - return ale#Escape(l:executable) - else - return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain) - endif + return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '') endfunction function! ale_linters#rust#rls#GetProjectRoot(buffer) abort @@ -28,7 +19,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'rls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#rust#rls#GetExecutable', +\ 'executable_callback': ale#VarFunc('rust_rls_executable'), \ 'command_callback': 'ale_linters#rust#rls#GetCommand', \ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/rust/rustc.vim b/sources_non_forked/ale/ale_linters/rust/rustc.vim index 3cd401b3..33fb72f4 100644 --- a/sources_non_forked/ale/ale_linters/rust/rustc.vim +++ b/sources_non_forked/ale/ale_linters/rust/rustc.vim @@ -1,7 +1,7 @@ " Author: Daniel Schemala " Description: rustc for rust files -call ale#Set('rust_rustc_options', '-Z no-trans') +call ale#Set('rust_rustc_options', '-Z no-codegen') function! ale_linters#rust#rustc#RustcCommand(buffer) abort " Try to guess the library search path. If the project is managed by cargo, diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim index fe941d6a..b6286f18 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -3,20 +3,11 @@ call ale#Set('sass_stylelint_executable', 'stylelint') call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#sass#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'sass_stylelint', [ - \ 'node_modules/.bin/stylelint', - \]) -endfunction - -function! ale_linters#sass#stylelint#GetCommand(buffer) abort - return ale_linters#sass#stylelint#GetExecutable(a:buffer) - \ . ' --stdin-filename %s' -endfunction - call ale#linter#Define('sass', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#sass#stylelint#GetExecutable', -\ 'command_callback': 'ale_linters#sass#stylelint#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('sass_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), +\ 'command': '%e --stdin-filename %s', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/scala/fsc.vim b/sources_non_forked/ale/ale_linters/scala/fsc.vim index 17b26f0b..fbdce20e 100644 --- a/sources_non_forked/ale/ale_linters/scala/fsc.vim +++ b/sources_non_forked/ale/ale_linters/scala/fsc.vim @@ -1,29 +1,14 @@ " Author: Nils Leuzinger - https://github.com/PawkyPenguin " Description: Basic scala support using fsc -" -function! ale_linters#scala#fsc#GetExecutable(buffer) abort - if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 - " Don't check sbt files - return '' - endif - return 'fsc' -endfunction - -function! ale_linters#scala#fsc#GetCommand(buffer) abort - let l:executable = ale_linters#scala#fsc#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' -Ystop-after:parser %t' +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 endfunction call ale#linter#Define('scala', { \ 'name': 'fsc', -\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable', -\ 'command_callback': 'ale_linters#scala#fsc#GetCommand', +\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'fsc'}, +\ 'command': '%e -Ystop-after:parser %t', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) diff --git a/sources_non_forked/ale/ale_linters/scala/scalac.vim b/sources_non_forked/ale/ale_linters/scala/scalac.vim index 551284af..3dbdd925 100644 --- a/sources_non_forked/ale/ale_linters/scala/scalac.vim +++ b/sources_non_forked/ale/ale_linters/scala/scalac.vim @@ -2,29 +2,14 @@ " w0rp " Description: Basic scala support using scalac -function! ale_linters#scala#scalac#GetExecutable(buffer) abort - if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 - " Don't check sbt files - return '' - endif - - return 'scalac' -endfunction - -function! ale_linters#scala#scalac#GetCommand(buffer) abort - let l:executable = ale_linters#scala#scalac#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' -Ystop-after:parser %t' +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 endfunction call ale#linter#Define('scala', { \ 'name': 'scalac', -\ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable', -\ 'command_callback': 'ale_linters#scala#scalac#GetCommand', +\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'}, +\ 'command': '%e -Ystop-after:parser %t', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim index 6bfdd09a..6d183b4a 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -3,20 +3,11 @@ call ale#Set('scss_stylelint_executable', 'stylelint') call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#scss#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'scss_stylelint', [ - \ 'node_modules/.bin/stylelint', - \]) -endfunction - -function! ale_linters#scss#stylelint#GetCommand(buffer) abort - return ale_linters#scss#stylelint#GetExecutable(a:buffer) - \ . ' --stdin-filename %s' -endfunction - call ale#linter#Define('scss', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#scss#stylelint#GetExecutable', -\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('scss_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), +\ 'command': '%e --stdin-filename %s', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim index 27c74531..0f68e62c 100644 --- a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim +++ b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim @@ -6,14 +6,9 @@ " codes to exclude from shellcheck. For example: " " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' -let g:ale_sh_shellcheck_exclusions = -\ get(g:, 'ale_sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) - -let g:ale_sh_shellcheck_executable = -\ get(g:, 'ale_sh_shellcheck_executable', 'shellcheck') - -let g:ale_sh_shellcheck_options = -\ get(g:, 'ale_sh_shellcheck_options', '') +call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) +call ale#Set('sh_shellcheck_executable', 'shellcheck') +call ale#Set('sh_shellcheck_options', '') function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort return ale#Var(a:buffer, 'sh_shellcheck_executable') diff --git a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim index f5308af6..486bef1e 100644 --- a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim +++ b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim @@ -26,19 +26,12 @@ " And this is always output at the end and should just be ignored: " 0 packages and 1 specfiles checked; 4 errors, 0 warnings. -let g:ale_spec_rpmlint_executable = -\ get(g:, 'ale_spec_rpmlint_executable', 'rpmlint') - -let g:ale_spec_rpmlint_options = -\ get(g:, 'ale_spec_rpmlint_options', '') - -function! ale_linters#spec#rpmlint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'spec_rpmlint_executable') -endfunction +call ale#Set('spec_rpmlint_executable', 'rpmlint') +call ale#Set('spec_rpmlint_options', '') function! ale_linters#spec#rpmlint#GetCommand(buffer) abort - return ale_linters#spec#rpmlint#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'spec_rpmlint_options') + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options')) \ . ' -o "NetworkEnabled False"' \ . ' -v' \ . ' %t' @@ -79,7 +72,7 @@ endfunction call ale#linter#Define('spec', { \ 'name': 'rpmlint', -\ 'executable_callback': 'ale_linters#spec#rpmlint#GetExecutable', +\ 'executable_callback': ale#VarFunc('spec_rpmlint_executable'), \ 'command_callback': 'ale_linters#spec#rpmlint#GetCommand', \ 'callback': 'ale_linters#spec#rpmlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim index 1562692a..2256f3c0 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -4,21 +4,17 @@ call ale#Set('stylus_stylelint_executable', 'stylelint') call ale#Set('stylus_stylelint_options', '') call ale#Set('stylus_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#stylus#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'stylus_stylelint', [ - \ 'node_modules/.bin/stylelint', - \]) -endfunction - function! ale_linters#stylus#stylelint#GetCommand(buffer) abort - return ale_linters#stylus#stylelint#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'stylus_stylelint_options') + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'stylus_stylelint_options')) \ . ' --stdin-filename %s' endfunction call ale#linter#Define('stylus', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#stylus#stylelint#GetExecutable', +\ 'executable_callback': ale#node#FindExecutableFunc('stylus_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), \ 'command_callback': 'ale_linters#stylus#stylelint#GetCommand', \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim index 13b7a549..183ea9e7 100644 --- a/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim +++ b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim @@ -4,16 +4,10 @@ call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl') call ale#Set('tcl_nagelfar_options', '') -function! ale_linters#tcl#nagelfar#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'tcl_nagelfar_executable') -endfunction - function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options') - return ale#Escape(ale_linters#tcl#nagelfar#GetExecutable(a:buffer)) - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' %s' + return '%e' . ale#Pad(l:options) . ' %s' endfunction function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort @@ -39,7 +33,7 @@ endfunction call ale#linter#Define('tcl', { \ 'name': 'nagelfar', \ 'output_stream': 'stdout', -\ 'executable_callback': 'ale_linters#tcl#nagelfar#GetExecutable', +\ 'executable_callback': ale#VarFunc('tcl_nagelfar_executable'), \ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand', \ 'callback': 'ale_linters#tcl#nagelfar#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/terraform/tflint.vim b/sources_non_forked/ale/ale_linters/terraform/tflint.vim index 93966ff3..b8e9c96d 100644 --- a/sources_non_forked/ale/ale_linters/terraform/tflint.vim +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -30,14 +30,11 @@ function! ale_linters#terraform#tflint#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#terraform#tflint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'terraform_tflint_executable') -endfunction - function! ale_linters#terraform#tflint#GetCommand(buffer) abort - let l:cmd = ale#Escape(ale#Var(a:buffer, 'terraform_tflint_executable')) + let l:cmd = '%e' let l:config_file = ale#path#FindNearestFile(a:buffer, '.tflint.hcl') + if !empty(l:config_file) let l:cmd .= ' --config ' . ale#Escape(l:config_file) endif @@ -54,9 +51,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'tflint', -\ 'executable_callback': 'ale_linters#terraform#tflint#GetExecutable', +\ 'executable_callback': ale#VarFunc('terraform_tflint_executable'), \ 'command_callback': 'ale_linters#terraform#tflint#GetCommand', \ 'callback': 'ale_linters#terraform#tflint#Handle', \}) - -" vim:sw=4 diff --git a/sources_non_forked/ale/ale_linters/tex/lacheck.vim b/sources_non_forked/ale/ale_linters/tex/lacheck.vim index e5a9632b..38135b85 100644 --- a/sources_non_forked/ale/ale_linters/tex/lacheck.vim +++ b/sources_non_forked/ale/ale_linters/tex/lacheck.vim @@ -1,16 +1,7 @@ " Author: Andrew Balmos - " Description: lacheck for LaTeX files -let g:ale_tex_lacheck_executable = -\ get(g:, 'ale_tex_lacheck_executable', 'lacheck') - -function! ale_linters#tex#lacheck#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'tex_lacheck_executable') -endfunction - -function! ale_linters#tex#lacheck#GetCommand(buffer) abort - return ale#Var(a:buffer, 'tex_lacheck_executable') . ' %t' -endfunction +call ale#Set('tex_lacheck_executable', 'lacheck') function! ale_linters#tex#lacheck#Handle(buffer, lines) abort " Mattes lines like: @@ -41,7 +32,7 @@ endfunction call ale#linter#Define('tex', { \ 'name': 'lacheck', -\ 'executable_callback': 'ale_linters#tex#lacheck#GetExecutable', -\ 'command_callback': 'ale_linters#tex#lacheck#GetCommand', +\ 'executable_callback': ale#VarFunc('tex_lacheck_executable'), +\ 'command': '%e %t', \ 'callback': 'ale_linters#tex#lacheck#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/thrift/thrift.vim b/sources_non_forked/ale/ale_linters/thrift/thrift.vim index a8fe10b6..ac1f69fc 100644 --- a/sources_non_forked/ale/ale_linters/thrift/thrift.vim +++ b/sources_non_forked/ale/ale_linters/thrift/thrift.vim @@ -5,10 +5,6 @@ call ale#Set('thrift_thrift_generators', ['cpp']) call ale#Set('thrift_thrift_includes', []) call ale#Set('thrift_thrift_options', '-strict') -function! ale_linters#thrift#thrift#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'thrift_thrift_executable') -endfunction - function! ale_linters#thrift#thrift#GetCommand(buffer) abort let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators') let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes') @@ -22,7 +18,7 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort let l:output_dir = ale#engine#CreateDirectory(a:buffer) - return ale#Escape(ale_linters#thrift#thrift#GetExecutable(a:buffer)) + return '%e' \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val"))) \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val"))) \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options')) @@ -83,7 +79,7 @@ call ale#linter#Define('thrift', { \ 'name': 'thrift', \ 'executable': 'thrift', \ 'output_stream': 'both', -\ 'executable_callback': 'ale_linters#thrift#thrift#GetExecutable', +\ 'executable_callback': ale#VarFunc('thrift_thrift_executable'), \ 'command_callback': 'ale_linters#thrift#thrift#GetCommand', \ 'callback': 'ale_linters#thrift#thrift#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index 08bd0f41..bac63229 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -5,22 +5,13 @@ call ale#Set('typescript_tsserver_executable', 'tsserver') call ale#Set('typescript_tsserver_config_path', '') call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) -" These functions need to be defined just to comply with the API for LSP. -function! ale_linters#typescript#tsserver#GetProjectRoot(buffer) abort - return '' -endfunction - -function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_tsserver', [ - \ 'node_modules/.bin/tsserver', - \]) -endfunction - call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable', -\ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable', -\ 'project_root_callback': 'ale_linters#typescript#tsserver#GetProjectRoot', +\ 'executable_callback': ale#node#FindExecutableFunc('typescript_tsserver', [ +\ 'node_modules/.bin/tsserver', +\ ]), +\ 'command': '%e', +\ 'project_root_callback': {-> ''}, \ 'language': '', \}) diff --git a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim new file mode 100644 index 00000000..f4e111ee --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim @@ -0,0 +1,57 @@ +" Author: w0rp +" Description: A linter for checking ALE project code itself. + +function! ale_linters#vim#ale_custom_linting_rules#GetExecutable(buffer) abort + let l:filename = expand('#' . a:buffer . ':p') + let l:dir_list = [] + + for l:dir in split(&runtimepath, ',') + if l:filename[:len(l:dir) - 1] is# l:dir + call add(l:dir_list, l:dir) + endif + endfor + + return !empty(l:dir_list) + \ ? findfile('test/script/custom-linting-rules', join(l:dir_list, ',')) + \ : '' +endfunction + +function! s:GetALEProjectDir(buffer) abort + let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer) + + return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort + let l:dir = s:GetALEProjectDir(a:buffer) + + return ale#path#CdString(l:dir) . '%e .' +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort + let l:dir = s:GetALEProjectDir(a:buffer) + let l:output = [] + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+) (.+)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:filename = ale#path#GetAbsPath(l:dir, l:match[1]) + + if bufnr(l:filename) is a:buffer + call add(l:output, { + \ 'lnum': l:match[2], + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'ale_custom_linting_rules', +\ 'executable_callback': 'ale_linters#vim#ale_custom_linting_rules#GetExecutable', +\ 'command_callback': 'ale_linters#vim#ale_custom_linting_rules#GetCommand', +\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vue/vls.vim b/sources_non_forked/ale/ale_linters/vue/vls.vim index 0d4bf9f6..7116128b 100644 --- a/sources_non_forked/ale/ale_linters/vue/vls.vim +++ b/sources_non_forked/ale/ale_linters/vue/vls.vim @@ -4,18 +4,6 @@ call ale#Set('vue_vls_executable', 'vls') call ale#Set('vue_vls_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#vue#vls#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'vue_vls', [ - \ 'node_modules/.bin/vls', - \]) -endfunction - -function! ale_linters#vue#vls#GetCommand(buffer) abort - let l:exe = ale#Escape(ale_linters#vue#vls#GetExecutable(a:buffer)) - - return l:exe . ' --stdio' -endfunction - function! ale_linters#vue#vls#GetProjectRoot(buffer) abort let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') @@ -25,8 +13,10 @@ endfunction call ale#linter#Define('vue', { \ 'name': 'vls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#vue#vls#GetExecutable', -\ 'command_callback': 'ale_linters#vue#vls#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('vue_vls', [ +\ 'node_modules/.bin/vls', +\ ]), +\ 'command': '%e --stdio', \ 'language': 'vue', \ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/xml/xmllint.vim b/sources_non_forked/ale/ale_linters/xml/xmllint.vim index 9d79438e..a0f97c3a 100644 --- a/sources_non_forked/ale/ale_linters/xml/xmllint.vim +++ b/sources_non_forked/ale/ale_linters/xml/xmllint.vim @@ -5,12 +5,8 @@ let g:ale_xml_xmllint_executable = get(g:, 'ale_xml_xmllint_executable', 'xmllint') let g:ale_xml_xmllint_options = get(g:, 'ale_xml_xmllint_options', '') -function! ale_linters#xml#xmllint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'xml_xmllint_executable') -endfunction - function! ale_linters#xml#xmllint#GetCommand(buffer) abort - return ale#Escape(ale_linters#xml#xmllint#GetExecutable(a:buffer)) + return '%e' \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options')) \ . ' --noout -' endfunction @@ -63,7 +59,7 @@ endfunction call ale#linter#Define('xml', { \ 'name': 'xmllint', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#xml#xmllint#GetExecutable', +\ 'executable_callback': ale#VarFunc('xml_xmllint_executable'), \ 'command_callback': 'ale_linters#xml#xmllint#GetCommand', \ 'callback': 'ale_linters#xml#xmllint#Handle', \ }) diff --git a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim index 4a22c70f..7362536e 100644 --- a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -4,17 +4,6 @@ call ale#Set('yaml_swaglint_executable', 'swaglint') call ale#Set('yaml_swaglint_use_global', get(g:, 'ale_use_global_executables', 0)) -function! ale_linters#yaml#swaglint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'yaml_swaglint', [ - \ 'node_modules/.bin/swaglint', - \]) -endfunction - -function! ale_linters#yaml#swaglint#GetCommand(buffer) abort - return ale_linters#yaml#swaglint#GetExecutable(a:buffer) - \ . ' -r compact --stdin' -endfunction - function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$' let l:output = [] @@ -43,7 +32,9 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'swaglint', -\ 'executable_callback': 'ale_linters#yaml#swaglint#GetExecutable', -\ 'command_callback': 'ale_linters#yaml#swaglint#GetCommand', +\ 'executable_callback': ale#node#FindExecutableFunc('yaml_swaglint', [ +\ 'node_modules/.bin/swaglint', +\ ]), +\ 'command': '%e -r compact --stdin', \ 'callback': 'ale_linters#yaml#swaglint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim index f100667e..9d2cc7c2 100644 --- a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim @@ -1,18 +1,10 @@ " Author: KabbAmine -let g:ale_yaml_yamllint_executable = -\ get(g:, 'ale_yaml_yamllint_executable', 'yamllint') - -let g:ale_yaml_yamllint_options = -\ get(g:, 'ale_yaml_yamllint_options', '') - -function! ale_linters#yaml#yamllint#GetExecutable(buffer) abort - return ale#Var(a:buffer, 'yaml_yamllint_executable') -endfunction +call ale#Set('yaml_yamllint_executable', 'yamllint') +call ale#Set('yaml_yamllint_options', '') function! ale_linters#yaml#yamllint#GetCommand(buffer) abort - return ale_linters#yaml#yamllint#GetExecutable(a:buffer) - \ . ' ' . ale#Var(a:buffer, 'yaml_yamllint_options') + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) \ . ' -f parsable %t' endfunction @@ -52,7 +44,7 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'yamllint', -\ 'executable_callback': 'ale_linters#yaml#yamllint#GetExecutable', +\ 'executable_callback': ale#VarFunc('yaml_yamllint_executable'), \ 'command_callback': 'ale_linters#yaml#yamllint#GetCommand', \ 'callback': 'ale_linters#yaml#yamllint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim b/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim new file mode 100644 index 00000000..a60e9113 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim @@ -0,0 +1,14 @@ +call ale#Set('yang_lsp_executable', 'yang-language-server') + +function! ale_linters#yang#yang_lsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'yang.settings') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +call ale#linter#Define('yang', { +\ 'name': 'yang_lsp', +\ 'lsp': 'stdio', +\ 'executable_callback': ale#VarFunc('yang_lsp_executable'), +\ 'project_root_callback': 'ale_linters#yang#yang_lsp#GetProjectRoot', +\ 'command': '%e', +\}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index ee32a9a6..51c0ce83 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -197,6 +197,11 @@ function! ale#Var(buffer, variable_name) abort return get(l:vars, l:full_name, g:[l:full_name]) endfunction +" As above, but curry the arguments so only the buffer number is required. +function! ale#VarFunc(variable_name) abort + return {buf -> ale#Var(buf, a:variable_name)} +endfunction + " Initialize a variable with a default value, if it isn't already set. " " Every variable name will be prefixed with 'ale_'. diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim index a6753a1a..87798520 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -54,9 +54,14 @@ function! ale#assert#Linter(expected_executable, expected_command) abort endif else let l:command = ale#linter#GetCommand(l:buffer, l:linter) + endif + + if type(l:command) is v:t_string " Replace %e with the escaped executable, so tests keep passing after " linters are changed to use %e. let l:command = substitute(l:command, '%e', '\=ale#Escape(l:executable)', 'g') + else + call map(l:command, 'substitute(v:val, ''%e'', ''\=ale#Escape(l:executable)'', ''g'')') endif AssertEqual @@ -126,7 +131,9 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim' - call ale#test#SetDirectory('/testplugin/test/command_callback') + if !exists('g:dir') + call ale#test#SetDirectory('/testplugin/test/command_callback') + endif command! -nargs=+ WithChainResults :call ale#assert#WithChainResults() command! -nargs=+ AssertLinter :call ale#assert#Linter() @@ -140,14 +147,33 @@ function! ale#assert#TearDownLinterTest() abort unlet! g:ale_create_dummy_temporary_file let s:chain_results = [] - delcommand WithChainResults - delcommand AssertLinter - delcommand AssertLinterNotExecuted - delcommand AssertLSPOptions - delcommand AssertLSPLanguage - delcommand AssertLSPProject + if exists(':WithChainResults') + delcommand WithChainResults + endif - 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 diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index 19bb0d5e..5ec62011 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -8,6 +8,25 @@ let s:sep = has('win32') ? '\' : '/' " Set just so tests can override it. let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt'] +function! ale#c#GetBuildDirectory(buffer) abort + " Don't include build directory for header files, as compile_commands.json + " files don't consider headers to be translation units, and provide no + " commands for compiling header files. + if expand('#' . a:buffer) =~# '\v\.(h|hpp)$' + return '' + endif + + let l:build_dir = ale#Var(a:buffer, 'c_build_dir') + + " c_build_dir has the priority if defined + if !empty(l:build_dir) + return l:build_dir + endif + + return ale#path#Dirname(ale#c#FindCompileCommands(a:buffer)) +endfunction + + function! ale#c#FindProjectRoot(buffer) abort for l:project_filename in g:__ale_c_project_filenames let l:full_path = ale#path#FindNearestFile(a:buffer, l:project_filename) @@ -150,12 +169,22 @@ function! s:GetListFromCompileCommandsFile(compile_commands_file) abort endfunction function! ale#c#ParseCompileCommandsFlags(buffer, dir, json_list) abort + " Search for an exact file match first. for l:item in a:json_list if bufnr(l:item.file) is a:buffer return ale#c#ParseCFlags(a:dir, l:item.command) endif endfor + " Look for any file in the same directory if we can't find an exact match. + let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h')) + + for l:item in a:json_list + if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir + return ale#c#ParseCFlags(a:dir, l:item.command) + endif + endfor + return '' endfunction @@ -246,7 +275,7 @@ function! ale#c#IncludeOptions(include_paths) abort return '' endif - return ' ' . join(l:option_list) . ' ' + return join(l:option_list) endfunction let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 900d1871..abe0f56e 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -424,6 +424,58 @@ function! ale#completion#HandleLSPResponse(conn_id, response) abort \) endfunction +function! s:OnReady(linter, lsp_details, ...) abort + let l:buffer = a:lsp_details.buffer + let l:id = a:lsp_details.connection_id + + " If we have sent a completion request already, don't send another. + if b:ale_completion_info.request_id + return + endif + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#completion#HandleTSServerResponse') + \ : function('ale#completion#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Completions( + \ l:buffer, + \ b:ale_completion_info.line, + \ b:ale_completion_info.column, + \ b:ale_completion_info.prefix, + \) + else + " Send a message saying the buffer has changed first, otherwise + " completions won't know what text is nearby. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + " For LSP completions, we need to clamp the column to the length of + " the line. python-language-server and perhaps others do not implement + " this correctly. + let l:message = ale#lsp#message#Completion( + \ l:buffer, + \ b:ale_completion_info.line, + \ min([ + \ b:ale_completion_info.line_length, + \ b:ale_completion_info.column, + \ ]), + \ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix), + \) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + if l:request_id + let b:ale_completion_info.conn_id = l:id + let b:ale_completion_info.request_id = l:request_id + + if has_key(a:linter, 'completion_filter') + let b:ale_completion_info.completion_filter = a:linter.completion_filter + endif + endif +endfunction + function! s:GetLSPCompletions(linter) abort let l:buffer = bufnr('') let l:lsp_details = ale#lsp_linter#StartLSP(l:buffer, a:linter) @@ -433,58 +485,10 @@ function! s:GetLSPCompletions(linter) abort endif let l:id = l:lsp_details.connection_id - let l:root = l:lsp_details.project_root - function! OnReady(...) abort closure - " If we have sent a completion request already, don't send another. - if b:ale_completion_info.request_id - return - endif + let l:OnReady = function('s:OnReady', [a:linter, l:lsp_details]) - let l:Callback = a:linter.lsp is# 'tsserver' - \ ? function('ale#completion#HandleTSServerResponse') - \ : function('ale#completion#HandleLSPResponse') - call ale#lsp#RegisterCallback(l:id, l:Callback) - - if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#Completions( - \ l:buffer, - \ b:ale_completion_info.line, - \ b:ale_completion_info.column, - \ b:ale_completion_info.prefix, - \) - else - " Send a message saying the buffer has changed first, otherwise - " completions won't know what text is nearby. - call ale#lsp#NotifyForChanges(l:id, l:root, l:buffer) - - " For LSP completions, we need to clamp the column to the length of - " the line. python-language-server and perhaps others do not implement - " this correctly. - let l:message = ale#lsp#message#Completion( - \ l:buffer, - \ b:ale_completion_info.line, - \ min([ - \ b:ale_completion_info.line_length, - \ b:ale_completion_info.column, - \ ]), - \ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix), - \) - endif - - let l:request_id = ale#lsp#Send(l:id, l:message, l:lsp_details.project_root) - - if l:request_id - let b:ale_completion_info.conn_id = l:id - let b:ale_completion_info.request_id = l:request_id - - if has_key(a:linter, 'completion_filter') - let b:ale_completion_info.completion_filter = a:linter.completion_filter - endif - endif - endfunction - - call ale#lsp#WaitForCapability(l:id, l:root, 'completion', function('OnReady')) + call ale#lsp#WaitForCapability(l:id, 'completion', l:OnReady) endfunction function! ale#completion#GetCompletions() abort diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 3ef24e28..e68d279d 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -57,6 +57,39 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort endif endfunction +function! s:OnReady(linter, lsp_details, line, column, options, ...) abort + let l:buffer = a:lsp_details.buffer + let l:id = a:lsp_details.connection_id + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#definition#HandleTSServerResponse') + \ : function('ale#definition#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Definition( + \ l:buffer, + \ a:line, + \ a:column + \) + else + " Send a message saying the buffer has changed first, or the + " definition position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + " For LSP completions, we need to clamp the column to the length of + " the line. python-language-server and perhaps others do not implement + " this correctly. + let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:go_to_definition_map[l:request_id] = { + \ 'open_in_tab': get(a:options, 'open_in_tab', 0), + \} +endfunction + function! s:GoToLSPDefinition(linter, options) abort let l:buffer = bufnr('') let [l:line, l:column] = getcurpos()[1:2] @@ -71,39 +104,10 @@ function! s:GoToLSPDefinition(linter, options) abort endif let l:id = l:lsp_details.connection_id - let l:root = l:lsp_details.project_root - function! OnReady(...) abort closure - let l:Callback = a:linter.lsp is# 'tsserver' - \ ? function('ale#definition#HandleTSServerResponse') - \ : function('ale#definition#HandleLSPResponse') - call ale#lsp#RegisterCallback(l:id, l:Callback) - - if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#Definition( - \ l:buffer, - \ l:line, - \ l:column - \) - else - " Send a message saying the buffer has changed first, or the - " definition position probably won't make sense. - call ale#lsp#NotifyForChanges(l:id, l:root, l:buffer) - - " For LSP completions, we need to clamp the column to the length of - " the line. python-language-server and perhaps others do not implement - " this correctly. - let l:message = ale#lsp#message#Definition(l:buffer, l:line, l:column) - endif - - let l:request_id = ale#lsp#Send(l:id, l:message, l:lsp_details.project_root) - - let s:go_to_definition_map[l:request_id] = { - \ 'open_in_tab': get(a:options, 'open_in_tab', 0), - \} - endfunction - - call ale#lsp#WaitForCapability(l:id, l:root, 'definition', function('OnReady')) + call ale#lsp#WaitForCapability(l:id, 'definition', function('s:OnReady', [ + \ a:linter, l:lsp_details, l:line, l:column, a:options + \])) endfunction function! ale#definition#GoTo(options) abort diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index dc34e4c5..dfcdc98f 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -157,7 +157,7 @@ let s:default_registry = { \ }, \ 'hackfmt': { \ 'function': 'ale#fixers#hackfmt#Fix', -\ 'suggested_filetypes': ['php'], +\ 'suggested_filetypes': ['hack'], \ 'description': 'Fix Hack files with hackfmt.', \ }, \ 'hfmt': { @@ -170,6 +170,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Fix Haskell files with brittany.', \ }, +\ 'hlint': { +\ 'function': 'ale#fixers#hlint#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Refactor Haskell files with hlint.', +\ }, +\ 'stylish-haskell': { +\ 'function': 'ale#fixers#stylish_haskell#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Refactor Haskell files with stylish-haskell.', +\ }, \ 'refmt': { \ 'function': 'ale#fixers#refmt#Fix', \ 'suggested_filetypes': ['reason'], @@ -243,7 +253,7 @@ endfunction " (name, func, filetypes, desc, aliases) function! ale#fix#registry#Add(name, func, filetypes, desc, ...) abort " This command will throw from the sandbox. - let &equalprg=&equalprg + let &l:equalprg=&l:equalprg if type(a:name) isnot v:t_string throw '''name'' must be a String' diff --git a/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim index b5bf0dc5..bf2d4f71 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim @@ -1,12 +1,12 @@ " Author: Sam Howie " Description: Integration of hackfmt with ALE. -call ale#Set('php_hackfmt_executable', 'hackfmt') -call ale#Set('php_hackfmt_options', '') +call ale#Set('hack_hackfmt_executable', 'hackfmt') +call ale#Set('hack_hackfmt_options', '') function! ale#fixers#hackfmt#Fix(buffer) abort - let l:executable = ale#Var(a:buffer, 'php_hackfmt_executable') - let l:options = ale#Var(a:buffer, 'php_hackfmt_options') + let l:executable = ale#Var(a:buffer, 'hack_hackfmt_executable') + let l:options = ale#Var(a:buffer, 'hack_hackfmt_options') return { \ 'command': ale#Escape(l:executable) diff --git a/sources_non_forked/ale/autoload/ale/fixers/hlint.vim b/sources_non_forked/ale/autoload/ale/fixers/hlint.vim new file mode 100644 index 00000000..94dd736e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hlint.vim @@ -0,0 +1,16 @@ +" Author: eborden +" Description: Integration of hlint refactor with ALE. +" +call ale#Set('haskell_hlint_executable', 'hlint') + +function! ale#fixers#hlint#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hlint_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' --refactor' + \ . ' --refactor-options="--inplace"' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/importjs.vim b/sources_non_forked/ale/autoload/ale/fixers/importjs.vim index e8eedb12..50d3d74e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/importjs.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/importjs.vim @@ -1,7 +1,7 @@ " Author: Jeff Willette " Description: Integration of importjs with ALE. -call ale#Set('js_importjs_executable', 'importjs') +call ale#Set('javascript_importjs_executable', 'importjs') function! ale#fixers#importjs#ProcessOutput(buffer, output) abort let l:result = ale#util#FuzzyJSONDecode(a:output, []) @@ -9,7 +9,7 @@ function! ale#fixers#importjs#ProcessOutput(buffer, output) abort endfunction function! ale#fixers#importjs#Fix(buffer) abort - let l:executable = ale#Var(a:buffer, 'js_importjs_executable') + let l:executable = ale#Var(a:buffer, 'javascript_importjs_executable') if !executable(l:executable) return 0 diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index e8f4e92e..608240a5 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -27,6 +27,17 @@ function! ale#fixers#prettier#Fix(buffer) abort \} endfunction +function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort + " If the output is an error message, don't use it. + for l:line in a:output[:10] + if l:line =~# '^\w*Error:' + return [] + endif + endfor + + return a:output +endfunction + function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort let l:executable = ale#fixers#prettier#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'javascript_prettier_options') @@ -36,12 +47,23 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort " Append the --parser flag depending on the current filetype (unless it's " already set in g:javascript_prettier_options). if empty(expand('#' . a:buffer . ':e')) && match(l:options, '--parser') == -1 - let l:prettier_parsers = ['typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue'] - let l:parser = 'babylon' + let l:prettier_parsers = { + \ 'typescript': 'typescript', + \ 'css': 'css', + \ 'less': 'less', + \ 'scss': 'scss', + \ 'json': 'json', + \ 'json5': 'json5', + \ 'graphql': 'graphql', + \ 'markdown': 'markdown', + \ 'vue': 'vue', + \ 'yaml': 'yaml', + \} + let l:parser = '' for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.') - if index(l:prettier_parsers, l:filetype) > -1 - let l:parser = l:filetype + if has_key(l:prettier_parsers, l:filetype) + let l:parser = l:prettier_parsers[l:filetype] break endif endfor @@ -51,6 +73,17 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--parser ' . l:parser endif + " Special error handling needed for prettier_d + if l:executable =~# 'prettier_d$' + return { + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filepath %s --stdin', + \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput', + \} + endif + " 1.4.0 is the first version with --stdin-filepath if ale#semver#GTE(l:version, [1, 4, 0]) return { diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim b/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim new file mode 100644 index 00000000..a352312f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim @@ -0,0 +1,15 @@ +" Author: eborden +" Description: Integration of stylish-haskell formatting with ALE. +" +call ale#Set('haskell_stylish_haskell_executable', 'stylish-haskell') + +function! ale#fixers#stylish_haskell#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_stylish_haskell_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' --inplace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim index b8bac77f..72d639da 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim @@ -92,9 +92,12 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort " the previous error parsed in output if l:match[4] is# 'note' if !empty(l:output) - let l:output[-1]['detail'] = - \ get(l:output[-1], 'detail', '') - \ . s:RemoveUnicodeQuotes(l:match[0]) . "\n" + if !has_key(l:output[-1], 'detail') + let l:output[-1].detail = l:output[-1].text + endif + + let l:output[-1].detail = l:output[-1].detail . "\n" + \ . s:RemoveUnicodeQuotes(l:match[0]) endif continue diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index dc97ff41..69db276e 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -92,7 +92,44 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort endif endfunction -function! s:ShowDetails(linter, buffer, line, column, opt) abort +function! s:OnReady(linter, lsp_details, line, column, opt, ...) abort + let l:buffer = a:lsp_details.buffer + let l:id = a:lsp_details.connection_id + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#hover#HandleTSServerResponse') + \ : function('ale#hover#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:column = a:column + + let l:message = ale#lsp#tsserver_message#Quickinfo( + \ l:buffer, + \ a:line, + \ l:column + \) + else + " Send a message saying the buffer has changed first, or the + " hover position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:column = min([a:column, len(getbufline(l:buffer, a:line)[0])]) + + let l:message = ale#lsp#message#Hover(l:buffer, a:line, l:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:hover_map[l:request_id] = { + \ 'buffer': l:buffer, + \ 'line': a:line, + \ 'column': l:column, + \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), + \} +endfunction + +function! s:ShowDetails(linter, buffer, line, column, opt, ...) abort let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter) if empty(l:lsp_details) @@ -100,44 +137,10 @@ function! s:ShowDetails(linter, buffer, line, column, opt) abort endif let l:id = l:lsp_details.connection_id - let l:root = l:lsp_details.project_root - let l:language_id = l:lsp_details.language_id - function! OnReady(...) abort closure - let l:Callback = a:linter.lsp is# 'tsserver' - \ ? function('ale#hover#HandleTSServerResponse') - \ : function('ale#hover#HandleLSPResponse') - call ale#lsp#RegisterCallback(l:id, l:Callback) - - if a:linter.lsp is# 'tsserver' - let l:column = a:column - - let l:message = ale#lsp#tsserver_message#Quickinfo( - \ a:buffer, - \ a:line, - \ l:column - \) - else - " Send a message saying the buffer has changed first, or the - " hover position probably won't make sense. - call ale#lsp#NotifyForChanges(l:id, l:root, a:buffer) - - let l:column = min([a:column, len(getbufline(a:buffer, a:line)[0])]) - - let l:message = ale#lsp#message#Hover(a:buffer, a:line, l:column) - endif - - let l:request_id = ale#lsp#Send(l:id, l:message, l:lsp_details.project_root) - - let s:hover_map[l:request_id] = { - \ 'buffer': a:buffer, - \ 'line': a:line, - \ 'column': l:column, - \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), - \} - endfunction - - call ale#lsp#WaitForCapability(l:id, l:root, 'hover', function('OnReady')) + call ale#lsp#WaitForCapability(l:id, 'hover', function('s:OnReady', [ + \ a:linter, l:lsp_details, a:line, a:column, a:opt + \])) endfunction " Obtain Hover information for the specified position diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 683d506a..aad386aa 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -26,11 +26,13 @@ let s:default_ale_linter_aliases = { " " Only cargo is enabled for Rust by default. " rpmlint is disabled by default because it can result in code execution. +" hhast is disabled by default because it executes code in the project root. " " NOTE: Update the g:ale_linters documentation when modifying this. let s:default_ale_linters = { \ 'csh': ['shell'], \ 'go': ['gofmt', 'golint', 'go vet'], +\ 'hack': ['hack'], \ 'help': [], \ 'perl': ['perlcritic'], \ 'python': ['flake8', 'mypy', 'pylint'], @@ -51,7 +53,7 @@ endfunction " Do not call this function. function! ale#linter#GetLintersLoaded() abort " This command will throw from the sandbox. - let &equalprg=&equalprg + let &l:equalprg=&l:equalprg return s:linters endfunction @@ -293,7 +295,7 @@ endfunction function! ale#linter#Define(filetype, linter) abort " This command will throw from the sandbox. - let &equalprg=&equalprg + let &l:equalprg=&l:equalprg if !has_key(s:linters, a:filetype) let s:linters[a:filetype] = [] diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index 5d900138..7f99422a 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -1,62 +1,66 @@ " Author: w0rp " Description: Language Server Protocol client code -" A List of connections, used for tracking servers which have been connected -" to, and programs which are run. -let s:connections = get(s:, 'connections', []) +" A Dictionary for tracking connections. +let s:connections = get(s:, 'connections', {}) let g:ale_lsp_next_message_id = 1 -" Exposed only so tests can get at it. -" Do not call this function basically anywhere. -function! ale#lsp#NewConnection(initialization_options) abort - " id: The job ID as a Number, or the server address as a string. - " data: The message data received so far. - " executable: An executable only set for program connections. - " open_documents: A Dictionary mapping buffers to b:changedtick, keeping - " track of when documents were opened, and when we last changed them. - " callback_list: A list of callbacks for handling LSP responses. - " initialization_options: Options to send to the server. - " capabilities: Features the server supports. - let l:conn = { - \ 'is_tsserver': 0, - \ 'id': '', - \ 'data': '', - \ 'projects': {}, - \ 'open_documents': {}, - \ 'callback_list': [], - \ 'initialization_options': a:initialization_options, - \ 'capabilities': { - \ 'hover': 0, - \ 'references': 0, - \ 'completion': 0, - \ 'completion_trigger_characters': [], - \ 'definition': 0, - \ }, - \} +" Given an id, which can be an executable or address, and a project path, +" create a new connection if needed. Return a unique ID for the connection. +function! ale#lsp#Register(executable_or_address, project, init_options) abort + let l:conn_id = a:executable_or_address . ':' . a:project - call add(s:connections, l:conn) + if !has_key(s:connections, l:conn_id) + " is_tsserver: 1 if the connection is for tsserver. + " data: The message data received so far. + " root: The project root. + " open_documents: A Dictionary mapping buffers to b:changedtick, keeping + " track of when documents were opened, and when we last changed them. + " initialized: 0 if the connection is ready, 1 otherwise. + " init_request_id: The ID for the init request. + " init_options: Options to send to the server. + " callback_list: A list of callbacks for handling LSP responses. + " message_queue: Messages queued for sending to callbacks. + " capabilities_queue: The list of callbacks to call with capabilities. + " capabilities: Features the server supports. + let s:connections[l:conn_id] = { + \ 'is_tsserver': 0, + \ 'data': '', + \ 'root': a:project, + \ 'open_documents': {}, + \ 'initialized': 0, + \ 'init_request_id': 0, + \ 'init_options': a:init_options, + \ 'callback_list': [], + \ 'message_queue': [], + \ 'capabilities_queue': [], + \ 'capabilities': { + \ 'hover': 0, + \ 'references': 0, + \ 'completion': 0, + \ 'completion_trigger_characters': [], + \ 'definition': 0, + \ }, + \} + endif - return l:conn + return l:conn_id endfunction " Remove an LSP connection with a given ID. This is only for tests. function! ale#lsp#RemoveConnectionWithID(id) abort - call filter(s:connections, 'v:val.id isnot a:id') + if has_key(s:connections, a:id) + call remove(s:connections, a:id) + endif endfunction -function! s:FindConnection(key, value) abort - for l:conn in s:connections - if has_key(l:conn, a:key) && get(l:conn, a:key) is# a:value - return l:conn - endif - endfor +" This is only needed for tests +function! ale#lsp#MarkDocumentAsOpen(id, buffer) abort + let l:conn = get(s:connections, a:id, {}) - return {} -endfunction - -" Get the capabilities for a connection, or an empty Dictionary. -function! ale#lsp#GetConnectionCapabilities(id) abort - return get(s:FindConnection('id', a:id), 'capabilities', {}) + if !empty(l:conn) + let l:conn.open_documents[a:buffer] = -1 + endif endfunction function! ale#lsp#GetNextMessageID() abort @@ -100,7 +104,7 @@ endfunction " Given a List of one or two items, [method_name] or [method_name, params], " return a List containing [message_id, message_data] function! ale#lsp#CreateMessageData(message) abort - if a:message[1] =~# '^ts@' + if a:message[1][:2] is# 'ts@' return s:CreateTSServerMessageData(a:message) endif @@ -167,49 +171,6 @@ function! ale#lsp#ReadMessageData(data) abort return [l:remainder, l:response_list] endfunction -function! s:FindProjectWithInitRequestID(conn, init_request_id) abort - for l:project_root in keys(a:conn.projects) - let l:project = a:conn.projects[l:project_root] - - if l:project.init_request_id == a:init_request_id - return l:project - endif - endfor - - return {} -endfunction - -function! s:MarkProjectAsInitialized(conn, project) abort - let a:project.initialized = 1 - - " After the server starts, send messages we had queued previously. - for l:message_data in a:project.message_queue - call s:SendMessageData(a:conn, l:message_data) - endfor - - " Remove the messages now. - let a:conn.message_queue = [] - - " Call capabilities callbacks queued for the project. - for [l:capability, l:Callback] in a:project.capabilities_queue - if a:conn.is_tsserver || a:conn.capabilities[l:capability] - call call(l:Callback, [a:conn.id, a:project.root]) - endif - endfor - - " Clear the queued callbacks now. - let a:project.capabilities_queue = [] -endfunction - -function! s:HandleInitializeResponse(conn, response) abort - let l:request_id = a:response.request_id - let l:project = s:FindProjectWithInitRequestID(a:conn, l:request_id) - - if !empty(l:project) - call s:MarkProjectAsInitialized(a:conn, l:project) - endif -endfunction - " Update capabilities from the server, so we know which features the server " supports. function! s:UpdateCapabilities(conn, capabilities) abort @@ -242,178 +203,138 @@ function! s:UpdateCapabilities(conn, capabilities) abort endif endfunction -function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort - let l:uninitialized_projects = [] +function! ale#lsp#HandleInitResponse(conn, response) abort + if get(a:response, 'method', '') is# 'initialize' + let a:conn.initialized = 1 + elseif type(get(a:response, 'result')) is v:t_dict + \&& has_key(a:response.result, 'capabilities') + call s:UpdateCapabilities(a:conn, a:response.result.capabilities) - for [l:key, l:value] in items(a:conn.projects) - if l:value.initialized == 0 - call add(l:uninitialized_projects, [l:key, l:value]) - endif - endfor + let a:conn.initialized = 1 + endif - if empty(l:uninitialized_projects) + if !a:conn.initialized return endif - if get(a:response, 'method', '') is# '' - if has_key(get(a:response, 'result', {}), 'capabilities') - call s:UpdateCapabilities(a:conn, a:response.result.capabilities) + " After the server starts, send messages we had queued previously. + for l:message_data in a:conn.message_queue + call s:SendMessageData(a:conn, l:message_data) + endfor - for [l:dir, l:project] in l:uninitialized_projects - call s:MarkProjectAsInitialized(a:conn, l:project) - endfor + " Remove the messages now. + let a:conn.message_queue = [] + + " Call capabilities callbacks queued for the project. + for [l:capability, l:Callback] in a:conn.capabilities_queue + if a:conn.capabilities[l:capability] + call call(l:Callback, [a:conn.id]) endif - elseif get(a:response, 'method', '') is# 'textDocument/publishDiagnostics' - let l:filename = ale#path#FromURI(a:response.params.uri) + endfor - for [l:dir, l:project] in l:uninitialized_projects - if l:filename[:len(l:dir) - 1] is# l:dir - call s:MarkProjectAsInitialized(a:conn, l:project) - endif - endfor - endif + let a:conn.capabilities_queue = [] endfunction -function! ale#lsp#HandleMessage(conn, message) abort +function! ale#lsp#HandleMessage(conn_id, message) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return + endif + if type(a:message) isnot v:t_string " Ignore messages that aren't strings. return endif - let a:conn.data .= a:message + let l:conn.data .= a:message " Parse the objects now if we can, and keep the remaining text. - let [a:conn.data, l:response_list] = ale#lsp#ReadMessageData(a:conn.data) + let [l:conn.data, l:response_list] = ale#lsp#ReadMessageData(l:conn.data) - " Call our callbacks. - for l:response in l:response_list - if get(l:response, 'method', '') is# 'initialize' - call s:HandleInitializeResponse(a:conn, l:response) - else - call ale#lsp#HandleOtherInitializeResponses(a:conn, l:response) + " Look for initialize responses first. + if !l:conn.initialized + for l:response in l:response_list + call ale#lsp#HandleInitResponse(l:conn, l:response) + endfor + endif + " If the connection is marked as initialized, call the callbacks with the + " responses. + if l:conn.initialized + for l:response in l:response_list " Call all of the registered handlers with the response. - for l:Callback in a:conn.callback_list - call ale#util#GetFunction(l:Callback)(a:conn.id, l:response) + for l:Callback in l:conn.callback_list + call ale#util#GetFunction(l:Callback)(a:conn_id, l:response) endfor - endif - endfor -endfunction - -function! s:HandleChannelMessage(channel_id, message) abort - let l:address = ale#socket#GetAddress(a:channel_id) - let l:conn = s:FindConnection('id', l:address) - - call ale#lsp#HandleMessage(l:conn, a:message) -endfunction - -function! s:HandleCommandMessage(job_id, message) abort - let l:conn = s:FindConnection('id', a:job_id) - - call ale#lsp#HandleMessage(l:conn, a:message) + endfor + endif endfunction " Given a connection ID, mark it as a tsserver connection, so it will be " handled that way. function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort - let l:conn = s:FindConnection('id', a:conn_id) - - if !empty(l:conn) - let l:conn.is_tsserver = 1 - endif + let l:conn = s:connections[a:conn_id] + let l:conn.is_tsserver = 1 + let l:conn.initialized = 1 + " Set capabilities which are supported by tsserver. + let l:conn.capabilities.hover = 1 + let l:conn.capabilities.references = 1 + let l:conn.capabilities.completion = 1 + let l:conn.capabilities.completion_trigger_characters = ['.'] + let l:conn.capabilities.definition = 1 endfunction -" Register a project for an LSP connection. +" Start a program for LSP servers. " -" This function will throw if the connection doesn't exist. -function! ale#lsp#RegisterProject(conn_id, project_root) abort - let l:conn = s:FindConnection('id', a:conn_id) +" 1 will be returned if the program is running, or 0 if the program could +" not be started. +function! ale#lsp#StartProgram(conn_id, executable, command) abort + let l:conn = s:connections[a:conn_id] - " Empty strings can't be used for Dictionary keys in NeoVim, due to E713. - " This appears to be a nonsensical bug in NeoVim. - let l:key = empty(a:project_root) ? '<>' : a:project_root - - if !has_key(l:conn.projects, l:key) - " Tools without project roots are ready right away, like tsserver. - let l:conn.projects[l:key] = { - \ 'root': a:project_root, - \ 'initialized': empty(a:project_root), - \ 'init_request_id': 0, - \ 'message_queue': [], - \ 'capabilities_queue': [], - \} - endif -endfunction - -function! ale#lsp#GetProject(conn, project_root) abort - if empty(a:conn) - return {} - endif - - let l:key = empty(a:project_root) ? '<>' : a:project_root - - return get(a:conn.projects, l:key, {}) -endfunction - -" Start a program for LSP servers which run with executables. -" -" The job ID will be returned for for the program if it ran, otherwise -" 0 will be returned. -function! ale#lsp#StartProgram(executable, command, init_options) abort - if !executable(a:executable) - return 0 - endif - - let l:conn = s:FindConnection('executable', a:executable) - - " Get the current connection or a new one. - let l:conn = !empty(l:conn) ? l:conn : ale#lsp#NewConnection(a:init_options) - let l:conn.executable = a:executable - - if !has_key(l:conn, 'id') || !ale#job#IsRunning(l:conn.id) + if !has_key(l:conn, 'job_id') || !ale#job#IsRunning(l:conn.job_id) let l:options = { \ 'mode': 'raw', - \ 'out_cb': function('s:HandleCommandMessage'), + \ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)}, \} let l:job_id = ale#job#Start(a:command, l:options) else - let l:job_id = l:conn.id + let l:job_id = l:conn.job_id endif - if l:job_id <= 0 - return 0 + if l:job_id > 0 + let l:conn.job_id = l:job_id endif - let l:conn.id = l:job_id - - return l:job_id + return l:job_id > 0 endfunction -" Connect to an address and set up a callback for handling responses. -function! ale#lsp#ConnectToAddress(address, init_options) abort - let l:conn = s:FindConnection('id', a:address) - " Get the current connection or a new one. - let l:conn = !empty(l:conn) ? l:conn : ale#lsp#NewConnection(a:init_options) +" Connect to an LSP server via TCP. +" +" 1 will be returned if the connection is running, or 0 if the connection could +" not be opened. +function! ale#lsp#ConnectToAddress(conn_id, address) abort + let l:conn = s:connections[a:conn_id] if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id) - let l:conn.channel_id = ale#socket#Open(a:address, { - \ 'callback': function('s:HandleChannelMessage'), + let l:channel_id = ale#socket#Open(a:address, { + \ 'callback': {_, mess -> ale#lsp#HandleMessage(a:conn_id, mess)}, \}) + else + let l:channel_id = l:conn.channel_id endif - if l:conn.channel_id < 0 - return '' + if l:channel_id >= 0 + let l:conn.channel_id = l:channel_id endif - let l:conn.id = a:address - - return a:address + return l:channel_id >= 0 endfunction " Given a connection ID and a callback, register that callback for handling " messages if the connection exists. function! ale#lsp#RegisterCallback(conn_id, callback) abort - let l:conn = s:FindConnection('id', a:conn_id) + let l:conn = get(s:connections, a:conn_id, {}) if !empty(l:conn) " Add the callback to the List if it's not there already. @@ -421,23 +342,33 @@ function! ale#lsp#RegisterCallback(conn_id, callback) abort endif endfunction +" Stop a single LSP connection. +function! ale#lsp#Stop(conn_id) abort + if has_key(s:connections, a:conn_id) + let l:conn = remove(s:connections, a:conn_id) + + if has_key(l:conn, 'channel_id') + call ale#socket#Close(l:conn.channel_id) + elseif has_key(l:conn, 'job_id') + call ale#job#Stop(l:conn.job_id) + endif + endif +endfunction + +function! ale#lsp#CloseDocument(conn_id) abort +endfunction + " Stop all LSP connections, closing all jobs and channels, and removing any " queued messages. function! ale#lsp#StopAll() abort - for l:conn in s:connections - if has_key(l:conn, 'channel_id') - call ale#socket#Close(l:conn.channel_id) - else - call ale#job#Stop(l:conn.id) - endif + for l:conn_id in keys(s:connections) + call ale#lsp#Stop(l:conn_id) endfor - - let s:connections = [] endfunction function! s:SendMessageData(conn, data) abort - if has_key(a:conn, 'executable') - call ale#job#SendRaw(a:conn.id, a:data) + if has_key(a:conn, 'job_id') + call ale#job#SendRaw(a:conn.job_id, a:data) elseif has_key(a:conn, 'channel_id') && ale#socket#IsOpen(a:conn.channel_id) " Send the message to the server call ale#socket#Send(a:conn.channel_id, a:data) @@ -454,38 +385,32 @@ endfunction " Returns -1 when a message is sent, but no response is expected " 0 when the message is not sent and " >= 1 with the message ID when a response is expected. -function! ale#lsp#Send(conn_id, message, ...) abort - let l:project_root = get(a:000, 0, '') +function! ale#lsp#Send(conn_id, message) abort + let l:conn = get(s:connections, a:conn_id, {}) - let l:conn = s:FindConnection('id', a:conn_id) - let l:project = ale#lsp#GetProject(l:conn, l:project_root) - - if empty(l:project) + if empty(l:conn) return 0 endif " If we haven't initialized the server yet, then send the message for it. - if !l:project.initialized - " Only send the init message once. - if !l:project.init_request_id - let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( - \ ale#lsp#message#Initialize(l:project_root, l:conn.initialization_options), - \) + if !l:conn.initialized && !l:conn.init_request_id + let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( + \ ale#lsp#message#Initialize(l:conn.root, l:conn.init_options), + \) - let l:project.init_request_id = l:init_id + let l:conn.init_request_id = l:init_id - call s:SendMessageData(l:conn, l:init_data) - endif + call s:SendMessageData(l:conn, l:init_data) endif let [l:id, l:data] = ale#lsp#CreateMessageData(a:message) - if l:project.initialized + if l:conn.initialized " Send the message now. call s:SendMessageData(l:conn, l:data) else " Add the message we wanted to send to a List to send later. - call add(l:project.message_queue, l:data) + call add(l:conn.message_queue, l:data) endif return l:id == 0 ? -1 : l:id @@ -493,11 +418,10 @@ endfunction " Notify LSP servers or tsserver if a document is opened, if needed. " If a document is opened, 1 will be returned, otherwise 0 will be returned. -function! ale#lsp#OpenDocument(conn_id, project_root, buffer, language_id) abort - let l:conn = s:FindConnection('id', a:conn_id) +function! ale#lsp#OpenDocument(conn_id, buffer, language_id) abort + let l:conn = get(s:connections, a:conn_id, {}) let l:opened = 0 - " FIXME: Return 1 if the document is already open? if !empty(l:conn) && !has_key(l:conn.open_documents, a:buffer) if l:conn.is_tsserver let l:message = ale#lsp#tsserver_message#Open(a:buffer) @@ -505,7 +429,7 @@ function! ale#lsp#OpenDocument(conn_id, project_root, buffer, language_id) abort let l:message = ale#lsp#message#DidOpen(a:buffer, a:language_id) endif - call ale#lsp#Send(a:conn_id, l:message, a:project_root) + call ale#lsp#Send(a:conn_id, l:message) let l:conn.open_documents[a:buffer] = getbufvar(a:buffer, 'changedtick') let l:opened = 1 endif @@ -515,8 +439,8 @@ endfunction " Notify LSP servers or tsserver that a document has changed, if needed. " If a notification is sent, 1 will be returned, otherwise 0 will be returned. -function! ale#lsp#NotifyForChanges(conn_id, project_root, buffer) abort - let l:conn = s:FindConnection('id', a:conn_id) +function! ale#lsp#NotifyForChanges(conn_id, buffer) abort + let l:conn = get(s:connections, a:conn_id, {}) let l:notified = 0 if !empty(l:conn) && has_key(l:conn.open_documents, a:buffer) @@ -529,7 +453,7 @@ function! ale#lsp#NotifyForChanges(conn_id, project_root, buffer) abort let l:message = ale#lsp#message#DidChange(a:buffer) endif - call ale#lsp#Send(a:conn_id, l:message, a:project_root) + call ale#lsp#Send(a:conn_id, l:message) let l:conn.open_documents[a:buffer] = l:new_tick let l:notified = 1 endif @@ -540,25 +464,24 @@ endfunction " Given some LSP details that must contain at least `connection_id` and " `project_root` keys, -function! ale#lsp#WaitForCapability(conn_id, project_root, capability, callback) abort - let l:conn = s:FindConnection('id', a:conn_id) - let l:project = ale#lsp#GetProject(l:conn, a:project_root) +function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort + let l:conn = get(s:connections, a:conn_id, {}) - if empty(l:project) - return 0 + if empty(l:conn) + return endif if type(get(l:conn.capabilities, a:capability, v:null)) isnot v:t_number throw 'Invalid capability ' . a:capability endif - if l:project.initialized - if l:conn.is_tsserver || l:conn.capabilities[a:capability] + if l:conn.initialized + if l:conn.capabilities[a:capability] " The project has been initialized, so call the callback now. - call call(a:callback, [a:conn_id, a:project_root]) + call call(a:callback, [a:conn_id]) endif else " Call the callback later, once we have the information we need. - call add(l:project.capabilities_queue, [a:capability, a:callback]) + call add(l:conn.capabilities_queue, [a:capability, a:callback]) endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim index 48740ad1..69e88d56 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/response.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -47,7 +47,23 @@ function! ale#lsp#response#ReadDiagnostics(response) abort endif if has_key(l:diagnostic, 'code') - let l:loclist_item.nr = l:diagnostic.code + if type(l:diagnostic.code) == v:t_string + let l:loclist_item.code = l:diagnostic.code + elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1 + let l:loclist_item.code = string(l:diagnostic.code) + let l:loclist_item.nr = l:diagnostic.code + endif + endif + + if has_key(l:diagnostic, 'relatedInformation') + let l:related = deepcopy(l:diagnostic.relatedInformation) + call map(l:related, {key, val -> + \ ale#path#FromURI(val.location.uri) . + \ ':' . (val.location.range.start.line + 1) . + \ ':' . (val.location.range.start.character + 1) . + \ ":\n\t" . val.message + \ }) + let l:loclist_item.detail = l:diagnostic.message . "\n" . join(l:related, "\n") endif call add(l:loclist, l:loclist_item) @@ -70,7 +86,12 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort \} if has_key(l:diagnostic, 'code') - let l:loclist_item.nr = l:diagnostic.code + if type(l:diagnostic.code) == v:t_string + let l:loclist_item.code = l:diagnostic.code + elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1 + let l:loclist_item.code = string(l:diagnostic.code) + let l:loclist_item.nr = l:diagnostic.code + endif endif if get(l:diagnostic, 'category') is# 'warning' @@ -110,7 +131,7 @@ function! ale#lsp#response#GetErrorMessage(response) abort if type(l:error_data) is v:t_string let l:message .= "\n" . l:error_data - else + elseif type(l:error_data) is v:t_dict let l:traceback = get(l:error_data, 'traceback', []) if type(l:traceback) is v:t_list && !empty(l:traceback) diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index 87aee759..8fbad12f 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -143,7 +143,8 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort if a:linter.lsp is# 'socket' let l:address = ale#linter#GetAddress(a:buffer, a:linter) - let l:conn_id = ale#lsp#ConnectToAddress(l:address, l:init_options) + let l:conn_id = ale#lsp#Register(l:address, l:root, l:init_options) + let l:ready = ale#lsp#ConnectToAddress(l:conn_id, l:address) else let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) @@ -151,18 +152,16 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort return {} endif + let l:conn_id = ale#lsp#Register(l:executable, l:root, l:init_options) + let l:command = ale#linter#GetCommand(a:buffer, a:linter) " Format the command, so %e can be formatted into it. let l:command = ale#command#FormatCommand(a:buffer, l:executable, l:command, 0)[1] let l:command = ale#job#PrepareCommand(a:buffer, l:command) - let l:conn_id = ale#lsp#StartProgram( - \ l:executable, - \ l:command, - \ l:init_options, - \) + let l:ready = ale#lsp#StartProgram(l:conn_id, l:executable, l:command) endif - if empty(l:conn_id) + if !l:ready if g:ale_history_enabled && !empty(l:command) call ale#history#Add(a:buffer, 'failed', l:conn_id, l:command) endif @@ -175,9 +174,6 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort call ale#lsp#MarkConnectionAsTsserver(l:conn_id) endif - " Register the project now the connection is ready. - call ale#lsp#RegisterProject(l:conn_id, l:root) - let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer) let l:details = { @@ -188,7 +184,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort \ 'language_id': l:language_id, \} - if ale#lsp#OpenDocument(l:conn_id, l:root, a:buffer, l:language_id) + if ale#lsp#OpenDocument(l:conn_id, a:buffer, l:language_id) if g:ale_history_enabled && !empty(l:command) call ale#history#Add(a:buffer, 'started', l:conn_id, l:command) endif @@ -196,7 +192,7 @@ function! ale#lsp_linter#StartLSP(buffer, linter) abort " The change message needs to be sent for tsserver before doing anything. if a:linter.lsp is# 'tsserver' - call ale#lsp#NotifyForChanges(l:conn_id, l:root, a:buffer) + call ale#lsp#NotifyForChanges(l:conn_id, a:buffer) endif return l:details @@ -211,7 +207,6 @@ function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort endif let l:id = l:lsp_details.connection_id - let l:root = l:lsp_details.project_root " Register a callback now for handling errors now. let l:Callback = function('ale#lsp_linter#HandleLSPResponse') @@ -222,16 +217,16 @@ function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort if a:linter.lsp is# 'tsserver' let l:message = ale#lsp#tsserver_message#Geterr(a:buffer) - let l:notified = ale#lsp#Send(l:id, l:message, l:root) != 0 + let l:notified = ale#lsp#Send(l:id, l:message) != 0 else - let l:notified = ale#lsp#NotifyForChanges(l:id, l:root, a:buffer) + let l:notified = ale#lsp#NotifyForChanges(l:id, a:buffer) endif " If this was a file save event, also notify the server of that. if a:linter.lsp isnot# 'tsserver' \&& getbufvar(a:buffer, 'ale_save_event_fired', 0) let l:save_message = ale#lsp#message#DidSave(a:buffer) - let l:notified = ale#lsp#Send(l:id, l:save_message, l:root) != 0 + let l:notified = ale#lsp#Send(l:id, l:save_message) != 0 endif if l:notified diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim index f75280b7..5c579c75 100644 --- a/sources_non_forked/ale/autoload/ale/node.vim +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -23,6 +23,11 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort return ale#Var(a:buffer, a:base_var_name . '_executable') endfunction +" As above, but curry the arguments so only the buffer number is required. +function! ale#node#FindExecutableFunc(base_var_name, path_list) abort + return {buf -> ale#node#FindExecutable(buf, a:base_var_name, a:path_list)} +endfunction + " Create a executable string which executes a Node.js script command with a " Node.js executable if needed. " diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index bc1cc980..1f963431 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -24,6 +24,7 @@ function! ale#python#FindProjectRootIni(buffer) abort \|| filereadable(l:path . '/mypy.ini') \|| filereadable(l:path . '/pycodestyle.cfg') \|| filereadable(l:path . '/flake8.cfg') + \|| filereadable(l:path . '/.flake8rc') \|| filereadable(l:path . '/Pipfile') \|| filereadable(l:path . '/Pipfile.lock') return l:path diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index 3a710b7b..d00a1fa9 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -64,6 +64,35 @@ function! ale#references#HandleLSPResponse(conn_id, response) abort endif endfunction +function! s:OnReady(linter, lsp_details, line, column, ...) abort + let l:buffer = a:lsp_details.buffer + let l:id = a:lsp_details.connection_id + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#references#HandleTSServerResponse') + \ : function('ale#references#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#References( + \ l:buffer, + \ a:line, + \ a:column + \) + else + " Send a message saying the buffer has changed first, or the + " references position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:message = ale#lsp#message#References(l:buffer, a:line, a:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:references_map[l:request_id] = {} +endfunction + function! s:FindReferences(linter) abort let l:buffer = bufnr('') let [l:line, l:column] = getcurpos()[1:2] @@ -79,35 +108,10 @@ function! s:FindReferences(linter) abort endif let l:id = l:lsp_details.connection_id - let l:root = l:lsp_details.project_root - function! OnReady(...) abort closure - let l:Callback = a:linter.lsp is# 'tsserver' - \ ? function('ale#references#HandleTSServerResponse') - \ : function('ale#references#HandleLSPResponse') - - call ale#lsp#RegisterCallback(l:id, l:Callback) - - if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#References( - \ l:buffer, - \ l:line, - \ l:column - \) - else - " Send a message saying the buffer has changed first, or the - " references position probably won't make sense. - call ale#lsp#NotifyForChanges(l:id, l:root, l:buffer) - - let l:message = ale#lsp#message#References(l:buffer, l:line, l:column) - endif - - let l:request_id = ale#lsp#Send(l:id, l:message, l:lsp_details.project_root) - - let s:references_map[l:request_id] = {} - endfunction - - call ale#lsp#WaitForCapability(l:id, l:root, 'references', function('OnReady')) + call ale#lsp#WaitForCapability(l:id, 'references', function('s:OnReady', [ + \ a:linter, l:lsp_details, l:line, l:column + \])) endfunction function! ale#references#Find() abort diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index be37d1b5..8c69c54f 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -88,10 +88,10 @@ endfunction function! ale#util#Open(filename, line, column, options) abort if get(a:options, 'open_in_tab', 0) - call ale#util#Execute('tabedit ' . fnameescape(a:filename)) + call ale#util#Execute('tabedit +' . a:line . ' ' . fnameescape(a:filename)) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. - call ale#util#Execute('edit ' . fnameescape(a:filename)) + call ale#util#Execute('edit +' . a:line . ' ' . fnameescape(a:filename)) else normal! m` endif @@ -268,7 +268,7 @@ endfunction " See :help sandbox function! ale#util#InSandbox() abort try - let &equalprg=&equalprg + let &l:equalprg=&l:equalprg catch /E48/ " E48 is the sandbox error. return 1 diff --git a/sources_non_forked/ale/doc/ale-cpp.txt b/sources_non_forked/ale/doc/ale-cpp.txt index be7e840c..e582ae6e 100644 --- a/sources_non_forked/ale/doc/ale-cpp.txt +++ b/sources_non_forked/ale/doc/ale-cpp.txt @@ -32,6 +32,25 @@ g:ale_cpp_clang_options *g:ale_cpp_clang_options* This variable can be changed to modify flags given to clang. +=============================================================================== +clangd *ale-cpp-clangd* + +g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* + *b:ale_cpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* + *b:ale_cpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== clangcheck *ale-cpp-clangcheck* @@ -119,6 +138,37 @@ g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options* of the |g:ale_c_build_dir_names| directories of the project tree. +=============================================================================== +clazy *ale-cpp-clazy* + +g:ale_cpp_clazy_executable *g:ale_cpp_clazy_executable* + *b:ale_cpp_clazy_executable* + Type: |String| + Default: `'clazy-standalone'` + + This variable can be changed to use a different executable for clazy. + + +g:ale_cpp_clazy_checks *g:ale_cpp_clazy_checks* + *b:ale_cpp_clazy_checks* + Type: |List| + Default: `['level1']` + + The checks to enable for clazy with the `-checks` argument. + + All options will be joined with commas, and escaped appropriately for + the shell. The `-checks` flag can be removed entirely by setting this + option to an empty List. + + +g:ale_cpp_clazy_options *g:ale_cpp_clazy_options* + *b:ale_cpp_clazy_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clazy. + + =============================================================================== cppcheck *ale-cpp-cppcheck* diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index 60d6cb84..baf403b7 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -44,6 +44,17 @@ g:ale_go_gofmt_options *g:ale_go_gofmt_options* This variable can be set to pass additional options to the gofmt fixer. +=============================================================================== +govet *ale-go-govet* + +g:ale_go_govet_options *g:ale_go_govet_options* + *b:ale_go_govet_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the go vet linter. + + =============================================================================== gometalinter *ale-go-gometalinter* diff --git a/sources_non_forked/ale/doc/ale-hack.txt b/sources_non_forked/ale/doc/ale-hack.txt new file mode 100644 index 00000000..4776b8cf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-hack.txt @@ -0,0 +1,51 @@ +=============================================================================== +ALE Hack Integration *ale-hack-options* + *ale-integration-hack* + + HHAST is disabled by default, as it executes code in the project root. + + Currently linters must be enabled globally. HHAST can be enabled with: + +> + let g:ale_linters = {'hack': ['hack', 'hhast']} +< + +=============================================================================== +hack *ale-hack-hack* + +g:ale_hack_hack_executable *g:ale_hack_hack_executable* + *b:ale_hack_hack_executable* + + Type: |String| + Default: `'hh_client'` + + This variable can be set to use a specific executable to interact with the + Hack typechecker. + + +=============================================================================== +hackfmt *ale-hack-hackfmt* + +g:ale_hack_hackfmt_options *g:ale_hack_hackfmt_options* + *b:ale_hack_hackfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the hackfmt fixer. + + +=============================================================================== +hhast *ale-hack-hhast* + +g:ale_hack_hhast_executable *g:ale_hack_hhast_executable* + *b:ale_hack_hhast_executable* + + Type: |String| + Default: `'vendor/bin/hhast-lint'` + + This variable can be set to use a specific executable to interact with the + Hack typechecker. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index 15d3ce48..c1f1e889 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -67,6 +67,16 @@ g:ale_haskell_hfmt_executable *g:ale_haskell_hfmt_executable* This variable can be changed to use a different executable for hfmt. +=============================================================================== +hlint *ale-haskell-hlint* + +g:ale_haskell_hlint_executable *g:ale_haskell_hlint_executable* + *b:ale_haskell_hlint_executable* + Type: |String| + Default: `'hlint'` + + This variable can be changed to use a different executable for hlint. + =============================================================================== stack-build *ale-haskell-stack-build* @@ -78,6 +88,27 @@ g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options* We default to using `'--fast'`. Since Stack generates binaries, your programs will be slower unless you separately rebuild them outside of ALE. +=============================================================================== +stylish-haskell *ale-haskell-stylish-haskell* + +g:ale_haskell_stylish_haskell_executable + *g:ale_haskell_stylish_haskell_executable* + *b:ale_haskell_stylish_haskell_executable* + Type: |String| + Default: `'stylish-haskell'` + + This variable can be changed to use a different executable for stylish-haskell. + +=============================================================================== +hie *ale-haskell-hie* + +g:ale_haskell_hie_executable *g:ale_haskell_hie_executable* + *b:ale_haskell_hie_executable* + Type: |String| + Default: `'hie'` + + This variable can be changed to use a different executable for the haskell + ide engine. i.e. `'hie-wrapper'` =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt index 98fddc58..de48775f 100644 --- a/sources_non_forked/ale/doc/ale-html.txt +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -79,6 +79,33 @@ g:ale_html_tidy_use_global *g:html_tidy_use_global* See |ale-integrations-local-executables| +=============================================================================== +stylelint *ale-html-stylelint* + +g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* + *b:ale_html_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_html_stylelint_options *g:ale_html_stylelint_options* + *b:ale_html_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* + *b:ale_html_stylelint_use_global* + Type: |String| + Default: `0` + + See |ale-integrations-local-executables| + + =============================================================================== write-good *ale-html-write-good* diff --git a/sources_non_forked/ale/doc/ale-objc.txt b/sources_non_forked/ale/doc/ale-objc.txt index 35b9a795..9e7db367 100644 --- a/sources_non_forked/ale/doc/ale-objc.txt +++ b/sources_non_forked/ale/doc/ale-objc.txt @@ -13,5 +13,24 @@ g:ale_objc_clang_options *g:ale_objc_clang_options* This variable can be changed to modify flags given to clang. +=============================================================================== +clangd *ale-objc-clangd* + +g:ale_objc_clangd_executable *g:ale_objc_clangd_executable* + *b:ale_objc_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_objc_clangd_options *g:ale_objc_clangd_options* + *b:ale_objc_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-objcpp.txt b/sources_non_forked/ale/doc/ale-objcpp.txt index 73d68a2e..1f76aecb 100644 --- a/sources_non_forked/ale/doc/ale-objcpp.txt +++ b/sources_non_forked/ale/doc/ale-objcpp.txt @@ -13,5 +13,24 @@ g:ale_objcpp_clang_options *g:ale_objcpp_clang_options* This variable can be changed to modify flags given to clang. +=============================================================================== +clangd *ale-objcpp-clangd* + +g:ale_objcpp_clangd_executable *g:ale_objcpp_clangd_executable* + *b:ale_objcpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_objcpp_clangd_options *g:ale_objcpp_clangd_options* + *b:ale_objcpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt index 33796f7c..f38c3f88 100644 --- a/sources_non_forked/ale/doc/ale-php.txt +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -1,24 +1,6 @@ =============================================================================== ALE PHP Integration *ale-php-options* - -=============================================================================== -hack *ale-php-hack* - -There are no options for this linter. - - -=============================================================================== -hackfmt *ale-php-hackfmt* - -g:ale_php_hackfmt_options *g:ale_php_hackfmt_options* - *b:ale_php_hackfmt_options* - Type: |String| - Default: `''` - - This variable can be set to pass additional options to the hackfmt fixer. - - =============================================================================== langserver *ale-php-langserver* @@ -132,6 +114,13 @@ g:ale_php_phpcs_use_global *g:ale_php_phpcs_use_global* See |ale-integrations-local-executables| +g:ale_php_phpcs_options *g:ale_php_phpcs_options* + *b:ale_php_phpcs_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cs + =============================================================================== phpmd *ale-php-phpmd* diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index 093ea758..b5c469b1 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -22,6 +22,7 @@ ALE will look for configuration files with the following filenames. > mypy.ini pycodestyle.cfg flake8.cfg + .flake8rc Pipfile Pipfile.lock < diff --git a/sources_non_forked/ale/doc/ale-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt index d61e5b55..a6bd59ad 100644 --- a/sources_non_forked/ale/doc/ale-rust.txt +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -5,8 +5,9 @@ ALE Rust Integration *ale-rust-options* =============================================================================== Integration Information - Since Vim does not detect the rust file type out-of-the-box, you need the - runtime files for rust from here: https://github.com/rust-lang/rust.vim + If Vim does not detect the Rust file type out-of-the-box, you need the runtime + files for Rust distributed in Vim >=8.0.0501 or upstream: + https://github.com/rust-lang/rust.vim Note that there are three possible linters for Rust files: @@ -147,11 +148,11 @@ rustc *ale-rust-rustc* g:ale_rust_rustc_options *g:ale_rust_rustc_options* *b:ale_rust_rustc_options* Type: |String| - Default: `'-Z no-trans'` + Default: `'-Z no-codegen'` The variable can be used to change the options passed to `rustc`. - `-Z no-trans` should only work with nightly builds of Rust. Be careful when + `-Z no-codegen` should only work with nightly builds of Rust. Be careful when setting the options, as running `rustc` could execute code or generate binary files. diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index 1bccf5a3..0cb0a7c2 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -19,6 +19,16 @@ See |ale-javascript-prettier| for information about the available options. =============================================================================== tslint *ale-typescript-tslint* +This linter isn't recommended, because TSLint can't be used for checking for +problems while you type. You should probably use the tsserver plugin instead. + +Follow the instructions on the plugin website for installing it: +https://github.com/angelozerr/tsserver-plugins + +Then disable TSLint in vimrc or any other Vim configuration file. > + let g:ale_linters_ignore = {'typescript': ['tslint']} +< + g:ale_typescript_tslint_executable *g:ale_typescript_tslint_executable* *b:ale_typescript_tslint_executable* Type: |String| diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index 044d0b3d..c9a12ea1 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -1,7 +1,21 @@ =============================================================================== ALE YAML Integration *ale-yaml-options* +=============================================================================== +prettier *ale-yaml-prettier* +Website: https://github.com/prettier/prettier + + +Installation +------------------------------------------------------------------------------- + +Install prettier either globally or locally: > + + npm install prettier -g # global + npm install prettier # local +< + =============================================================================== swaglint *ale-yaml-swaglint* diff --git a/sources_non_forked/ale/doc/ale-yang.txt b/sources_non_forked/ale/doc/ale-yang.txt new file mode 100644 index 00000000..ad619733 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-yang.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE YANG Integration *ale-yang-options* + + +=============================================================================== +yang-lsp *ale-yang-lsp* + +g:ale_yang_lsp_executable *g:ale_yang_lsp_executable* + *b:ale_yang_lsp_executable* + Type: |String| + Default: `'yang-language-server'` + + This variable can be changed to use a different executable for yang-lsp. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index 15a20469..8e38f92a 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -43,9 +43,11 @@ CONTENTS *ale-contents* cmakelint...........................|ale-cmake-cmakelint| cpp...................................|ale-cpp-options| clang...............................|ale-cpp-clang| + clangd..............................|ale-cpp-clangd| clangcheck..........................|ale-cpp-clangcheck| clang-format........................|ale-cpp-clangformat| clangtidy...........................|ale-cpp-clangtidy| + clazy...............................|ale-cpp-clazy| cppcheck............................|ale-cpp-cppcheck| cpplint.............................|ale-cpp-cpplint| cquery..............................|ale-cpp-cquery| @@ -90,12 +92,17 @@ CONTENTS *ale-contents* go....................................|ale-go-options| gobuild.............................|ale-go-gobuild| gofmt...............................|ale-go-gofmt| + govet...............................|ale-go-govet| gometalinter........................|ale-go-gometalinter| staticcheck.........................|ale-go-staticcheck| graphql...............................|ale-graphql-options| eslint..............................|ale-graphql-eslint| gqlint..............................|ale-graphql-gqlint| prettier............................|ale-graphql-prettier| + hack..................................|ale-hack-options| + hack................................|ale-hack-hack| + hackfmt.............................|ale-hack-hackfmt| + hhast...............................|ale-hack-hhast| handlebars............................|ale-handlebars-options| ember-template-lint.................|ale-handlebars-embertemplatelint| haskell...............................|ale-haskell-options| @@ -104,10 +111,14 @@ CONTENTS *ale-contents* cabal-ghc...........................|ale-haskell-cabal-ghc| hdevtools...........................|ale-haskell-hdevtools| hfmt................................|ale-haskell-hfmt| + hlint...............................|ale-haskell-hlint| stack-build.........................|ale-haskell-stack-build| + stylish-haskell.....................|ale-haskell-stylish-haskell| + hie.................................|ale-haskell-hie| html..................................|ale-html-options| htmlhint............................|ale-html-htmlhint| tidy................................|ale-html-tidy| + stylelint...........................|ale-html-stylelint| write-good..........................|ale-html-write-good| idris.................................|ale-idris-options| idris...............................|ale-idris-idris| @@ -161,8 +172,10 @@ CONTENTS *ale-contents* write-good..........................|ale-nroff-write-good| objc..................................|ale-objc-options| clang...............................|ale-objc-clang| + clangd..............................|ale-objc-clangd| objcpp................................|ale-objcpp-options| clang...............................|ale-objcpp-clang| + clangd..............................|ale-objcpp-clangd| ocaml.................................|ale-ocaml-options| merlin..............................|ale-ocaml-merlin| ols.................................|ale-ocaml-ols| @@ -171,8 +184,6 @@ CONTENTS *ale-contents* perlcritic..........................|ale-perl-perlcritic| perltidy............................|ale-perl-perltidy| php...................................|ale-php-options| - hack................................|ale-php-hack| - hackfmt.............................|ale-php-hackfmt| langserver..........................|ale-php-langserver| phan................................|ale-php-phan| phpcbf..............................|ale-php-phpcbf| @@ -287,8 +298,11 @@ CONTENTS *ale-contents* xml...................................|ale-xml-options| xmllint.............................|ale-xml-xmllint| yaml..................................|ale-yaml-options| + prettier............................|ale-yaml-prettier| swaglint............................|ale-yaml-swaglint| yamllint............................|ale-yaml-yamllint| + yang..................................|ale-yang-options| + yang-lsp............................|ale-yang-lsp| 8. Commands/Keybinds....................|ale-commands| 9. API..................................|ale-api| 10. Special Thanks......................|ale-special-thanks| @@ -339,7 +353,7 @@ Notes: * Bash: `language-server`, `shell` (-n flag), `shellcheck`, `shfmt` * Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` * C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc` -* C++ (filetype cpp): `clang`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc` +* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc` * CUDA: `nvcc`!! * C#: `mcs`, `mcsc`!! * Chef: `foodcritic` @@ -367,9 +381,10 @@ Notes: * GLSL: glslang, `glslls` * Go: `gofmt`, `goimports`, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!! * GraphQL: `eslint`, `gqlint`, `prettier` +* Hack: `hack`, `hackfmt`, `hhast` * Haml: `haml-lint` * Handlebars: `ember-template-lint` -* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt` +* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stylish-haskell`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt`, `hie` * HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good` * Idris: `idris` * Java: `checkstyle`, `javac`, `google-java-format`, `PMD` @@ -389,11 +404,11 @@ Notes: * Nim: `nim check`!! * nix: `nix-instantiate` * nroff: `alex`!!, `proselint`, `write-good` -* Objective-C: `clang` -* Objective-C++: `clang` +* Objective-C: `clang`, `clangd` +* Objective-C++: `clang`, `clangd` * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols` * Perl: `perl -c`, `perl-critic`, `perltidy` -* PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer` +* PHP: `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer` * PO: `alex`!!, `msgfmt`, `proselint`, `write-good` * Pod: `alex`!!, `proselint`, `write-good` * Pony: `ponyc` @@ -430,7 +445,8 @@ Notes: * Vue: `prettier`, `vls` * XHTML: `alex`!!, `proselint`, `write-good` * XML: `xmllint` -* YAML: `swaglint`, `yamllint` +* YAML: `prettier`, `swaglint`, `yamllint` +* YANG: `yang-lsp` =============================================================================== 3. Linting *ale-lint* @@ -646,10 +662,10 @@ servers. LSP linters can be used in combination with any other linter, and will automatically connect to LSP servers when needed. ALE also supports `tsserver` for TypeScript, which uses a different but very similar protocol. -ALE supports the following LSP/tsserver features. +ALE supports the following LSP/tsserver features: 1. Diagnostics/linting - Enabled via selecting linters as usual. -2. Completion (Only for tsserver) +2. Completion 3. Go to definition @@ -657,7 +673,7 @@ ALE supports the following LSP/tsserver features. 5.1 Completion *ale-completion* ALE offers limited support for automatic completion of code while you type. -Completion is only supported while a least one LSP linter is enabled. ALE +Completion is only supported while at least one LSP linter is enabled. ALE will only suggest symbols provided by the LSP servers. Suggestions will be made while you type after completion is enabled. @@ -669,6 +685,16 @@ items can be controlled with |g:ale_completion_max_suggestions|. If you don't like some of the suggestions you see, you can filter them out with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|. + *ale-completion-completopt-bug* + +ALE implements completion as you type by temporarily adjusting |completeopt| +before opening the omnicomplete menu with . In some versions of Vim, +the value set for the option will not be respected. If you experience issues +with Vim automatically inserting text while you type, set the following option +in vimrc, and your issues should go away. > + + set completeopt=menu,menuone,preview,noselect,noinsert +< ------------------------------------------------------------------------------- 5.2 Go To Definition *ale-go-to-definition* @@ -1201,6 +1227,7 @@ g:ale_linters *g:ale_linters* { \ 'csh': ['shell'], \ 'go': ['gofmt', 'golint', 'go vet'], + \ 'hack': ['hack'], \ 'help': [], \ 'perl': ['perlcritic'], \ 'python': ['flake8', 'mypy', 'pylint'], @@ -2318,6 +2345,13 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* `type` - Defaults to `'E'`. `nr` - Defaults to `-1`. + Numeric error code. If `nr` is not `-1`, `code` + likely should contain the string representation of + the same value. + `code` - No default; may be unset. + + Human-readable |String| error code. + `executable` A |String| naming the executable itself which will be run. This value will be used to check if the program requested is installed or not. @@ -2662,7 +2696,7 @@ ALEFixPost *ALEFixPost-autocmd* augroup ALEProgress autocmd! autocmd User ALELintPre hi Statusline ctermfg=darkgrey - autocmd User ALELintPOST hi Statusline ctermfg=NONE + autocmd User ALELintPost hi Statusline ctermfg=NONE augroup end < Or to display the progress in the statusline: diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index f0f90b6b..ffb5da8a 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -14,7 +14,7 @@ let g:loaded_ale_dont_use_this_in_other_plugins_please = 1 " A flag for detecting if the required features are set. if has('nvim') - let s:has_features = has('timers') + let s:has_features = has('timers') && has('nvim-0.2.0') else " Check if Job and Channel functions are available, instead of the " features. This works better on old MacVim versions. @@ -24,7 +24,7 @@ endif if !s:has_features " Only output a warning if editing some special files. if index(['', 'gitcommit'], &filetype) == -1 - execute 'echoerr ''ALE requires NeoVim >= 0.1.5 or Vim 8 with +timers +job +channel''' + execute 'echoerr ''ALE requires NeoVim >= 0.2.0 or Vim 8 with +timers +job +channel''' execute 'echoerr ''Please update your editor appropriately.''' endif diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index b138c21c..bdf3deb7 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -61,7 +61,6 @@ endfunction function! nerdtree#compareNodesBySortKey(n1, n2) let sortKey1 = a:n1.path.getSortKey() let sortKey2 = a:n2.path.getSortKey() - let i = 0 while i < min([len(sortKey1), len(sortKey2)]) " Compare chunks upto common length. @@ -73,9 +72,9 @@ function! nerdtree#compareNodesBySortKey(n1, n2) elseif sortKey1[i] ># sortKey2[i] return 1 endif - elseif sortKey1[i] == type(0) + elseif type(sortKey1[i]) == v:t_number return -1 - elseif sortKey2[i] == type(0) + elseif type(sortKey2[i]) == v:t_number return 1 endif let i = i + 1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 974d99d3..56701cfe 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -233,7 +233,6 @@ endfunction " FUNCTION: Opener.open(target) {{{1 function! s:Opener.open(target) - if self._path.isDirectory call self._openDirectory(a:target) return @@ -303,7 +302,7 @@ endfunction " FUNCTION: Opener._restoreCursorPos() {{{1 function! s:Opener._restoreCursorPos() - call nerdtree#exec('normal ' . self._tabnr . 'gt') + call nerdtree#exec(self._tabnr . 'tabnext') call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w') endfunction @@ -332,7 +331,7 @@ function! s:Opener._reuseWindow() let tabnr = self._path.tabnr() if tabnr call self._checkToCloseTree(1) - call nerdtree#exec('normal! ' . tabnr . 'gt') + call nerdtree#exec(tabnr . 'tabnext') let winnr = bufwinnr('^' . self._path.str() . '$') call nerdtree#exec(winnr . "wincmd w") return 1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index 2d8de23c..912c5372 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -7,10 +7,6 @@ " ============================================================================ -" This constant is used throughout this script for sorting purposes. -let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') -lockvar s:NERDTreeSortStarIndex - let s:Path = {} let g:NERDTreePath = s:Path @@ -374,7 +370,8 @@ function! s:Path.getSortOrderIndex() endif let i = i + 1 endwhile - return s:NERDTreeSortStarIndex + + return index(g:NERDTreeSortOrder, '*') endfunction " FUNCTION: Path._splitChunks(path) {{{1 @@ -395,7 +392,7 @@ endfunction " FUNCTION: Path.getSortKey() {{{1 " returns a key used in compare function for sorting function! s:Path.getSortKey() - if !exists("self._sortKey") + if !exists("self._sortKey") || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder let path = self.getLastPathComponent(1) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') @@ -820,7 +817,7 @@ function! s:Path.tabnr() let str = self.str() for t in range(tabpagenr('$')) for b in tabpagebuflist(t+1) - if str == expand('#' . b . ':p') + if str ==# expand('#' . b . ':p') return t+1 endif endfor diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index 03c3545b..9d4edee8 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -247,7 +247,7 @@ function! s:TreeDirNode._glob(pattern, all) if self.path.str() == getcwd() let l:pathSpec = ',' else - let l:pathSpec = fnamemodify(self.path.str({'format': 'Glob'}), ':.') + let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') " On Windows, the drive letter may be removed by "fnamemodify()". if nerdtree#runningWindows() && l:pathSpec[0] == g:NERDTreePath.Slash() @@ -607,8 +607,12 @@ endfunction " FUNCTION: TreeDirNode.sortChildren() {{{1 " Sort "self.children" by alphabetical order and directory priority. function! s:TreeDirNode.sortChildren() + if count(g:NERDTreeSortOrder, '*') < 1 + call add(g:NERDTreeSortOrder, '*') + endif let CompareFunc = function("nerdtree#compareNodesBySortKey") call sort(self.children, CompareFunc) + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction " FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index 68a72b68..07373107 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -475,15 +475,23 @@ function! s:UI.toggleIgnoreFilter() endfunction " FUNCTION: s:UI.toggleShowBookmarks() {{{1 -" toggles the display of bookmarks +" Toggle the visibility of the Bookmark table. function! s:UI.toggleShowBookmarks() let self._showBookmarks = !self._showBookmarks + if self.getShowBookmarks() call self.nerdtree.render() call g:NERDTree.CursorToBookmarkTable() else + + if empty(g:NERDTreeFileNode.GetSelected()) + call b:NERDTree.root.putCursorHere(0, 0) + normal! 0 + endif + call self.renderViewSavingPosition() endif + call self.centerView() endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 36e2eae0..c9897cee 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -164,7 +164,7 @@ function! NERDTreeMoveNode() "if the node is open in a buffer, ask the user if they want to "close that buffer if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)" + let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with the new file? (yN)" call s:promptToRenameBuffer(bufnum, prompt, newNodePath) endif diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index 35b47c38..71d719aa 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -81,12 +81,8 @@ call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -else - "if there isnt a * in the sort sequence then add one - if count(g:NERDTreeSortOrder, '*') < 1 - call add(g:NERDTreeSortOrder, '*') - endif endif +let g:NERDTreeOldSortOrder = [] call s:initVariable("g:NERDTreeGlyphReadOnly", "RO") diff --git a/sources_non_forked/nginx.vim/ftdetect/nginx.vim b/sources_non_forked/nginx.vim/ftdetect/nginx.vim index cae77e4c..0916ca89 100644 --- a/sources_non_forked/nginx.vim/ftdetect/nginx.vim +++ b/sources_non_forked/nginx.vim/ftdetect/nginx.vim @@ -3,3 +3,4 @@ au BufRead,BufNewFile nginx*.conf set ft=nginx au BufRead,BufNewFile *nginx.conf set ft=nginx au BufRead,BufNewFile */etc/nginx/* set ft=nginx au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx +au BufRead,BufNewFile */nginx/*.conf set ft=nginx diff --git a/sources_non_forked/vim-abolish/README.markdown b/sources_non_forked/vim-abolish/README.markdown index beb696cb..e8dd0d03 100644 --- a/sources_non_forked/vim-abolish/README.markdown +++ b/sources_non_forked/vim-abolish/README.markdown @@ -120,8 +120,7 @@ Want to turn `fooBar` into `foo_bar`? Press `crs` (coerce to snake\_case). MixedCase (`crm`), camelCase (`crc`), snake\_case (`crs`), UPPER\_CASE (`cru`), dash-case (`cr-`), dot.case (`cr.`), space case (`cr`), and Title Case (`crt`) are all just 3 -keystrokes away. These commands support -[repeat.vim](https://github.com/tpope/vim-repeat). +keystrokes away. ## Installation diff --git a/sources_non_forked/vim-flake8/autoload/flake8.vim b/sources_non_forked/vim-flake8/autoload/flake8.vim index 06a1b6b4..81aedfd3 100644 --- a/sources_non_forked/vim-flake8/autoload/flake8.vim +++ b/sources_non_forked/vim-flake8/autoload/flake8.vim @@ -109,8 +109,10 @@ function! s:Flake8() " {{{ " read config call s:Setup() - if !executable(s:flake8_cmd) - echoerr "File " . s:flake8_cmd . " not found. Please install it first." + let l:executable = split(s:flake8_cmd)[0] + + if !executable(l:executable) + echoerr "File " . l:executable . " not found. Please install it first." return endif diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index 6dcd5ee7..bd4eced1 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -24,8 +24,23 @@ function! s:gsub(str,pat,rep) abort return substitute(a:str,'\v\C'.a:pat,a:rep,'g') endfunction +function! s:Uniq(list) abort + let i = 0 + let seen = {} + while i < len(a:list) + let str = string(a:list[i]) + if has_key(seen, str) + call remove(a:list, i) + else + let seen[str] = 1 + let i += 1 + endif + endwhile + return a:list +endfunction + function! s:winshell() abort - return &shell =~? 'cmd' || exists('+shellslash') && !&shellslash + return has('win32') && &shellcmdflag !~# '^-' endfunction function! s:shellesc(arg) abort @@ -46,14 +61,6 @@ function! s:fnameescape(file) abort endif endfunction -function! s:tempname() abort - let temp = resolve(tempname()) - if has('win32') - let temp = fnamemodify(fnamemodify(temp, ':h'), ':p').fnamemodify(temp, ':t') - endif - return temp -endfunction - function! s:throw(string) abort let v:errmsg = 'fugitive: '.a:string throw v:errmsg @@ -66,8 +73,8 @@ function! s:warn(str) abort let v:warningmsg = a:str endfunction -function! s:shellslash(path) abort - if s:winshell() +function! s:Slash(path) abort + if exists('+shellslash') return tr(a:path, '\', '/') else return a:path @@ -82,6 +89,23 @@ function! s:PlatformSlash(path) abort endif endfunction +function! s:Resolve(path) abort + let path = resolve(a:path) + if has('win32') + let path = s:PlatformSlash(fnamemodify(fnamemodify(path, ':h'), ':p') . fnamemodify(path, ':t')) + endif + return path +endfunction + +function! s:cpath(path, ...) abort + if exists('+fileignorecase') && &fileignorecase + let path = s:PlatformSlash(tolower(a:path)) + else + let path = s:PlatformSlash(a:path) + endif + return a:0 ? path ==# s:cpath(a:1) : path +endfunction + let s:executables = {} function! s:executable(binary) abort @@ -91,111 +115,6 @@ function! s:executable(binary) abort return s:executables[a:binary] endfunction -function! s:UserCommand() abort - return get(g:, 'fugitive_git_command', g:fugitive_git_executable) -endfunction - -function! s:System(cmd) abort - try - return system(a:cmd) - catch /^Vim\%((\a\+)\)\=:E484:/ - let opts = ['shell', 'shellcmdflag', 'shellredir', 'shellquote', 'shellxquote', 'shellxescape', 'shellslash'] - call filter(opts, 'exists("+".v:val) && !empty(eval("&".v:val))') - call map(opts, 'v:val."=".eval("&".v:val)') - call s:throw('failed to run `' . a:cmd . '` with ' . join(opts, ' ')) - endtry -endfunction - -function! s:Prepare(dir, ...) abort - let args = ['--git-dir=' . a:dir] + (a:000) - return g:fugitive_git_executable . ' ' . join(map(args, 's:shellesc(v:val)')) -endfunction - -let s:git_versions = {} -function! fugitive#GitVersion(...) abort - if !has_key(s:git_versions, g:fugitive_git_executable) - let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), "\\S\\+\\ze\n") - endif - return s:git_versions[g:fugitive_git_executable] -endfunction - -function! s:Tree(...) abort - return FugitiveTreeForGitDir(a:0 ? a:1 : get(b:, 'git_dir', '')) -endfunction - -function! s:TreeChomp(...) abort - let args = copy(type(a:1) == type([]) ? a:1 : a:000) - let dir = a:0 > 1 && type(a:1) == type([]) ? a:2 : b:git_dir - let tree = s:Tree(dir) - let pre = '' - if empty(tree) - let args = ['--git-dir=' . dir] . args - elseif s:cpath(tree) !=# s:cpath(getcwd()) - if fugitive#GitVersion() =~# '^[01]\.' - let pre = 'cd ' . s:shellesc(tree) . (s:winshell() ? ' & ' : '; ') - else - let args = ['-C', tree] + args - endif - endif - return s:sub(s:System(pre . g:fugitive_git_executable . ' ' . - \ join(map(args, 's:shellesc(v:val)'))), '\n$', '') -endfunction - -function! fugitive#RevParse(rev, ...) abort - let hash = system(s:Prepare(a:0 ? a:1 : b:git_dir, 'rev-parse', '--verify', a:rev))[0:-2] - if !v:shell_error && hash =~# '^\x\{40\}$' - return hash - endif - call s:throw('rev-parse '.a:rev.': '.hash) -endfunction - -function! fugitive#Config(name, ...) abort - let cmd = s:Prepare(a:0 ? a:1 : get(b:, 'git_dir', ''), 'config', '--get', a:name) - let out = matchstr(system(cmd), "[^\r\n]*") - return v:shell_error ? '' : out -endfunction - -function! s:Remote(dir) abort - let head = FugitiveHead(0, a:dir) - let remote = len(head) ? fugitive#Config('branch.' . head . '.remote') : '' - let i = 10 - while remote ==# '.' && i > 0 - let head = matchstr(fugitive#Config('branch.' . head . '.merge'), 'refs/heads/\zs.*') - let remote = len(head) ? fugitive#Config('branch.' . head . '.remote') : '' - let i -= 1 - endwhile - return remote =~# '\.\=$' ? 'origin' : remote -endfunction - -function! fugitive#RemoteUrl(...) abort - let dir = a:0 > 1 ? a:2 : get(b:, 'git_dir', '') - let remote = !a:0 || a:1 =~# '^\.\=$' ? s:Remote(dir) : a:1 - if fugitive#GitVersion() =~# '^[01]\.\|^2\.[0-6]\.' - return fugitive#Config('remote.' . remote . '.url') - endif - let cmd = s:Prepare(dir, 'remote', 'get-url', remote) - let out = substitute(system(cmd), "\n$", '', '') - return v:shell_error ? '' : out -endfunction - -function! s:recall() abort - let rev = s:sub(s:buffer().rev(), '^/', '') - if rev ==# ':' - return matchstr(getline('.'),'^.\=\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*') - elseif s:buffer().type('tree') - let file = matchstr(getline('.'), '\t\zs.*') - if empty(file) && line('.') > 2 - let file = s:sub(getline('.'), '/$', '') - endif - if !empty(file) && rev !~# ':$' - return rev . '/' . file - else - return rev . file - endif - endif - return rev -endfunction - function! s:map(mode, lhs, rhs, ...) abort let flags = (a:0 ? a:1 : '') . (a:rhs =~# '' ? '' : '