diff --git a/sources_non_forked/ale/ale_linters/ada/gcc.vim b/sources_non_forked/ale/ale_linters/ada/gcc.vim index d6f973ae..87496b81 100644 --- a/sources_non_forked/ale/ale_linters/ada/gcc.vim +++ b/sources_non_forked/ale/ale_linters/ada/gcc.vim @@ -12,7 +12,7 @@ function! ale_linters#ada#gcc#GetCommand(buffer) abort " the .ali file may be created even if no code generation is attempted. " The output file name must match the source file name (except for the " extension), so here we cannot use the null file as output. - let l:tmp_dir = fnamemodify(ale#engine#CreateDirectory(a:buffer), ':p') + let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p') let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o' " -gnatc: Check syntax and semantics only (no code generation attempted) @@ -48,7 +48,7 @@ endfunction call ale#linter#Define('ada', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('ada_gcc_executable'), -\ 'command_callback': 'ale_linters#ada#gcc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ada_gcc_executable')}, +\ 'command': function('ale_linters#ada#gcc#GetCommand'), \ 'callback': 'ale_linters#ada#gcc#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim index 99fff6c3..c4affa31 100644 --- a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim +++ b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim @@ -50,7 +50,7 @@ endfunction call ale#linter#Define('ansible', { \ 'name': 'ansible_lint', \ 'aliases': ['ansible', 'ansible-lint'], -\ 'executable_callback': 'ale_linters#ansible#ansible_lint#GetExecutable', +\ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'), \ 'command': '%e -p %t', \ 'callback': 'ale_linters#ansible#ansible_lint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/alex.vim b/sources_non_forked/ale/ale_linters/asciidoc/alex.vim index 79b04fc3..97976b2c 100644 --- a/sources_non_forked/ale/ale_linters/asciidoc/alex.vim +++ b/sources_non_forked/ale/ale_linters/asciidoc/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for asciidoc files -call ale#linter#Define('help', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('asciidoc', '--text') diff --git a/sources_non_forked/ale/ale_linters/asm/gcc.vim b/sources_non_forked/ale/ale_linters/asm/gcc.vim index fdd0ee83..72b293c0 100644 --- a/sources_non_forked/ale/ale_linters/asm/gcc.vim +++ b/sources_non_forked/ale/ale_linters/asm/gcc.vim @@ -28,7 +28,7 @@ endfunction call ale#linter#Define('asm', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('asm_gcc_executable'), -\ 'command_callback': 'ale_linters#asm#gcc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'asm_gcc_executable')}, +\ 'command': function('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 eb92e45e..f795c57d 100644 --- a/sources_non_forked/ale/ale_linters/awk/gawk.vim +++ b/sources_non_forked/ale/ale_linters/awk/gawk.vim @@ -15,8 +15,8 @@ endfunction call ale#linter#Define('awk', { \ 'name': 'gawk', -\ 'executable_callback': ale#VarFunc('awk_gawk_executable'), -\ 'command_callback': 'ale_linters#awk#gawk#GetCommand', +\ 'executable': {b -> ale#Var(b, 'awk_gawk_executable')}, +\ 'command': function('ale_linters#awk#gawk#GetCommand'), \ 'callback': 'ale#handlers#gawk#HandleGawkFormat', \ 'output_stream': 'both' \}) diff --git a/sources_non_forked/ale/ale_linters/bib/bibclean.vim b/sources_non_forked/ale/ale_linters/bib/bibclean.vim index 6750f22f..9056a9c3 100644 --- a/sources_non_forked/ale/ale_linters/bib/bibclean.vim +++ b/sources_non_forked/ale/ale_linters/bib/bibclean.vim @@ -11,9 +11,9 @@ endfunction function! ale_linters#bib#bibclean#get_type(str) abort if a:str is# '??' - return 'E' + return 'E' else - return 'W' + return 'W' endif endfunction @@ -36,30 +36,31 @@ function! ale_linters#bib#bibclean#Handle(buffer, lines) abort let l:msg = '' for l:line in a:lines - if empty(l:msg) - let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) + if empty(l:msg) + let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) - if !empty(l:mlist) - let l:msg = l:mlist[3] - let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) - endif - else - if l:type is# 'E' - let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) - else - let l:mlist = ale_linters#bib#bibclean#match_value(l:line) - endif + if !empty(l:mlist) + let l:msg = l:mlist[3] + let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) + endif + else + if l:type is# 'E' + let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) + else + let l:mlist = ale_linters#bib#bibclean#match_value(l:line) + endif - if !empty(l:mlist) - call add(l:output, { - \ 'lnum': l:mlist[1], - \ 'col': l:mlist[2], - \ 'text': l:msg, - \ 'type': l:type - \}) - let l:msg = '' - endif - endif + if !empty(l:mlist) + call add(l:output, { + \ 'lnum': l:mlist[1], + \ 'col': l:mlist[2], + \ 'text': l:msg, + \ 'type': l:type + \}) + + let l:msg = '' + endif + endif endfor return l:output @@ -67,8 +68,8 @@ endfunction call ale#linter#Define('bib', { \ 'name': 'bibclean', -\ 'executable_callback': ale#VarFunc('bib_bibclean_executable'), -\ 'command_callback': 'ale_linters#bib#bibclean#GetCommand', +\ 'executable': {b -> ale#Var(b, 'bib_bibclean_executable')}, +\ 'command': function('ale_linters#bib#bibclean#GetCommand'), \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#bib#bibclean#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/c/ccls.vim b/sources_non_forked/ale/ale_linters/c/ccls.vim index 5dc2339f..9e3dafe9 100644 --- a/sources_non_forked/ale/ale_linters/c/ccls.vim +++ b/sources_non_forked/ale/ale_linters/c/ccls.vim @@ -7,8 +7,8 @@ call ale#Set('c_ccls_init_options', {}) call ale#linter#Define('c', { \ 'name': 'ccls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('c_ccls_executable'), +\ 'executable': {b -> ale#Var(b, 'c_ccls_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', -\ 'initialization_options_callback':ale#VarFunc('c_ccls_init_options'), +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'c_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/c/clang.vim b/sources_non_forked/ale/ale_linters/c/clang.vim index f1bd675b..5b243bfe 100644 --- a/sources_non_forked/ale/ale_linters/c/clang.vim +++ b/sources_non_forked/ale/ale_linters/c/clang.vim @@ -18,7 +18,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'clang', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('c_clang_executable'), +\ 'executable': {b -> ale#Var(b, '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 6cad601a..918eadcc 100644 --- a/sources_non_forked/ale/ale_linters/c/clangd.vim +++ b/sources_non_forked/ale/ale_linters/c/clangd.vim @@ -17,7 +17,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'clangd', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('c_clangd_executable'), -\ 'command_callback': 'ale_linters#c#clangd#GetCommand', -\ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot', +\ 'executable': {b -> ale#Var(b, 'c_clangd_executable')}, +\ 'command': function('ale_linters#c#clangd#GetCommand'), +\ 'project_root': function('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 4f334655..6484f8af 100644 --- a/sources_non_forked/ale/ale_linters/c/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/c/clangtidy.vim @@ -35,8 +35,8 @@ endfunction call ale#linter#Define('c', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('c_clangtidy_executable'), -\ 'command_callback': 'ale_linters#c#clangtidy#GetCommand', +\ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, +\ 'command': function('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 5e8c7936..851f9f11 100644 --- a/sources_non_forked/ale/ale_linters/c/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -28,7 +28,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable_callback': ale#VarFunc('c_cppcheck_executable'), -\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand', +\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')}, +\ 'command': function('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 a20782a2..d2be9cd9 100644 --- a/sources_non_forked/ale/ale_linters/c/cquery.vim +++ b/sources_non_forked/ale/ale_linters/c/cquery.vim @@ -21,8 +21,8 @@ endfunction call ale#linter#Define('c', { \ 'name': 'cquery', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('c_cquery_executable'), +\ 'executable': {b -> ale#Var(b, 'c_cquery_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot', -\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions', +\ 'project_root': function('ale_linters#c#cquery#GetProjectRoot'), +\ 'initialization_options': function('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 7e1f6769..53c36716 100644 --- a/sources_non_forked/ale/ale_linters/c/flawfinder.vim +++ b/sources_non_forked/ale/ale_linters/c/flawfinder.vim @@ -7,19 +7,19 @@ call ale#Set('c_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) 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') + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') - return '%e -CDQS' - \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) - \ . l:minlevel - \ . ' %t' + return '%e -CDQS' + \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) + \ . l:minlevel + \ . ' %t' endfunction call ale#linter#Define('c', { \ 'name': 'flawfinder', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('c_flawfinder_executable'), -\ 'command_callback': 'ale_linters#c#flawfinder#GetCommand', +\ 'executable': {b -> ale#Var(b, 'c_flawfinder_executable')}, +\ 'command': function('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 60ecb712..ccb1912b 100644 --- a/sources_non_forked/ale/ale_linters/c/gcc.vim +++ b/sources_non_forked/ale/ale_linters/c/gcc.vim @@ -18,7 +18,7 @@ endfunction call ale#linter#Define('c', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('c_gcc_executable'), +\ 'executable': {b -> ale#Var(b, '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 c86336d6..48beba75 100644 --- a/sources_non_forked/ale/ale_linters/chef/foodcritic.vim +++ b/sources_non_forked/ale/ale_linters/chef/foodcritic.vim @@ -34,8 +34,8 @@ endfunction call ale#linter#Define('chef', { \ 'name': 'foodcritic', -\ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'), -\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand', +\ 'executable': {b -> ale#Var(b, 'chef_foodcritic_executable')}, +\ 'command': function('ale_linters#chef#foodcritic#GetCommand'), \ 'callback': 'ale_linters#chef#foodcritic#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/clojure/joker.vim b/sources_non_forked/ale/ale_linters/clojure/joker.vim index 2f61148b..1f17cd31 100644 --- a/sources_non_forked/ale/ale_linters/clojure/joker.vim +++ b/sources_non_forked/ale/ale_linters/clojure/joker.vim @@ -11,7 +11,7 @@ function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort let l:type = 'E' if l:match[4] is? 'Parse warning' - let l:type = 'W' + let l:type = 'W' endif call add(l:output, { diff --git a/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim b/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim index 78676518..d955a265 100644 --- a/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim +++ b/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim @@ -18,7 +18,7 @@ endfunction call ale#linter#Define('cmake', { \ 'name': 'cmakelint', -\ 'executable_callback': 'ale_linters#cmake#cmakelint#Executable', -\ 'command_callback': 'ale_linters#cmake#cmakelint#Command', +\ 'executable': function('ale_linters#cmake#cmakelint#Executable'), +\ 'command': function('ale_linters#cmake#cmakelint#Command'), \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/sources_non_forked/ale/ale_linters/coffee/coffee.vim b/sources_non_forked/ale/ale_linters/coffee/coffee.vim index f2539281..8e891639 100644 --- a/sources_non_forked/ale/ale_linters/coffee/coffee.vim +++ b/sources_non_forked/ale/ale_linters/coffee/coffee.vim @@ -16,8 +16,8 @@ endfunction call ale#linter#Define('coffee', { \ 'name': 'coffee', -\ 'executable_callback': 'ale_linters#coffee#coffee#GetExecutable', -\ 'command_callback': 'ale_linters#coffee#coffee#GetCommand', +\ 'executable': function('ale_linters#coffee#coffee#GetExecutable'), +\ 'command': function('ale_linters#coffee#coffee#GetCommand'), \ 'output_stream': 'stderr', \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim b/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim index 6d3df353..b7c85fa7 100644 --- a/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim +++ b/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim @@ -37,7 +37,7 @@ endfunction call ale#linter#Define('coffee', { \ 'name': 'coffeelint', -\ 'executable_callback': 'ale_linters#coffee#coffeelint#GetExecutable', -\ 'command_callback': 'ale_linters#coffee#coffeelint#GetCommand', +\ 'executable': function('ale_linters#coffee#coffeelint#GetExecutable'), +\ 'command': function('ale_linters#coffee#coffeelint#GetCommand'), \ 'callback': 'ale_linters#coffee#coffeelint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/ccls.vim b/sources_non_forked/ale/ale_linters/cpp/ccls.vim index 501fd685..b265ff70 100644 --- a/sources_non_forked/ale/ale_linters/cpp/ccls.vim +++ b/sources_non_forked/ale/ale_linters/cpp/ccls.vim @@ -7,8 +7,8 @@ call ale#Set('cpp_ccls_init_options', {}) call ale#linter#Define('cpp', { \ 'name': 'ccls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('cpp_ccls_executable'), +\ 'executable': {b -> ale#Var(b, 'cpp_ccls_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', -\ 'initialization_options_callback': ale#VarFunc('cpp_ccls_init_options'), +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'cpp_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clang.vim b/sources_non_forked/ale/ale_linters/cpp/clang.vim index 649c5993..5a465812 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clang.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clang.vim @@ -18,7 +18,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'clang', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('cpp_clang_executable'), +\ 'executable': {b -> ale#Var(b, '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 c66d6702..b511a413 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim @@ -27,8 +27,8 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'clangcheck', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'), -\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cpp_clangcheck_executable')}, +\ 'command': function('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 index 9139f054..4a8ff4f6 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangd.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangd.vim @@ -17,7 +17,7 @@ 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', +\ 'executable': {b -> ale#Var(b, 'cpp_clangd_executable')}, +\ 'command': function('ale_linters#cpp#clangd#GetCommand'), +\ 'project_root': function('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 9c3da8db..841b795f 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -29,8 +29,8 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'), -\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, +\ 'command': function('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 index cbbd0ccf..9b29ac9a 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clazy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clazy.vim @@ -25,8 +25,8 @@ 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', +\ 'executable': {b -> ale#Var(b, 'cpp_clazy_executable')}, +\ 'command': function('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 229d6133..5173d698 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -28,7 +28,7 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', -\ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'), -\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')}, +\ 'command': function('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 d135fa79..f1f6ce7f 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cpplint.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cpplint.vim @@ -13,8 +13,8 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cpplint', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'), -\ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cpp_cpplint_executable')}, +\ 'command': function('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 b1c81989..0dd9f6ad 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cquery.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cquery.vim @@ -21,8 +21,8 @@ endfunction call ale#linter#Define('cpp', { \ 'name': 'cquery', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('cpp_cquery_executable'), +\ 'executable': {b -> ale#Var(b, 'cpp_cquery_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot', -\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions', +\ 'project_root': function('ale_linters#cpp#cquery#GetProjectRoot'), +\ 'initialization_options': function('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 4f669bff..5bfdea22 100644 --- a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim +++ b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim @@ -7,19 +7,19 @@ call ale#Set('cpp_flawfinder_minlevel', 1) call ale#Set('c_flawfinder_error_severity', 6) 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') + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') - return '%e -CDQS' - \ . ale#Var(a:buffer, 'cpp_flawfinder_options') - \ . l:minlevel - \ . ' %t' + return '%e -CDQS' + \ . ale#Var(a:buffer, 'cpp_flawfinder_options') + \ . l:minlevel + \ . ' %t' endfunction call ale#linter#Define('cpp', { \ 'name': 'flawfinder', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'), -\ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cpp_flawfinder_executable')}, +\ 'command': function('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 9935b0bb..831620d5 100644 --- a/sources_non_forked/ale/ale_linters/cpp/gcc.vim +++ b/sources_non_forked/ale/ale_linters/cpp/gcc.vim @@ -19,7 +19,7 @@ call ale#linter#Define('cpp', { \ 'name': 'gcc', \ 'aliases': ['g++'], \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('cpp_gcc_executable'), +\ 'executable': {b -> ale#Var(b, '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/crystal/crystal.vim b/sources_non_forked/ale/ale_linters/crystal/crystal.vim index 81579d63..3c2fefb7 100644 --- a/sources_non_forked/ale/ale_linters/crystal/crystal.vim +++ b/sources_non_forked/ale/ale_linters/crystal/crystal.vim @@ -26,6 +26,6 @@ call ale#linter#Define('crystal', { \ 'executable': 'crystal', \ 'output_stream': 'both', \ 'lint_file': 1, -\ 'command_callback': 'ale_linters#crystal#crystal#GetCommand', +\ 'command': function('ale_linters#crystal#crystal#GetCommand'), \ 'callback': 'ale_linters#crystal#crystal#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/cs/mcs.vim b/sources_non_forked/ale/ale_linters/cs/mcs.vim index 8738026d..1b373e73 100644 --- a/sources_non_forked/ale/ale_linters/cs/mcs.vim +++ b/sources_non_forked/ale/ale_linters/cs/mcs.vim @@ -32,6 +32,6 @@ call ale#linter#Define('cs',{ \ 'name': 'mcs', \ 'output_stream': 'stderr', \ 'executable': 'mcs', -\ 'command_callback': 'ale_linters#cs#mcs#GetCommand', +\ 'command': function('ale_linters#cs#mcs#GetCommand'), \ 'callback': 'ale_linters#cs#mcs#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/cs/mcsc.vim b/sources_non_forked/ale/ale_linters/cs/mcsc.vim index 1561661e..dd067eba 100644 --- a/sources_non_forked/ale/ale_linters/cs/mcsc.vim +++ b/sources_non_forked/ale/ale_linters/cs/mcsc.vim @@ -30,7 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort " register temporary module target file with ale " register temporary module target file with ALE. - let l:out = ale#engine#CreateFile(a:buffer) + let l:out = ale#command#CreateFile(a:buffer) " The code is compiled as a module and the output is redirected to a " temporary file. @@ -75,7 +75,7 @@ call ale#linter#Define('cs',{ \ 'name': 'mcsc', \ 'output_stream': 'stderr', \ 'executable': 'mcs', -\ 'command_callback': 'ale_linters#cs#mcsc#GetCommand', +\ 'command': function('ale_linters#cs#mcsc#GetCommand'), \ 'callback': 'ale_linters#cs#mcsc#Handle', \ 'lint_file': 1 \}) diff --git a/sources_non_forked/ale/ale_linters/css/csslint.vim b/sources_non_forked/ale/ale_linters/css/csslint.vim index 98b7fdd4..50c21ce2 100644 --- a/sources_non_forked/ale/ale_linters/css/csslint.vim +++ b/sources_non_forked/ale/ale_linters/css/csslint.vim @@ -13,6 +13,6 @@ endfunction call ale#linter#Define('css', { \ 'name': 'csslint', \ 'executable': 'csslint', -\ 'command_callback': 'ale_linters#css#csslint#GetCommand', +\ 'command': function('ale_linters#css#csslint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index 6f8bef68..38cb0e0b 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -11,9 +11,9 @@ endfunction call ale#linter#Define('css', { \ 'name': 'stylelint', -\ 'executable_callback': ale#node#FindExecutableFunc('css_stylelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'css_stylelint', [ \ 'node_modules/.bin/stylelint', -\ ]), -\ 'command_callback': 'ale_linters#css#stylelint#GetCommand', +\ ])}, +\ 'command': function('ale_linters#css#stylelint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim index e8ae09ff..0cfd815e 100644 --- a/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim +++ b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim @@ -41,6 +41,6 @@ endfunction call ale#linter#Define('cucumber', { \ 'name': 'cucumber', \ 'executable': 'cucumber', -\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand', +\ 'command': function('ale_linters#cucumber#cucumber#GetCommand'), \ 'callback': 'ale_linters#cucumber#cucumber#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim index f4442cb8..f3af07b6 100644 --- a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim +++ b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim @@ -7,7 +7,7 @@ call ale#Set('cuda_nvcc_options', '-std=c++11') 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) + " call ale#command#ManageFile(a:buffer, l:output_file) return '%e -cuda' \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) @@ -42,8 +42,8 @@ endfunction call ale#linter#Define('cuda', { \ 'name': 'nvcc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'), -\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'cuda_nvcc_executable')}, +\ 'command': function('ale_linters#cuda#nvcc#GetCommand'), \ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/d/dls.vim b/sources_non_forked/ale/ale_linters/d/dls.vim index 7210d21e..78d1c152 100644 --- a/sources_non_forked/ale/ale_linters/d/dls.vim +++ b/sources_non_forked/ale/ale_linters/d/dls.vim @@ -16,7 +16,7 @@ endfunction call ale#linter#Define('d', { \ 'name': 'dls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#d#dls#GetExecutable', -\ 'command_callback': 'ale_linters#d#dls#GetExecutable', -\ 'project_root_callback': 'ale_linters#d#dls#FindProjectRoot', +\ 'executable': function('ale_linters#d#dls#GetExecutable'), +\ 'command': function('ale_linters#d#dls#GetExecutable'), +\ 'project_root': function('ale_linters#d#dls#FindProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim b/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim index 26817df5..0a4d9742 100644 --- a/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim +++ b/sources_non_forked/ale/ale_linters/dart/dartanalyzer.vim @@ -29,8 +29,8 @@ endfunction call ale#linter#Define('dart', { \ 'name': 'dartanalyzer', -\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'), -\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand', +\ 'executable': {b -> ale#Var(b, 'dart_dartanalyzer_executable')}, +\ 'command': function('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 8e0c139b..d0e639c8 100644 --- a/sources_non_forked/ale/ale_linters/dart/language_server.vim +++ b/sources_non_forked/ale/ale_linters/dart/language_server.vim @@ -14,7 +14,7 @@ endfunction call ale#linter#Define('dart', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('dart_language_server_executable'), +\ 'executable': {b -> ale#Var(b, 'dart_language_server_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot', +\ 'project_root': function('ale_linters#dart#language_server#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim index a5a846f2..95768b12 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim @@ -55,7 +55,7 @@ endfunction call ale#linter#Define('dockerfile', { \ 'name': 'dockerfile_lint', -\ 'executable_callback': ale#VarFunc('dockerfile_dockerfile_lint_executable'), -\ 'command_callback': 'ale_linters#dockerfile#dockerfile_lint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'dockerfile_dockerfile_lint_executable')}, +\ 'command': function('ale_linters#dockerfile#dockerfile_lint#GetCommand'), \ 'callback': 'ale_linters#dockerfile#dockerfile_lint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim index dc0f5b9e..e57cd76d 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim @@ -93,7 +93,7 @@ endfunction call ale#linter#Define('dockerfile', { \ 'name': 'hadolint', -\ 'executable_callback': 'ale_linters#dockerfile#hadolint#GetExecutable', -\ 'command_callback': 'ale_linters#dockerfile#hadolint#GetCommand', +\ 'executable': function('ale_linters#dockerfile#hadolint#GetExecutable'), +\ 'command': function('ale_linters#dockerfile#hadolint#GetCommand'), \ 'callback': 'ale_linters#dockerfile#hadolint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/credo.vim b/sources_non_forked/ale/ale_linters/elixir/credo.vim index d778471c..8431c0df 100644 --- a/sources_non_forked/ale/ale_linters/elixir/credo.vim +++ b/sources_non_forked/ale/ale_linters/elixir/credo.vim @@ -47,6 +47,6 @@ endfunction call ale#linter#Define('elixir', { \ 'name': 'credo', \ 'executable': 'mix', -\ 'command_callback': 'ale_linters#elixir#credo#GetCommand', +\ 'command': function('ale_linters#elixir#credo#GetCommand'), \ 'callback': 'ale_linters#elixir#credo#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim index d28d3c70..c7da7757 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim @@ -35,7 +35,7 @@ endfunction call ale#linter#Define('elixir', { \ 'name': 'dialyxir', \ 'executable': 'mix', -\ 'command_callback': 'ale_linters#elixir#dialyxir#GetCommand', +\ 'command': function('ale_linters#elixir#dialyxir#GetCommand'), \ 'callback': 'ale_linters#elixir#dialyxir#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/dogma.vim b/sources_non_forked/ale/ale_linters/elixir/dogma.vim index dcfb6f28..1c721158 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dogma.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dogma.vim @@ -39,7 +39,7 @@ endfunction call ale#linter#Define('elixir', { \ 'name': 'dogma', \ 'executable': 'mix', -\ 'command_callback': 'ale_linters#elixir#dogma#GetCommand', +\ 'command': function('ale_linters#elixir#dogma#GetCommand'), \ 'lint_file': 1, \ 'callback': 'ale_linters#elixir#dogma#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim index 3b299ec6..d5db7cd0 100644 --- a/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim +++ b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim @@ -14,8 +14,8 @@ endfunction call ale#linter#Define('elixir', { \ 'name': 'elixir-ls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', -\ 'command_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', -\ 'project_root_callback': 'ale#handlers#elixir#FindMixUmbrellaRoot', -\ 'lsp_config_callback': ale#VarFunc('elixir_elixir_ls_config'), +\ 'executable': function('ale_linters#elixir#elixir_ls#GetExecutable'), +\ 'command': function('ale_linters#elixir#elixir_ls#GetExecutable'), +\ 'project_root': function('ale#handlers#elixir#FindMixUmbrellaRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'elixir_elixir_ls_config')}, \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/mix.vim b/sources_non_forked/ale/ale_linters/elixir/mix.vim index dc3c1818..abf5d0aa 100644 --- a/sources_non_forked/ale/ale_linters/elixir/mix.vim +++ b/sources_non_forked/ale/ale_linters/elixir/mix.vim @@ -32,7 +32,7 @@ endfunction function! ale_linters#elixir#mix#GetCommand(buffer) abort let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - let l:temp_dir = ale#engine#CreateDirectory(a:buffer) + let l:temp_dir = ale#command#CreateDirectory(a:buffer) let l:mix_build_path = has('win32') \ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&' @@ -46,7 +46,7 @@ endfunction call ale#linter#Define('elixir', { \ 'name': 'mix', \ 'executable': 'mix', -\ 'command_callback': 'ale_linters#elixir#mix#GetCommand', +\ 'command': function('ale_linters#elixir#mix#GetCommand'), \ 'callback': 'ale_linters#elixir#mix#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index 76622028..6b93257f 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -189,7 +189,10 @@ endfunction " Return the command to execute the linter in the projects directory. " If it doesn't, then this will fail when imports are needed. function! ale_linters#elm#make#GetCommand(buffer) abort + let l:executable = ale_linters#elm#make#GetExecutable(a:buffer) let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) + let l:is_using_elm_test = l:executable =~# 'elm-test$' if empty(l:root_dir) let l:dir_set_cmd = '' @@ -197,11 +200,20 @@ function! ale_linters#elm#make#GetCommand(buffer) abort let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' endif + " elm-test needs to know the path of elm-make if elm isn't installed globally. + " https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler + if l:is_v19 && l:is_using_elm_test + let l:elm_make_executable = ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + let l:elm_test_compiler_flag = ' --compiler ' . l:elm_make_executable . ' ' + else + let l:elm_test_compiler_flag = ' ' + endif + " The elm compiler, at the time of this writing, uses '/dev/null' as " 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 - return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t' + return l:dir_set_cmd . '%e make --report=json --output=/dev/null' . l:elm_test_compiler_flag . '%t' endfunction function! ale_linters#elm#make#GetExecutable(buffer) abort @@ -210,10 +222,10 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort if l:is_test && l:is_v19 return ale#node#FindExecutable( -\ a:buffer, -\ 'elm_make', -\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] -\ ) + \ a:buffer, + \ 'elm_make', + \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] + \) else return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) endif @@ -221,8 +233,8 @@ endfunction call ale#linter#Define('elm', { \ 'name': 'make', -\ 'executable_callback': 'ale_linters#elm#make#GetExecutable', +\ 'executable': function('ale_linters#elm#make#GetExecutable'), \ 'output_stream': 'both', -\ 'command_callback': 'ale_linters#elm#make#GetCommand', +\ 'command': function('ale_linters#elm#make#GetCommand'), \ 'callback': 'ale_linters#elm#make#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/erlc.vim b/sources_non_forked/ale/ale_linters/erlang/erlc.vim index 0bdb4dea..a83bacc3 100644 --- a/sources_non_forked/ale/ale_linters/erlang/erlc.vim +++ b/sources_non_forked/ale/ale_linters/erlang/erlc.vim @@ -4,7 +4,7 @@ let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '') function! ale_linters#erlang#erlc#GetCommand(buffer) abort let l:output_file = ale#util#Tempname() - call ale#engine#ManageFile(a:buffer, l:output_file) + call ale#command#ManageFile(a:buffer, l:output_file) return 'erlc -o ' . ale#Escape(l:output_file) \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') @@ -91,6 +91,6 @@ endfunction call ale#linter#Define('erlang', { \ 'name': 'erlc', \ 'executable': 'erlc', -\ 'command_callback': 'ale_linters#erlang#erlc#GetCommand', +\ 'command': function('ale_linters#erlang#erlc#GetCommand'), \ 'callback': 'ale_linters#erlang#erlc#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim index 5b679743..2b7276a1 100644 --- a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim +++ b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim @@ -26,7 +26,7 @@ endfunction call ale#linter#Define('erlang', { \ 'name': 'syntaxerl', -\ 'executable_callback': ale#VarFunc('erlang_syntaxerl_executable'), +\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')}, \ 'command_chain': [ \ {'callback': {-> '%e -h'}}, \ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/eruby/erb.vim b/sources_non_forked/ale/ale_linters/eruby/erb.vim index 61d97032..f3438320 100644 --- a/sources_non_forked/ale/ale_linters/eruby/erb.vim +++ b/sources_non_forked/ale/ale_linters/eruby/erb.vim @@ -19,7 +19,7 @@ call ale#linter#Define('eruby', { \ 'aliases': ['erubylint'], \ 'executable': 'erb', \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#eruby#erb#GetCommand', +\ 'command': function('ale_linters#eruby#erb#GetCommand'), \ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', \}) diff --git a/sources_non_forked/ale/ale_linters/eruby/erubis.vim b/sources_non_forked/ale/ale_linters/eruby/erubis.vim index 1ebd4a05..755c5803 100644 --- a/sources_non_forked/ale/ale_linters/eruby/erubis.vim +++ b/sources_non_forked/ale/ale_linters/eruby/erubis.vim @@ -18,6 +18,6 @@ call ale#linter#Define('eruby', { \ 'name': 'erubis', \ 'executable': 'erubis', \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#eruby#erubis#GetCommand', +\ 'command': function('ale_linters#eruby#erubis#GetCommand'), \ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', \}) diff --git a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim index 24f112e4..e68bb51d 100644 --- a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim +++ b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim @@ -56,7 +56,7 @@ endfunction call ale#linter#Define('eruby', { \ 'name': 'ruumba', -\ 'executable_callback': ale#VarFunc('eruby_ruumba_executable'), -\ 'command_callback': 'ale_linters#eruby#ruumba#GetCommand', +\ 'executable': {b -> ale#Var(b, 'eruby_ruumba_executable')}, +\ 'command': function('ale_linters#eruby#ruumba#GetCommand'), \ 'callback': 'ale_linters#eruby#ruumba#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/fortran/gcc.vim b/sources_non_forked/ale/ale_linters/fortran/gcc.vim index f1595789..6e97d6fd 100644 --- a/sources_non_forked/ale/ale_linters/fortran/gcc.vim +++ b/sources_non_forked/ale/ale_linters/fortran/gcc.vim @@ -66,7 +66,7 @@ endfunction call ale#linter#Define('fortran', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('fortran_gcc_executable'), -\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'fortran_gcc_executable')}, +\ 'command': function('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 4e5f5dc4..00aa0577 100644 --- a/sources_non_forked/ale/ale_linters/fortran/language_server.vim +++ b/sources_non_forked/ale/ale_linters/fortran/language_server.vim @@ -13,7 +13,7 @@ endfunction call ale#linter#Define('fortran', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('fortran_language_server_executable'), +\ 'executable': {b -> ale#Var(b, 'fortran_language_server_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot', +\ 'project_root': function('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 ab8f143b..ffb25d33 100644 --- a/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim +++ b/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim @@ -27,7 +27,7 @@ endfunction call ale#linter#Define('fuse', { \ 'name': 'fusionlint', -\ 'executable_callback': ale#VarFunc('fuse_fusionlint_executable'), -\ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'fuse_fusionlint_executable')}, +\ 'command': function('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 a9c4822d..4b9cec63 100644 --- a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim +++ b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim @@ -45,7 +45,7 @@ endfunction call ale#linter#Define('gitcommit', { \ 'name': 'gitlint', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#gitcommit#gitlint#GetExecutable', -\ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand', +\ 'executable': function('ale_linters#gitcommit#gitlint#GetExecutable'), +\ 'command': function('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 d55a5e7c..bbddce90 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslang.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslang.vim @@ -34,7 +34,7 @@ endfunction call ale#linter#Define('glsl', { \ 'name': 'glslang', -\ 'executable_callback': ale#VarFunc('glsl_glslang_executable'), -\ 'command_callback': 'ale_linters#glsl#glslang#GetCommand', +\ 'executable': {b -> ale#Var(b, 'glsl_glslang_executable')}, +\ 'command': function('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 8c6d9bd9..b62844c7 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslls.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslls.vim @@ -24,7 +24,7 @@ endfunction call ale#linter#Define('glsl', { \ 'name': 'glslls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('glsl_glslls_executable'), -\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand', -\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot', +\ 'executable': {b -> ale#Var(b, 'glsl_glslls_executable')}, +\ 'command': function('ale_linters#glsl#glslls#GetCommand'), +\ 'project_root': function('ale_linters#glsl#glslls#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/go/bingo.vim b/sources_non_forked/ale/ale_linters/go/bingo.vim index ba80fbe8..e446bdcc 100644 --- a/sources_non_forked/ale/ale_linters/go/bingo.vim +++ b/sources_non_forked/ale/ale_linters/go/bingo.vim @@ -23,7 +23,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'bingo', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('go_bingo_executable'), -\ 'command_callback': 'ale_linters#go#bingo#GetCommand', -\ 'project_root_callback': 'ale_linters#go#bingo#FindProjectRoot', +\ 'executable': {b -> ale#Var(b, 'go_bingo_executable')}, +\ 'command': function('ale_linters#go#bingo#GetCommand'), +\ 'project_root': function('ale_linters#go#bingo#FindProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/go/gobuild.vim b/sources_non_forked/ale/ale_linters/go/gobuild.vim index cef1ff88..374ded35 100644 --- a/sources_non_forked/ale/ale_linters/go/gobuild.vim +++ b/sources_non_forked/ale/ale_linters/go/gobuild.vim @@ -48,8 +48,8 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], -\ 'executable_callback': ale#VarFunc('go_go_executable'), -\ 'command_callback': 'ale_linters#go#gobuild#GetCommand', +\ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'command': function('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/golangci_lint.vim b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim index dd9a3c64..357f7949 100644 --- a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim +++ b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim @@ -49,8 +49,8 @@ endfunction call ale#linter#Define('go', { \ 'name': 'golangci-lint', -\ 'executable_callback': ale#VarFunc('go_golangci_lint_executable'), -\ 'command_callback': 'ale_linters#go#golangci_lint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')}, +\ 'command': function('ale_linters#go#golangci_lint#GetCommand'), \ 'callback': 'ale_linters#go#golangci_lint#Handler', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/go/golint.vim b/sources_non_forked/ale/ale_linters/go/golint.vim index 4bf14fcc..765e1477 100644 --- a/sources_non_forked/ale/ale_linters/go/golint.vim +++ b/sources_non_forked/ale/ale_linters/go/golint.vim @@ -15,7 +15,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'golint', \ 'output_stream': 'both', -\ 'executable_callback': ale#VarFunc('go_golint_executable'), -\ 'command_callback': 'ale_linters#go#golint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'go_golint_executable')}, +\ 'command': function('ale_linters#go#golint#GetCommand'), \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/sources_non_forked/ale/ale_linters/go/gometalinter.vim b/sources_non_forked/ale/ale_linters/go/gometalinter.vim index d005e1d2..19d70a81 100644 --- a/sources_non_forked/ale/ale_linters/go/gometalinter.vim +++ b/sources_non_forked/ale/ale_linters/go/gometalinter.vim @@ -50,8 +50,8 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gometalinter', -\ 'executable_callback': ale#VarFunc('go_gometalinter_executable'), -\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand', +\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')}, +\ 'command': function('ale_linters#go#gometalinter#GetCommand'), \ 'callback': 'ale_linters#go#gometalinter#Handler', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/go/gosimple.vim b/sources_non_forked/ale/ale_linters/go/gosimple.vim index dbdc3fcf..281a0e53 100644 --- a/sources_non_forked/ale/ale_linters/go/gosimple.vim +++ b/sources_non_forked/ale/ale_linters/go/gosimple.vim @@ -8,7 +8,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gosimple', \ 'executable': 'gosimple', -\ 'command_callback': 'ale_linters#go#gosimple#GetCommand', +\ 'command': function('ale_linters#go#gosimple#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gotype.vim b/sources_non_forked/ale/ale_linters/go/gotype.vim index a678e0f3..159df892 100644 --- a/sources_non_forked/ale/ale_linters/go/gotype.vim +++ b/sources_non_forked/ale/ale_linters/go/gotype.vim @@ -13,7 +13,7 @@ call ale#linter#Define('go', { \ 'name': 'gotype', \ 'output_stream': 'stderr', \ 'executable': 'gotype', -\ 'command_callback': 'ale_linters#go#gotype#GetCommand', +\ 'command': function('ale_linters#go#gotype#GetCommand'), \ 'callback': 'ale#handlers#go#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 3d0d2adf..bb81d5d0 100644 --- a/sources_non_forked/ale/ale_linters/go/govet.vim +++ b/sources_non_forked/ale/ale_linters/go/govet.vim @@ -20,8 +20,8 @@ call ale#linter#Define('go', { \ 'name': 'govet', \ 'aliases': ['go vet'], \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('go_go_executable'), -\ 'command_callback': 'ale_linters#go#govet#GetCommand', +\ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'command': function('ale_linters#go#govet#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/go/langserver.vim b/sources_non_forked/ale/ale_linters/go/langserver.vim index df956483..776186c7 100644 --- a/sources_non_forked/ale/ale_linters/go/langserver.vim +++ b/sources_non_forked/ale/ale_linters/go/langserver.vim @@ -10,8 +10,8 @@ function! ale_linters#go#langserver#GetCommand(buffer) abort let l:options = substitute(l:options, '-gocodecompletion', '', 'g') let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1') - if(ale#Var(a:buffer, 'completion_enabled') == 1) - call add(l:options, '-gocodecompletion') + if ale#Var(a:buffer, 'completion_enabled') + call add(l:options, '-gocodecompletion') endif let l:options = uniq(sort(l:options)) @@ -22,7 +22,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'golangserver', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('go_langserver_executable'), -\ 'command_callback': 'ale_linters#go#langserver#GetCommand', -\ 'project_root_callback': 'ale#go#FindProjectRoot', +\ 'executable': {b -> ale#Var(b, 'go_langserver_executable')}, +\ 'command': function('ale_linters#go#langserver#GetCommand'), +\ 'project_root': function('ale#go#FindProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/go/staticcheck.vim b/sources_non_forked/ale/ale_linters/go/staticcheck.vim index a3464015..26fe0193 100644 --- a/sources_non_forked/ale/ale_linters/go/staticcheck.vim +++ b/sources_non_forked/ale/ale_linters/go/staticcheck.vim @@ -26,7 +26,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'staticcheck', \ 'executable': 'staticcheck', -\ 'command_callback': 'ale_linters#go#staticcheck#GetCommand', +\ 'command': function('ale_linters#go#staticcheck#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/graphql/eslint.vim b/sources_non_forked/ale/ale_linters/graphql/eslint.vim index dfcbf9d9..654b8c17 100644 --- a/sources_non_forked/ale/ale_linters/graphql/eslint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/eslint.vim @@ -3,7 +3,7 @@ call ale#linter#Define('graphql', { \ 'name': 'eslint', -\ 'executable_callback': 'ale#handlers#eslint#GetExecutable', -\ 'command_callback': 'ale#handlers#eslint#GetCommand', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim index e45bf4c8..d5029de1 100644 --- a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim @@ -10,6 +10,6 @@ endfunction call ale#linter#Define('graphql', { \ 'name': 'gqlint', \ 'executable': 'gqlint', -\ 'command_callback': 'ale_linters#graphql#gqlint#GetCommand', +\ 'command': function('ale_linters#graphql#gqlint#GetCommand'), \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/sources_non_forked/ale/ale_linters/hack/hack.vim b/sources_non_forked/ale/ale_linters/hack/hack.vim index aea428cc..822b5c87 100644 --- a/sources_non_forked/ale/ale_linters/hack/hack.vim +++ b/sources_non_forked/ale/ale_linters/hack/hack.vim @@ -16,7 +16,7 @@ endfunction call ale#linter#Define('hack', { \ 'name': 'hack', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable', +\ 'executable': function('ale_linters#hack#hack#GetExecutable'), \ 'command': '%e lsp --from vim-ale', -\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot', +\ 'project_root': function('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 index 710b7b25..5e6d4dec 100644 --- a/sources_non_forked/ale/ale_linters/hack/hhast.vim +++ b/sources_non_forked/ale/ale_linters/hack/hhast.vim @@ -9,7 +9,7 @@ function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') if empty(l:hhconfig) - return '' + return '' endif let l:root = fnamemodify(l:hhconfig, ':h') @@ -33,8 +33,8 @@ endfunction call ale#linter#Define('hack', { \ 'name': 'hhast', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable', +\ 'executable': function('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', +\ 'project_root': function('ale_linters#hack#hhast#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#hack#hhast#GetInitializationOptions'), \}) diff --git a/sources_non_forked/ale/ale_linters/haml/hamllint.vim b/sources_non_forked/ale/ale_linters/haml/hamllint.vim index 6598f81a..7d7278aa 100644 --- a/sources_non_forked/ale/ale_linters/haml/hamllint.vim +++ b/sources_non_forked/ale/ale_linters/haml/hamllint.vim @@ -51,7 +51,7 @@ endfunction call ale#linter#Define('haml', { \ 'name': 'hamllint', -\ 'executable_callback': 'ale_linters#haml#hamllint#GetExecutable', -\ 'command_callback': 'ale_linters#haml#hamllint#GetCommand', +\ 'executable': function('ale_linters#haml#hamllint#GetExecutable'), +\ 'command': function('ale_linters#haml#hamllint#GetCommand'), \ 'callback': 'ale_linters#haml#hamllint#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 4fc0f20d..74bd6a99 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -31,9 +31,9 @@ endfunction call ale#linter#Define('handlebars', { \ 'name': 'ember-template-lint', -\ 'executable_callback': ale#node#FindExecutableFunc('handlebars_embertemplatelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, '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/cabal_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim index 003adf5d..59978e7e 100644 --- a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim @@ -14,6 +14,6 @@ call ale#linter#Define('haskell', { \ 'aliases': ['cabal-ghc'], \ 'output_stream': 'stderr', \ 'executable': 'cabal', -\ 'command_callback': 'ale_linters#haskell#cabal_ghc#GetCommand', +\ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/ghc.vim b/sources_non_forked/ale/ale_linters/haskell/ghc.vim index daf91c8f..9c3906b2 100644 --- a/sources_non_forked/ale/ale_linters/haskell/ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/ghc.vim @@ -13,6 +13,6 @@ call ale#linter#Define('haskell', { \ 'name': 'ghc', \ 'output_stream': 'stderr', \ 'executable': 'ghc', -\ 'command_callback': 'ale_linters#haskell#ghc#GetCommand', +\ 'command': function('ale_linters#haskell#ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim b/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim index 9762be7a..30e96b40 100644 --- a/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim +++ b/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim @@ -13,7 +13,7 @@ endfunction call ale#linter#Define('haskell', { \ 'name': 'ghc_mod', \ 'aliases': ['ghc-mod'], -\ 'executable_callback': ale#VarFunc('haskell_ghc_mod_executable'), -\ 'command_callback': 'ale_linters#haskell#ghc_mod#GetCommand', +\ 'executable': {b -> ale#Var(b, 'haskell_ghc_mod_executable')}, +\ 'command': function('ale_linters#haskell#ghc_mod#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim index cc5ce56f..3e55e4f0 100644 --- a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim +++ b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim @@ -14,7 +14,7 @@ endfunction call ale#linter#Define('haskell', { \ 'name': 'hdevtools', -\ 'executable_callback': ale#VarFunc('haskell_hdevtools_executable'), -\ 'command_callback': 'ale_linters#haskell#hdevtools#GetCommand', +\ 'executable': {b -> ale#Var(b, 'haskell_hdevtools_executable')}, +\ 'command': function('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 index 3ff1180a..c4b5f1df 100644 --- a/sources_non_forked/ale/ale_linters/haskell/hie.vim +++ b/sources_non_forked/ale/ale_linters/haskell/hie.vim @@ -9,39 +9,33 @@ function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort " 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 - + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) 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') + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') endif - return l:project_file + return fnamemodify(l:project_file, ':h') endfunction function! ale_linters#haskell#hie#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'haskell_hie_executable') return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie') -\ . ' --lsp' + \ . ' --lsp' endfunction call ale#linter#Define('haskell', { \ 'name': 'hie', \ 'lsp': 'stdio', -\ 'command_callback': 'ale_linters#haskell#hie#GetCommand', -\ 'executable_callback': ale#VarFunc('haskell_hie_executable'), -\ 'project_root_callback': 'ale_linters#haskell#hie#GetProjectRoot', +\ 'command': function('ale_linters#haskell#hie#GetCommand'), +\ 'executable': {b -> ale#Var(b, 'haskell_hie_executable')}, +\ 'project_root': function('ale_linters#haskell#hie#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hlint.vim b/sources_non_forked/ale/ale_linters/haskell/hlint.vim index 0cc7437f..1425251a 100644 --- a/sources_non_forked/ale/ale_linters/haskell/hlint.vim +++ b/sources_non_forked/ale/ale_linters/haskell/hlint.vim @@ -40,7 +40,7 @@ endfunction call ale#linter#Define('haskell', { \ 'name': 'hlint', -\ 'executable_callback': ale#VarFunc('haskell_hlint_executable'), -\ 'command_callback': 'ale_linters#haskell#hlint#GetCommand' , +\ 'executable': {b -> ale#Var(b, 'haskell_hlint_executable')}, +\ 'command': function('ale_linters#haskell#hlint#GetCommand') , \ 'callback': 'ale_linters#haskell#hlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_build.vim b/sources_non_forked/ale/ale_linters/haskell/stack_build.vim index 95a54587..8f2d9fd9 100644 --- a/sources_non_forked/ale/ale_linters/haskell/stack_build.vim +++ b/sources_non_forked/ale/ale_linters/haskell/stack_build.vim @@ -16,8 +16,8 @@ call ale#linter#Define('haskell', { \ 'name': 'stack_build', \ 'aliases': ['stack-build'], \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale#handlers#haskell#GetStackExecutable', -\ 'command_callback': 'ale_linters#haskell#stack_build#GetCommand', +\ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'command': function('ale_linters#haskell#stack_build#GetCommand'), \ 'lint_file': 1, \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim index 8f42b96c..06af7f6d 100644 --- a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim @@ -1,11 +1,20 @@ " Author: w0rp " Description: ghc for Haskell files, using Stack +call ale#Set('haskell_stack_ghc_options', '-fno-code -v0') + +function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort + return ale#handlers#haskell#GetStackExecutable(a:buffer) + \ . ' ghc -- ' + \ . ale#Var(a:buffer, 'haskell_stack_ghc_options') + \ . ' %t' +endfunction + call ale#linter#Define('haskell', { \ 'name': 'stack_ghc', \ 'aliases': ['stack-ghc'], \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale#handlers#haskell#GetStackExecutable', -\ 'command': 'stack ghc -- -fno-code -v0 %t', +\ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/help/alex.vim b/sources_non_forked/ale/ale_linters/help/alex.vim index 21b23b4f..9be00a82 100644 --- a/sources_non_forked/ale/ale_linters/help/alex.vim +++ b/sources_non_forked/ale/ale_linters/help/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for help files -call ale#linter#Define('help', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('help', '--text') diff --git a/sources_non_forked/ale/ale_linters/html/alex.vim b/sources_non_forked/ale/ale_linters/html/alex.vim index 5a1f61e9..97756753 100644 --- a/sources_non_forked/ale/ale_linters/html/alex.vim +++ b/sources_non_forked/ale/ale_linters/html/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for HTML files -call ale#linter#Define('html', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('html', '--html') diff --git a/sources_non_forked/ale/ale_linters/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim index 234c1176..3e01f51a 100644 --- a/sources_non_forked/ale/ale_linters/html/htmlhint.vim +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -24,9 +24,9 @@ endfunction call ale#linter#Define('html', { \ 'name': 'htmlhint', -\ 'executable_callback': ale#node#FindExecutableFunc('html_htmlhint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'html_htmlhint', [ \ 'node_modules/.bin/htmlhint', -\ ]), -\ 'command_callback': 'ale_linters#html#htmlhint#GetCommand', +\ ])}, +\ 'command': function('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 index 908c4b02..ae8955f3 100644 --- a/sources_non_forked/ale/ale_linters/html/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -21,7 +21,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'stylelint', -\ 'executable_callback': 'ale_linters#html#stylelint#GetExecutable', -\ 'command_callback': 'ale_linters#html#stylelint#GetCommand', +\ 'executable': function('ale_linters#html#stylelint#GetExecutable'), +\ 'command': function('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 4ec29091..1e476d40 100644 --- a/sources_non_forked/ale/ale_linters/html/tidy.vim +++ b/sources_non_forked/ale/ale_linters/html/tidy.vim @@ -63,8 +63,8 @@ endfunction call ale#linter#Define('html', { \ 'name': 'tidy', -\ 'executable_callback': ale#VarFunc('html_tidy_executable'), +\ 'executable': {b -> ale#Var(b, 'html_tidy_executable')}, \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#html#tidy#GetCommand', +\ 'command': function('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 feac0f10..879e92f2 100644 --- a/sources_non_forked/ale/ale_linters/idris/idris.vim +++ b/sources_non_forked/ale/ale_linters/idris/idris.vim @@ -49,11 +49,11 @@ function! ale_linters#idris#idris#Handle(buffer, lines) abort let l:errors = matchlist(l:match[5], '\v([wW]arning|[eE]rror) - ?(.*)') if len(l:errors) > 0 - let l:ghc_type = l:errors[1] - let l:text = l:errors[2] + let l:ghc_type = l:errors[1] + let l:text = l:errors[2] else - let l:ghc_type = '' - let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5] + let l:ghc_type = '' + let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5] endif if l:ghc_type is? 'Warning' @@ -75,7 +75,7 @@ endfunction call ale#linter#Define('idris', { \ 'name': 'idris', -\ 'executable_callback': ale#VarFunc('idris_idris_executable'), -\ 'command_callback': 'ale_linters#idris#idris#GetCommand', +\ 'executable': {b -> ale#Var(b, 'idris_idris_executable')}, +\ 'command': function('ale_linters#idris#idris#GetCommand'), \ 'callback': 'ale_linters#idris#idris#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/ispc/ispc.vim b/sources_non_forked/ale/ale_linters/ispc/ispc.vim index de7ceafa..eb365117 100644 --- a/sources_non_forked/ale/ale_linters/ispc/ispc.vim +++ b/sources_non_forked/ale/ale_linters/ispc/ispc.vim @@ -38,8 +38,8 @@ endfunction call ale#linter#Define('ispc', { \ 'name': 'ispc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('ispc_ispc_executable'), -\ 'command_callback': 'ale_linters#ispc#ispc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ispc_ispc_executable')}, +\ 'command': function('ale_linters#ispc#ispc#GetCommand'), \ 'callback': 'ale_linters#ispc#ispc#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/java/checkstyle.vim b/sources_non_forked/ale/ale_linters/java/checkstyle.vim index c07b65d0..3159cd55 100644 --- a/sources_non_forked/ale/ale_linters/java/checkstyle.vim +++ b/sources_non_forked/ale/ale_linters/java/checkstyle.vim @@ -44,7 +44,7 @@ endif call ale#linter#Define('java', { \ 'name': 'checkstyle', \ 'executable': 'checkstyle', -\ 'command_callback': 'ale_linters#java#checkstyle#GetCommand', +\ 'command': function('ale_linters#java#checkstyle#GetCommand'), \ 'callback': 'ale_linters#java#checkstyle#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index 63dcdd94..50cabacd 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -55,15 +55,14 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort if isdirectory(l:jaxb_dir) call add(l:sp_dirs, l:jaxb_dir) endif + endif - " Automatically include the test directory, but only for test code. - if expand('#' . a:buffer . ':p') =~? '\vsrc[/\\]test[/\\]java' - let l:test_dir = fnamemodify(l:src_dir, ':h:h:h') - \ . (has('win32') ? '\test\java\' : '/test/java/') + " Automatically include the test directory, but only for test code. + if expand('#' . a:buffer . ':p') =~? '\vsrc[/\\]test[/\\]java' + let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'src/test/java') - if isdirectory(l:test_dir) - call add(l:sp_dirs, l:test_dir) - endif + if isdirectory(l:test_dir) + call add(l:sp_dirs, l:test_dir) endif endif @@ -73,7 +72,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort endif " Create .class files in a temporary directory, which we will delete later. - let l:class_file_directory = ale#engine#CreateDirectory(a:buffer) + let l:class_file_directory = ale#command#CreateDirectory(a:buffer) " Always run javac from the directory the file is in, so we can resolve " relative paths correctly. @@ -120,7 +119,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javac', -\ 'executable_callback': ale#VarFunc('java_javac_executable'), +\ 'executable': {b -> ale#Var(b, '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/java/javalsp.vim b/sources_non_forked/ale/ale_linters/java/javalsp.vim index 1436a52c..a327363d 100644 --- a/sources_non_forked/ale/ale_linters/java/javalsp.vim +++ b/sources_non_forked/ale/ale_linters/java/javalsp.vim @@ -1,7 +1,6 @@ " Author: Horacio Sanson " Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac -call ale#Set('java_javalsp_jar', 'javacs.jar') call ale#Set('java_javalsp_executable', 'java') function! ale_linters#java#javalsp#Executable(buffer) abort @@ -9,17 +8,16 @@ function! ale_linters#java#javalsp#Executable(buffer) abort endfunction function! ale_linters#java#javalsp#Command(buffer) abort - let l:jar = ale#Var(a:buffer, 'java_javalsp_jar') let l:executable = ale_linters#java#javalsp#Executable(a:buffer) - return ale#Escape(l:executable) . ' -cp ' . l:jar . ' -Xverify:none org.javacs.Main' + return ale#Escape(l:executable) . ' -Xverify:none -m javacs/org.javacs.Main' endfunction call ale#linter#Define('java', { \ 'name': 'javalsp', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#java#javalsp#Executable', -\ 'command_callback': 'ale_linters#java#javalsp#Command', +\ 'executable': function('ale_linters#java#javalsp#Executable'), +\ 'command': function('ale_linters#java#javalsp#Command'), \ 'language': 'java', -\ 'project_root_callback': 'ale#java#FindProjectRoot', +\ 'project_root': function('ale#java#FindProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/java/pmd.vim b/sources_non_forked/ale/ale_linters/java/pmd.vim index b530ad09..a1f4c93c 100644 --- a/sources_non_forked/ale/ale_linters/java/pmd.vim +++ b/sources_non_forked/ale/ale_linters/java/pmd.vim @@ -31,6 +31,6 @@ endif call ale#linter#Define('java', { \ 'name': 'pmd', \ 'executable': 'pmd', -\ 'command_callback': 'ale_linters#java#pmd#GetCommand', +\ 'command': function('ale_linters#java#pmd#GetCommand'), \ 'callback': 'ale_linters#java#pmd#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/eslint.vim b/sources_non_forked/ale/ale_linters/javascript/eslint.vim index 23e16949..8aeac2d8 100644 --- a/sources_non_forked/ale/ale_linters/javascript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/eslint.vim @@ -4,7 +4,7 @@ call ale#linter#Define('javascript', { \ 'name': 'eslint', \ 'output_stream': 'both', -\ 'executable_callback': 'ale#handlers#eslint#GetExecutable', -\ 'command_callback': 'ale#handlers#eslint#GetCommand', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/flow.vim b/sources_non_forked/ale/ale_linters/javascript/flow.vim index cdb289c7..05aae030 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow.vim @@ -54,7 +54,8 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort return ale#Escape(l:executable) \ . ' check-contents' \ . (l:use_respect_pragma ? ' --respect-pragma': '') - \ . ' --json --from ale %s' + \ . ' --json --from ale %s < %t' + \ . (!has('win32') ? '; echo' : '') endfunction " Filter lines of flow output until we find the first line where the JSON @@ -155,7 +156,8 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort \} if has_key(l:error, 'extra') - let l:errorToAdd.detail = s:GetDetails(l:error) + let l:errorToAdd.detail = l:errorToAdd.text + \ . "\n" . s:GetDetails(l:error) endif call add(l:output, l:errorToAdd) @@ -166,11 +168,11 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'flow', -\ 'executable_callback': 'ale_linters#javascript#flow#GetExecutable', +\ 'executable': function('ale_linters#javascript#flow#GetExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#javascript#flow#VersionCheck'}, \ {'callback': 'ale_linters#javascript#flow#GetCommand'}, \ ], \ 'callback': 'ale_linters#javascript#flow#Handle', -\ 'add_newline': !has('win32'), +\ 'read_buffer': 0, \}) 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 75377183..accaaa73 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim @@ -19,10 +19,10 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'flow-language-server', \ 'lsp': 'stdio', -\ 'executable_callback': ale#node#FindExecutableFunc('javascript_flow_ls', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_flow_ls', [ \ 'node_modules/.bin/flow', -\ ]), +\ ])}, \ 'command': '%e lsp --from ale-lsp', -\ 'project_root_callback': 'ale_linters#javascript#flow_ls#FindProjectRoot', +\ 'project_root': function('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 a38766a6..8905b3a1 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jscs.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -53,9 +53,9 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jscs', -\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jscs', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jscs', [ \ 'node_modules/.bin/jscs', -\ ]), -\ 'command_callback': 'ale_linters#javascript#jscs#GetCommand', +\ ])}, +\ 'command': function('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 cb7f66fc..d80a2250 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jshint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -25,9 +25,9 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jshint', -\ 'executable_callback': ale#node#FindExecutableFunc('javascript_jshint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jshint', [ \ 'node_modules/.bin/jshint', -\ ]), -\ 'command_callback': 'ale_linters#javascript#jshint#GetCommand', +\ ])}, +\ 'command': function('ale_linters#javascript#jshint#GetCommand'), \ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim index f16b837a..4cd2c303 100644 --- a/sources_non_forked/ale/ale_linters/javascript/standard.vim +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -24,7 +24,7 @@ endfunction " standard uses eslint and the output format is the same call ale#linter#Define('javascript', { \ 'name': 'standard', -\ 'executable_callback': 'ale_linters#javascript#standard#GetExecutable', -\ 'command_callback': 'ale_linters#javascript#standard#GetCommand', +\ 'executable': function('ale_linters#javascript#standard#GetExecutable'), +\ 'command': function('ale_linters#javascript#standard#GetCommand'), \ 'callback': 'ale#handlers#eslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim index 6cf08dd6..68c252c5 100644 --- a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim @@ -8,10 +8,10 @@ call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('javascript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable_callback': ale#node#FindExecutableFunc('javascript_tsserver', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_tsserver', [ \ 'node_modules/.bin/tsserver', -\ ]), +\ ])}, \ 'command': '%e', -\ 'project_root_callback': {-> ''}, +\ 'project_root': function('ale#handlers#tsserver#GetProjectRoot'), \ 'language': '', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/xo.vim b/sources_non_forked/ale/ale_linters/javascript/xo.vim index bc8657ed..4ba39101 100644 --- a/sources_non_forked/ale/ale_linters/javascript/xo.vim +++ b/sources_non_forked/ale/ale_linters/javascript/xo.vim @@ -20,7 +20,7 @@ endfunction " xo uses eslint and the output format is the same call ale#linter#Define('javascript', { \ 'name': 'xo', -\ 'executable_callback': 'ale_linters#javascript#xo#GetExecutable', -\ 'command_callback': 'ale_linters#javascript#xo#GetCommand', +\ 'executable': function('ale_linters#javascript#xo#GetExecutable'), +\ 'command': function('ale_linters#javascript#xo#GetCommand'), \ 'callback': 'ale#handlers#eslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/julia/languageserver.vim b/sources_non_forked/ale/ale_linters/julia/languageserver.vim index cd2000de..564bec39 100644 --- a/sources_non_forked/ale/ale_linters/julia/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/julia/languageserver.vim @@ -14,8 +14,8 @@ endfunction call ale#linter#Define('julia', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('julia_executable'), -\ 'command_callback': 'ale_linters#julia#languageserver#GetCommand', +\ 'executable': {b -> ale#Var(b, 'julia_executable')}, +\ 'command': function('ale_linters#julia#languageserver#GetCommand'), \ 'language': 'julia', -\ 'project_root_callback': 'ale#julia#FindProjectRoot', +\ 'project_root': function('ale#julia#FindProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim index 4a993986..32dcc6d1 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -20,7 +20,7 @@ function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort if !empty(l:pom_path) && executable('mvn') return ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' + \ . 'mvn dependency:build-classpath' endif let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer) diff --git a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim index f474e845..f0384005 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim @@ -1,54 +1,10 @@ " Author: Francis Agyapong " Description: Lint kotlin files using ktlint -call ale#Set('kotlin_ktlint_executable', 'ktlint') -call ale#Set('kotlin_ktlint_rulesets', []) -call ale#Set('kotlin_ktlint_format', 0) - - -function! ale_linters#kotlin#ktlint#GetCommand(buffer) abort - let l:executable = ale#Var(a:buffer, 'kotlin_ktlint_executable') - let l:file_path = expand('#' . a:buffer . ':p') - let l:options = '' - - " Formmatted content written to original file, not sure how to handle - " if ale#Var(a:buffer, 'kotlin_ktlint_format') - " let l:options = l:options . ' --format' - " endif - - for l:ruleset in ale#Var(a:buffer, 'kotlin_ktlint_rulesets') - let l:options = l:options . ' --ruleset ' . l:ruleset - endfor - - return l:executable . ' ' . l:options . ' ' . l:file_path -endfunction - -function! ale_linters#kotlin#ktlint#Handle(buffer, lines) abort - let l:message_pattern = '^\(.*\):\([0-9]\+\):\([0-9]\+\):\s\+\(.*\)' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:message_pattern) - let l:line = l:match[2] + 0 - let l:column = l:match[3] + 0 - let l:text = l:match[4] - - let l:type = l:text =~? 'not a valid kotlin file' ? 'E' : 'W' - - call add(l:output, { - \ 'lnum': l:line, - \ 'col': l:column, - \ 'text': l:text, - \ 'type': l:type - \}) - endfor - - return l:output -endfunction - call ale#linter#Define('kotlin', { \ 'name': 'ktlint', \ 'executable': 'ktlint', -\ 'command_callback': 'ale_linters#kotlin#ktlint#GetCommand', -\ 'callback': 'ale_linters#kotlin#ktlint#Handle', +\ 'command': function('ale#handlers#ktlint#GetCommand'), +\ 'callback': 'ale#handlers#ktlint#Handle', \ 'lint_file': 1 \}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim index aea817ba..af78c0e0 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim @@ -22,8 +22,8 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('kotlin_languageserver_executable'), +\ 'executable': {b -> ale#Var(b, 'kotlin_languageserver_executable')}, \ 'command': '%e', \ 'language': 'kotlin', -\ 'project_root_callback': 'ale_linters#kotlin#languageserver#GetProjectRoot', +\ 'project_root': function('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 37600649..4ec8b00e 100644 --- a/sources_non_forked/ale/ale_linters/less/lessc.vim +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -38,10 +38,10 @@ endfunction call ale#linter#Define('less', { \ 'name': 'lessc', -\ 'executable_callback': ale#node#FindExecutableFunc('less_lessc', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'less_lessc', [ \ 'node_modules/.bin/lessc', -\ ]), -\ 'command_callback': 'ale_linters#less#lessc#GetCommand', +\ ])}, +\ 'command': function('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 479808c2..efb036c2 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -12,9 +12,9 @@ endfunction call ale#linter#Define('less', { \ 'name': 'stylelint', -\ 'executable_callback': ale#node#FindExecutableFunc('less_stylelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'less_stylelint', [ \ 'node_modules/.bin/stylelint', -\ ]), -\ 'command_callback': 'ale_linters#less#stylelint#GetCommand', +\ ])}, +\ 'command': function('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 044f8c44..594be063 100644 --- a/sources_non_forked/ale/ale_linters/llvm/llc.vim +++ b/sources_non_forked/ale/ale_linters/llvm/llc.vim @@ -17,8 +17,8 @@ endfunction call ale#linter#Define('llvm', { \ 'name': 'llc', -\ 'executable_callback': ale#VarFunc('llvm_llc_executable'), +\ 'executable': {b -> ale#Var(b, 'llvm_llc_executable')}, \ 'output_stream': 'stderr', -\ 'command_callback': {-> '%e -filetype=null -o=' . g:ale#util#nul_file}, +\ 'command': {-> '%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 bca2cd8d..41674a43 100644 --- a/sources_non_forked/ale/ale_linters/lua/luac.vim +++ b/sources_non_forked/ale/ale_linters/lua/luac.vim @@ -24,7 +24,7 @@ endfunction call ale#linter#Define('lua', { \ 'name': 'luac', -\ 'executable_callback': ale#VarFunc('lua_luac_executable'), +\ 'executable': {b -> ale#Var(b, '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 669103b8..34be2b5a 100644 --- a/sources_non_forked/ale/ale_linters/lua/luacheck.vim +++ b/sources_non_forked/ale/ale_linters/lua/luacheck.vim @@ -38,7 +38,7 @@ endfunction call ale#linter#Define('lua', { \ 'name': 'luacheck', -\ 'executable_callback': ale#VarFunc('lua_luacheck_executable'), -\ 'command_callback': 'ale_linters#lua#luacheck#GetCommand', +\ 'executable': {b -> ale#Var(b, 'lua_luacheck_executable')}, +\ 'command': function('ale_linters#lua#luacheck#GetCommand'), \ 'callback': 'ale_linters#lua#luacheck#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/mail/alex.vim b/sources_non_forked/ale/ale_linters/mail/alex.vim index b0651ccd..0fceea7b 100644 --- a/sources_non_forked/ale/ale_linters/mail/alex.vim +++ b/sources_non_forked/ale/ale_linters/mail/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke -" Description: alex for HTML files +" Description: alex for mail files -call ale#linter#Define('mail', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('mail', '--text') diff --git a/sources_non_forked/ale/ale_linters/markdown/alex.vim b/sources_non_forked/ale/ale_linters/markdown/alex.vim index 29306141..63769b5e 100644 --- a/sources_non_forked/ale/ale_linters/markdown/alex.vim +++ b/sources_non_forked/ale/ale_linters/markdown/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for markdown files -call ale#linter#Define('markdown', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('markdown', '') diff --git a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim index 5c8af650..e935cbfe 100644 --- a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim @@ -2,10 +2,10 @@ " Description: Adds support for markdownlint call ale#linter#Define('markdown', { - \ 'name': 'markdownlint', - \ 'executable': 'markdownlint', - \ 'lint_file': 1, - \ 'output_stream': 'both', - \ 'command': 'markdownlint %s', - \ 'callback': 'ale#handlers#markdownlint#Handle' -\ }) +\ 'name': 'markdownlint', +\ 'executable': 'markdownlint', +\ 'lint_file': 1, +\ 'output_stream': 'both', +\ 'command': 'markdownlint %s', +\ 'callback': 'ale#handlers#markdownlint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/mdl.vim b/sources_non_forked/ale/ale_linters/markdown/mdl.vim index 0953144b..305f5359 100644 --- a/sources_non_forked/ale/ale_linters/markdown/mdl.vim +++ b/sources_non_forked/ale/ale_linters/markdown/mdl.vim @@ -38,7 +38,7 @@ endfunction call ale#linter#Define('markdown', { \ 'name': 'mdl', -\ 'executable_callback': 'ale_linters#markdown#mdl#GetExecutable', -\ 'command_callback': 'ale_linters#markdown#mdl#GetCommand', +\ 'executable': function('ale_linters#markdown#mdl#GetExecutable'), +\ 'command': function('ale_linters#markdown#mdl#GetCommand'), \ 'callback': 'ale_linters#markdown#mdl#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 4f8d48fa..ed87d1ad 100644 --- a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim @@ -39,10 +39,10 @@ endfunction call ale#linter#Define('markdown', { \ 'name': 'remark_lint', \ 'aliases': ['remark-lint'], -\ 'executable_callback': ale#node#FindExecutableFunc('markdown_remark_lint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'markdown_remark_lint', [ \ 'node_modules/.bin/remark', -\ ]), -\ 'command_callback': 'ale_linters#markdown#remark_lint#GetCommand', +\ ])}, +\ 'command': function('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/markdown/textlint.vim b/sources_non_forked/ale/ale_linters/markdown/textlint.vim index 26458506..613c8411 100644 --- a/sources_non_forked/ale/ale_linters/markdown/textlint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/textlint.vim @@ -3,7 +3,7 @@ call ale#linter#Define('markdown', { \ 'name': 'textlint', -\ 'executable_callback': 'ale#handlers#textlint#GetExecutable', -\ 'command_callback': 'ale#handlers#textlint#GetCommand', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), \ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', \}) diff --git a/sources_non_forked/ale/ale_linters/matlab/mlint.vim b/sources_non_forked/ale/ale_linters/matlab/mlint.vim index 3435045e..f58f8b6d 100644 --- a/sources_non_forked/ale/ale_linters/matlab/mlint.vim +++ b/sources_non_forked/ale/ale_linters/matlab/mlint.vim @@ -37,7 +37,7 @@ endfunction call ale#linter#Define('matlab', { \ 'name': 'mlint', -\ 'executable_callback': ale#VarFunc('matlab_mlint_executable'), +\ 'executable': {b -> ale#Var(b, '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 76d357f0..8a9ccc0e 100644 --- a/sources_non_forked/ale/ale_linters/mercury/mmc.vim +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -33,8 +33,8 @@ endfunction call ale#linter#Define('mercury', { \ 'name': 'mmc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('mercury_mmc_executable'), -\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')}, +\ 'command': function('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 cb2119a6..347abc1b 100644 --- a/sources_non_forked/ale/ale_linters/nasm/nasm.vim +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -36,7 +36,7 @@ call ale#linter#Define('nasm', { \ 'name': 'nasm', \ 'output_stream': 'stderr', \ 'lint_file': 1, -\ 'executable_callback': ale#VarFunc('nasm_nasm_executable'), -\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', +\ 'executable': {b -> ale#Var(b, 'nasm_nasm_executable')}, +\ 'command': function('ale_linters#nasm#nasm#GetCommand'), \ 'callback': 'ale_linters#nasm#nasm#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim index bff45f7d..b5796dcd 100644 --- a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim +++ b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim @@ -59,7 +59,7 @@ call ale#linter#Define('nim', { \ 'name': 'nimcheck', \ 'executable': 'nim', \ 'output_stream': 'both', -\ 'command_callback': 'ale_linters#nim#nimcheck#GetCommand', +\ 'command': function('ale_linters#nim#nimcheck#GetCommand'), \ 'callback': 'ale_linters#nim#nimcheck#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/nroff/alex.vim b/sources_non_forked/ale/ale_linters/nroff/alex.vim index a10db2dd..3f06af26 100644 --- a/sources_non_forked/ale/ale_linters/nroff/alex.vim +++ b/sources_non_forked/ale/ale_linters/nroff/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for nroff files -call ale#linter#Define('nroff', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('nroff', '--text') diff --git a/sources_non_forked/ale/ale_linters/objc/ccls.vim b/sources_non_forked/ale/ale_linters/objc/ccls.vim index 0aa6a5e5..51ecf056 100644 --- a/sources_non_forked/ale/ale_linters/objc/ccls.vim +++ b/sources_non_forked/ale/ale_linters/objc/ccls.vim @@ -7,8 +7,8 @@ call ale#Set('objc_ccls_init_options', {}) call ale#linter#Define('objc', { \ 'name': 'ccls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('objc_ccls_executable'), +\ 'executable': {b -> ale#Var(b, 'objc_ccls_executable')}, \ 'command': '%e', -\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot', -\ 'initialization_options_callback': ale#VarFunc('objc_ccls_init_options'), +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'objc_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/objc/clang.vim b/sources_non_forked/ale/ale_linters/objc/clang.vim index 4e80ac5c..7873dccd 100644 --- a/sources_non_forked/ale/ale_linters/objc/clang.vim +++ b/sources_non_forked/ale/ale_linters/objc/clang.vim @@ -18,6 +18,6 @@ call ale#linter#Define('objc', { \ 'name': 'clang', \ 'output_stream': 'stderr', \ 'executable': 'clang', -\ 'command_callback': 'ale_linters#objc#clang#GetCommand', +\ 'command': function('ale_linters#objc#clang#GetCommand'), \ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', \}) diff --git a/sources_non_forked/ale/ale_linters/objc/clangd.vim b/sources_non_forked/ale/ale_linters/objc/clangd.vim index f090e6ce..ab52fec3 100644 --- a/sources_non_forked/ale/ale_linters/objc/clangd.vim +++ b/sources_non_forked/ale/ale_linters/objc/clangd.vim @@ -17,7 +17,7 @@ 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', +\ 'executable': {b -> ale#Var(b, 'objc_clangd_executable')}, +\ 'command': function('ale_linters#objc#clangd#GetCommand'), +\ 'project_root': function('ale_linters#objc#clangd#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/objcpp/clang.vim b/sources_non_forked/ale/ale_linters/objcpp/clang.vim index d1474f17..4dbe55b3 100644 --- a/sources_non_forked/ale/ale_linters/objcpp/clang.vim +++ b/sources_non_forked/ale/ale_linters/objcpp/clang.vim @@ -18,6 +18,6 @@ call ale#linter#Define('objcpp', { \ 'name': 'clang', \ 'output_stream': 'stderr', \ 'executable': 'clang++', -\ 'command_callback': 'ale_linters#objcpp#clang#GetCommand', +\ 'command': function('ale_linters#objcpp#clang#GetCommand'), \ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', \}) diff --git a/sources_non_forked/ale/ale_linters/objcpp/clangd.vim b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim index a09753be..3991d2ac 100644 --- a/sources_non_forked/ale/ale_linters/objcpp/clangd.vim +++ b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim @@ -17,7 +17,7 @@ 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', +\ 'executable': {b -> ale#Var(b, 'objcpp_clangd_executable')}, +\ 'command': function('ale_linters#objcpp#clangd#GetCommand'), +\ 'project_root': function('ale_linters#objcpp#clangd#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ols.vim b/sources_non_forked/ale/ale_linters/ocaml/ols.vim index 077862fc..d8208c52 100644 --- a/sources_non_forked/ale/ale_linters/ocaml/ols.vim +++ b/sources_non_forked/ale/ale_linters/ocaml/ols.vim @@ -7,8 +7,8 @@ call ale#Set('ocaml_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('ocaml', { \ 'name': 'ols', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale#handlers#ols#GetExecutable', -\ 'command_callback': 'ale#handlers#ols#GetCommand', +\ 'executable': function('ale#handlers#ols#GetExecutable'), +\ 'command': function('ale#handlers#ols#GetCommand'), \ 'language_callback': 'ale#handlers#ols#GetLanguage', -\ 'project_root_callback': 'ale#handlers#ols#GetProjectRoot', +\ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/perl/perl.vim b/sources_non_forked/ale/ale_linters/perl/perl.vim index 4b954f0d..0f06528a 100644 --- a/sources_non_forked/ale/ale_linters/perl/perl.vim +++ b/sources_non_forked/ale/ale_linters/perl/perl.vim @@ -57,8 +57,8 @@ endfunction call ale#linter#Define('perl', { \ 'name': 'perl', -\ 'executable_callback': ale#VarFunc('perl_perl_executable'), +\ 'executable': {b -> ale#Var(b, 'perl_perl_executable')}, \ 'output_stream': 'both', -\ 'command_callback': 'ale_linters#perl#perl#GetCommand', +\ 'command': function('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 8619a404..f3154c09 100644 --- a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim +++ b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim @@ -55,7 +55,7 @@ endfunction call ale#linter#Define('perl', { \ 'name': 'perlcritic', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('perl_perlcritic_executable'), -\ 'command_callback': 'ale_linters#perl#perlcritic#GetCommand', +\ 'executable': {b -> ale#Var(b, 'perl_perlcritic_executable')}, +\ 'command': function('ale_linters#perl#perlcritic#GetCommand'), \ 'callback': 'ale_linters#perl#perlcritic#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/perl6/perl6.vim b/sources_non_forked/ale/ale_linters/perl6/perl6.vim index b33a0c51..68ef4769 100644 --- a/sources_non_forked/ale/ale_linters/perl6/perl6.vim +++ b/sources_non_forked/ale/ale_linters/perl6/perl6.vim @@ -36,8 +36,8 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort endif if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line']) - let l:line = a:dict[a:item]['line'] - let l:counter -= 1 + let l:line = a:dict[a:item]['line'] + let l:counter -= 1 endif if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column']) @@ -61,7 +61,7 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort " Currently, filenames and line numbers are not always given in the error output if l:counter < 2 - \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) + \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) return { \ 'lnum': '' . l:line, \ 'text': l:text, @@ -83,7 +83,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort endif if a:lines[0] is# 'Syntax OK' - return l:output + return l:output endif try @@ -101,8 +101,8 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort if type(l:json) is v:t_dict for l:key in keys(l:json) - if has_key(l:json[l:key], 'sorrows') && - \ has_key(l:json[l:key], 'worries') + if has_key(l:json[l:key], 'sorrows') + \&& has_key(l:json[l:key], 'worries') if !empty(l:json[l:key]['sorrows']) for l:dictionary in get(l:json[l:key], 'sorrows') for l:item in keys(l:dictionary) @@ -115,7 +115,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endfor endfor @@ -133,7 +133,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endfor endfor @@ -147,7 +147,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort \ ) if l:result isnot# '' - call add(l:output, l:result) + call add(l:output, l:result) endif endif endfor @@ -158,9 +158,9 @@ endfunction call ale#linter#Define('perl6', { \ 'name': 'perl6', -\ 'executable_callback': 'ale_linters#perl6#perl6#GetExecutable', +\ 'executable': function('ale_linters#perl6#perl6#GetExecutable'), \ 'output_stream': 'both', -\ 'command_callback': 'ale_linters#perl6#perl6#GetCommand', +\ 'command': function('ale_linters#perl6#perl6#GetCommand'), \ 'callback': 'ale_linters#perl6#perl6#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim index ca91db4c..c88281c4 100644 --- a/sources_non_forked/ale/ale_linters/php/langserver.vim +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -13,9 +13,9 @@ endfunction call ale#linter#Define('php', { \ 'name': 'langserver', \ 'lsp': 'stdio', -\ 'executable_callback': ale#node#FindExecutableFunc('php_langserver', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'php_langserver', [ \ 'vendor/bin/php-language-server.php', -\ ]), +\ ])}, \ 'command': 'php %e', -\ 'project_root_callback': 'ale_linters#php#langserver#GetProjectRoot', +\ 'project_root': function('ale_linters#php#langserver#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/php/phan.vim b/sources_non_forked/ale/ale_linters/php/phan.vim index c6f16356..53cb1ea9 100644 --- a/sources_non_forked/ale/ale_linters/php/phan.vim +++ b/sources_non_forked/ale/ale_linters/php/phan.vim @@ -67,7 +67,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phan', -\ 'executable_callback': 'ale_linters#php#phan#GetExecutable', -\ 'command_callback': 'ale_linters#php#phan#GetCommand', +\ 'executable': function('ale_linters#php#phan#GetExecutable'), +\ 'command': function('ale_linters#php#phan#GetCommand'), \ 'callback': 'ale_linters#php#phan#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/php.vim b/sources_non_forked/ale/ale_linters/php/php.vim index 5d87196c..51a109b9 100644 --- a/sources_non_forked/ale/ale_linters/php/php.vim +++ b/sources_non_forked/ale/ale_linters/php/php.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'php', -\ 'executable_callback': ale#VarFunc('php_php_executable'), +\ 'executable': {b -> ale#Var(b, 'php_php_executable')}, \ 'output_stream': 'stdout', \ 'command': '%e -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --', \ 'callback': 'ale_linters#php#php#Handle', diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index 408c2652..1c92bbb2 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -44,10 +44,10 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpcs', -\ 'executable_callback': ale#node#FindExecutableFunc('php_phpcs', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'php_phpcs', [ \ 'vendor/bin/phpcs', \ 'phpcs' -\ ]), -\ 'command_callback': 'ale_linters#php#phpcs#GetCommand', +\ ])}, +\ 'command': function('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 65f1cc3c..9b1d1e44 100644 --- a/sources_non_forked/ale/ale_linters/php/phpmd.vim +++ b/sources_non_forked/ale/ale_linters/php/phpmd.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpmd', -\ 'executable_callback': ale#VarFunc('php_phpmd_executable'), -\ 'command_callback': 'ale_linters#php#phpmd#GetCommand', +\ 'executable': {b -> ale#Var(b, 'php_phpmd_executable')}, +\ 'command': function('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 1c831e1b..34d4e799 100644 --- a/sources_non_forked/ale/ale_linters/php/phpstan.vim +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -65,7 +65,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpstan', -\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable', +\ 'executable': function('ale_linters#php#phpstan#GetExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#php#phpstan#VersionCheck'}, \ {'callback': 'ale_linters#php#phpstan#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim index dce59178..3cdb026a 100644 --- a/sources_non_forked/ale/ale_linters/php/psalm.vim +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -13,9 +13,9 @@ endfunction call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', -\ 'executable_callback': ale#node#FindExecutableFunc('psalm_langserver', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ \ 'vendor/bin/psalm-language-server', -\ ]), +\ ])}, \ 'command': '%e', -\ 'project_root_callback': 'ale_linters#php#psalm#GetProjectRoot', +\ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/po/alex.vim b/sources_non_forked/ale/ale_linters/po/alex.vim index 411d835b..05c67f15 100644 --- a/sources_non_forked/ale/ale_linters/po/alex.vim +++ b/sources_non_forked/ale/ale_linters/po/alex.vim @@ -1,11 +1,4 @@ " Author: Cian Butler https://github.com/butlerx " Description: alex for PO files -call ale#linter#Define('po', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('po', '--text') diff --git a/sources_non_forked/ale/ale_linters/pod/alex.vim b/sources_non_forked/ale/ale_linters/pod/alex.vim index 5c09befb..c89f8330 100644 --- a/sources_non_forked/ale/ale_linters/pod/alex.vim +++ b/sources_non_forked/ale/ale_linters/pod/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for pod files -call ale#linter#Define('pod', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('pod', '--text') diff --git a/sources_non_forked/ale/ale_linters/pony/ponyc.vim b/sources_non_forked/ale/ale_linters/pony/ponyc.vim index 19e7e828..6d4594f9 100644 --- a/sources_non_forked/ale/ale_linters/pony/ponyc.vim +++ b/sources_non_forked/ale/ale_linters/pony/ponyc.vim @@ -10,7 +10,7 @@ endfunction call ale#linter#Define('pony', { \ 'name': 'ponyc', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('pony_ponyc_executable'), -\ 'command_callback': 'ale_linters#pony#ponyc#GetCommand', +\ 'executable': {b -> ale#Var(b, 'pony_ponyc_executable')}, +\ 'command': function('ale_linters#pony#ponyc#GetCommand'), \ 'callback': 'ale#handlers#pony#HandlePonycFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/prolog/swipl.vim b/sources_non_forked/ale/ale_linters/prolog/swipl.vim index 401e52b6..5c601c40 100644 --- a/sources_non_forked/ale/ale_linters/prolog/swipl.vim +++ b/sources_non_forked/ale/ale_linters/prolog/swipl.vim @@ -87,14 +87,14 @@ endfunction " Skip sandbox error which is caused by directives " because what we want is syntactic or semantic check. function! s:Ignore(item) abort - return a:item.type is# 'E' && - \ a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' + return a:item.type is# 'E' + \ && a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' endfunction call ale#linter#Define('prolog', { \ 'name': 'swipl', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('prolog_swipl_executable'), -\ 'command_callback': 'ale_linters#prolog#swipl#GetCommand', +\ 'executable': {b -> ale#Var(b, 'prolog_swipl_executable')}, +\ 'command': function('ale_linters#prolog#swipl#GetCommand'), \ 'callback': 'ale_linters#prolog#swipl#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim b/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim index c8b5c331..c3d10935 100644 --- a/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim +++ b/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim @@ -22,6 +22,6 @@ call ale#linter#Define('proto', { \ 'lint_file': 1, \ 'output_stream': 'stderr', \ 'executable': 'protoc', -\ 'command_callback': 'ale_linters#proto#protoc_gen_lint#GetCommand', +\ 'command': function('ale_linters#proto#protoc_gen_lint#GetCommand'), \ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim index 63208986..c4e0e233 100644 --- a/sources_non_forked/ale/ale_linters/pug/puglint.vim +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -33,10 +33,10 @@ endfunction call ale#linter#Define('pug', { \ 'name': 'puglint', -\ 'executable_callback': ale#node#FindExecutableFunc('pug_puglint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'pug_puglint', [ \ 'node_modules/.bin/pug-lint', -\ ]), +\ ])}, \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#pug#puglint#GetCommand', +\ 'command': function('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 a3060e65..2078695f 100644 --- a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim @@ -30,8 +30,8 @@ endfunction call ale#linter#Define('puppet', { \ 'name': 'languageserver', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('puppet_languageserver_executable'), +\ 'executable': {b -> ale#Var(b, 'puppet_languageserver_executable')}, \ 'command': '%e --stdio', \ 'language': 'puppet', -\ 'project_root_callback': 'ale_linters#puppet#languageserver#GetProjectRoot', +\ 'project_root': function('ale_linters#puppet#languageserver#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppet.vim b/sources_non_forked/ale/ale_linters/puppet/puppet.vim index 0e37bdbd..ae648615 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppet.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppet.vim @@ -30,8 +30,8 @@ endfunction call ale#linter#Define('puppet', { \ 'name': 'puppet', -\ 'executable_callback': ale#VarFunc('puppet_puppet_executable'), +\ 'executable': {b -> ale#Var(b, 'puppet_puppet_executable')}, \ 'output_stream': 'stderr', -\ 'command_callback': 'ale_linters#puppet#puppet#GetCommand', +\ 'command': function('ale_linters#puppet#puppet#GetCommand'), \ 'callback': 'ale_linters#puppet#puppet#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim index c9c16f5e..985d6a4d 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim @@ -12,7 +12,7 @@ endfunction call ale#linter#Define('puppet', { \ 'name': 'puppetlint', -\ 'executable_callback': ale#VarFunc('puppet_puppetlint_executable'), -\ 'command_callback': 'ale_linters#puppet#puppetlint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'puppet_puppetlint_executable')}, +\ 'command': function('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 d260698c..84382ba1 100644 --- a/sources_non_forked/ale/ale_linters/pyrex/cython.vim +++ b/sources_non_forked/ale/ale_linters/pyrex/cython.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('pyrex', { \ 'name': 'cython', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('pyrex_cython_executable'), -\ 'command_callback': 'ale_linters#pyrex#cython#GetCommand', +\ 'executable': {b -> ale#Var(b, 'pyrex_cython_executable')}, +\ 'command': function('ale_linters#pyrex#cython#GetCommand'), \ 'callback': 'ale_linters#pyrex#cython#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index 14b67d77..993d7adb 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -74,23 +74,18 @@ let s:end_col_pattern_map = { \} function! ale_linters#python#flake8#Handle(buffer, lines) abort - for l:line in a:lines[:10] - if match(l:line, '^Traceback') >= 0 - return [{ - \ 'lnum': 1, - \ 'text': 'An exception was thrown. See :ALEDetail', - \ 'detail': join(a:lines, "\n"), - \}] - endif - endfor + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif " Matches patterns line the following: " " Matches patterns line the following: " " stdin:6:6: E111 indentation is not a multiple of four - let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+) (.*)$' - let l:output = [] + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+):? (.*)$' for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:code = l:match[3] @@ -148,7 +143,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'flake8', -\ 'executable_callback': 'ale_linters#python#flake8#GetExecutable', +\ 'executable': function('ale_linters#python#flake8#GetExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#python#flake8#VersionCheck'}, \ {'callback': 'ale_linters#python#flake8#GetCommand', 'output_stream': 'both'}, diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim index 0c90a3c7..c4c6507f 100644 --- a/sources_non_forked/ale/ale_linters/python/mypy.vim +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -75,7 +75,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'mypy', -\ 'executable_callback': 'ale_linters#python#mypy#GetExecutable', -\ 'command_callback': 'ale_linters#python#mypy#GetCommand', +\ 'executable': function('ale_linters#python#mypy#GetExecutable'), +\ 'command': function('ale_linters#python#mypy#GetCommand'), \ 'callback': 'ale_linters#python#mypy#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim index b01cec87..ee47012f 100644 --- a/sources_non_forked/ale/ale_linters/python/prospector.vim +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -93,8 +93,8 @@ endfunction call ale#linter#Define('python', { \ 'name': 'prospector', -\ 'executable_callback': 'ale_linters#python#prospector#GetExecutable', -\ 'command_callback': 'ale_linters#python#prospector#GetCommand', +\ 'executable': function('ale_linters#python#prospector#GetExecutable'), +\ 'command': function('ale_linters#python#prospector#GetCommand'), \ 'callback': 'ale_linters#python#prospector#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim index f0269585..fb521bc1 100644 --- a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -69,7 +69,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pycodestyle', -\ 'executable_callback': 'ale_linters#python#pycodestyle#GetExecutable', -\ 'command_callback': 'ale_linters#python#pycodestyle#GetCommand', +\ 'executable': function('ale_linters#python#pycodestyle#GetExecutable'), +\ 'command': function('ale_linters#python#pycodestyle#GetCommand'), \ 'callback': 'ale_linters#python#pycodestyle#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim index ebf92bf1..3901db4d 100644 --- a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -33,8 +33,7 @@ function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort " Matches patterns like the following: " mydir/myfile.py:33 in public function `myfunction`: " DXXX: Error description - let l:fname = ale#Escape(fnamemodify(bufname(a:buffer), ':p:t')) - let l:line1_pattern = '\v^' . l:fname . ':\s*(\d+)\s+.*$' + let l:line1_pattern = '\v^.*:\s*(\d+)\s+.*$' let l:line2_pattern = '\v^.*([a-zA-Z]\d+):\s*(.*)$' let l:output = [] @@ -68,7 +67,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pydocstyle', -\ 'executable_callback': 'ale_linters#python#pydocstyle#GetExecutable', -\ 'command_callback': 'ale_linters#python#pydocstyle#GetCommand', +\ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'), +\ 'command': function('ale_linters#python#pydocstyle#GetCommand'), \ 'callback': 'ale_linters#python#pydocstyle#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim index 091408d5..b5127022 100644 --- a/sources_non_forked/ale/ale_linters/python/pyflakes.vim +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -43,8 +43,8 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pyflakes', -\ 'executable_callback': 'ale_linters#python#pyflakes#GetExecutable', -\ 'command_callback': 'ale_linters#python#pyflakes#GetCommand', +\ 'executable': function('ale_linters#python#pyflakes#GetExecutable'), +\ 'command': function('ale_linters#python#pyflakes#GetCommand'), \ 'callback': 'ale_linters#python#pyflakes#Handle', \ 'output_stream': 'both', \}) diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index 01c3cb37..57e82691 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -17,9 +17,17 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort endfunction function! ale_linters#python#pylint#GetCommand(buffer) abort - let l:cd_string = ale#Var(a:buffer, 'python_pylint_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' + let l:cd_string = '' + + if ale#Var(a:buffer, 'python_pylint_change_directory') + " pylint only checks for pylintrc in the packages above its current + " directory before falling back to user and global pylintrc. + " Run from project root, if found, otherwise buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + let l:cd_string = l:project_root isnot# '' + \ ? ale#path#CdString(l:project_root) + \ : ale#path#BufferCdString(a:buffer) + endif let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) @@ -53,7 +61,7 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort if l:code is# 'I0011' " Skip 'Locally disabling' message - continue + continue endif call add(l:output, { @@ -70,8 +78,8 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pylint', -\ 'executable_callback': 'ale_linters#python#pylint#GetExecutable', -\ 'command_callback': 'ale_linters#python#pylint#GetCommand', +\ 'executable': function('ale_linters#python#pylint#GetExecutable'), +\ 'command': function('ale_linters#python#pylint#GetCommand'), \ 'callback': 'ale_linters#python#pylint#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyls.vim b/sources_non_forked/ale/ale_linters/python/pyls.vim index 83fe8066..c7f91430 100644 --- a/sources_non_forked/ale/ale_linters/python/pyls.vim +++ b/sources_non_forked/ale/ale_linters/python/pyls.vim @@ -4,6 +4,7 @@ call ale#Set('python_pyls_executable', 'pyls') call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyls_auto_pipenv', 0) +call ale#Set('python_pyls_config', {}) function! ale_linters#python#pyls#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv')) @@ -27,8 +28,9 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pyls', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#python#pyls#GetExecutable', -\ 'command_callback': 'ale_linters#python#pyls#GetCommand', -\ 'project_root_callback': 'ale#python#FindProjectRoot', +\ 'executable': function('ale_linters#python#pyls#GetExecutable'), +\ 'command': function('ale_linters#python#pyls#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), \ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': {b -> ale#Var(b, 'python_pyls_config')}, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyre.vim b/sources_non_forked/ale/ale_linters/python/pyre.vim index adc185f2..4edd80f7 100644 --- a/sources_non_forked/ale/ale_linters/python/pyre.vim +++ b/sources_non_forked/ale/ale_linters/python/pyre.vim @@ -27,8 +27,8 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pyre', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#python#pyre#GetExecutable', -\ 'command_callback': 'ale_linters#python#pyre#GetCommand', -\ 'project_root_callback': 'ale#python#FindProjectRoot', +\ 'executable': function('ale_linters#python#pyre#GetExecutable'), +\ 'command': function('ale_linters#python#pyre#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), \ 'completion_filter': 'ale#completion#python#CompletionItemFilter', \}) diff --git a/sources_non_forked/ale/ale_linters/python/vulture.vim b/sources_non_forked/ale/ale_linters/python/vulture.vim index 80828013..d328d262 100644 --- a/sources_non_forked/ale/ale_linters/python/vulture.vim +++ b/sources_non_forked/ale/ale_linters/python/vulture.vim @@ -46,19 +46,14 @@ endfunction function! ale_linters#python#vulture#Handle(buffer, lines) abort - for l:line in a:lines[:10] - if match(l:line, '^Traceback') >= 0 - return [{ - \ 'lnum': 1, - \ 'text': 'An exception was thrown. See :ALEDetail', - \ 'detail': join(a:lines, "\n"), - \}] - endif - endfor + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif " Matches patterns line the following: let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (.*)$' - let l:output = [] let l:dir = s:GetDir(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -78,8 +73,8 @@ endfunction call ale#linter#Define('python', { \ 'name': 'vulture', -\ 'executable_callback': 'ale_linters#python#vulture#GetExecutable', -\ 'command_callback': 'ale_linters#python#vulture#GetCommand', +\ 'executable': function('ale_linters#python#vulture#GetExecutable'), +\ 'command': function('ale_linters#python#vulture#GetCommand'), \ 'callback': 'ale_linters#python#vulture#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim index 12f3e97b..11cc9413 100644 --- a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim +++ b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim @@ -19,7 +19,7 @@ endfunction call ale#linter#Define('qml', { \ 'name': 'qmlfmt', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('qml_qmlfmt_executable'), +\ 'executable': {b -> ale#Var(b, 'qml_qmlfmt_executable')}, \ 'command': '%e -e', \ 'callback': 'ale_linters#qml#qmlfmt#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/r/lintr.vim b/sources_non_forked/ale/ale_linters/r/lintr.vim index 8f74c9b8..3164c06f 100644 --- a/sources_non_forked/ale/ale_linters/r/lintr.vim +++ b/sources_non_forked/ale/ale_linters/r/lintr.vim @@ -29,7 +29,7 @@ endfunction call ale#linter#Define('r', { \ 'name': 'lintr', \ 'executable': 'Rscript', -\ 'command_callback': 'ale_linters#r#lintr#GetCommand', +\ 'command': function('ale_linters#r#lintr#GetCommand'), \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'output_stream': 'both', \}) diff --git a/sources_non_forked/ale/ale_linters/reason/ols.vim b/sources_non_forked/ale/ale_linters/reason/ols.vim index 4e5bd395..66137e1b 100644 --- a/sources_non_forked/ale/ale_linters/reason/ols.vim +++ b/sources_non_forked/ale/ale_linters/reason/ols.vim @@ -7,8 +7,8 @@ call ale#Set('reason_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('reason', { \ 'name': 'ols', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale#handlers#ols#GetExecutable', -\ 'command_callback': 'ale#handlers#ols#GetCommand', +\ 'executable': function('ale#handlers#ols#GetExecutable'), +\ 'command': function('ale#handlers#ols#GetCommand'), \ 'language_callback': 'ale#handlers#ols#GetLanguage', -\ 'project_root_callback': 'ale#handlers#ols#GetProjectRoot', +\ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/rst/alex.vim b/sources_non_forked/ale/ale_linters/rst/alex.vim index e637eae7..e7ca6fa0 100644 --- a/sources_non_forked/ale/ale_linters/rst/alex.vim +++ b/sources_non_forked/ale/ale_linters/rst/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for rst files -call ale#linter#Define('rst', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('rst', '--text') diff --git a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim index 8504738b..39e11d6e 100644 --- a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim +++ b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('rst', { \ 'name': 'rstcheck', \ 'executable': 'rstcheck', -\ 'command_callback': 'ale_linters#rst#rstcheck#GetCommand', +\ 'command': function('ale_linters#rst#rstcheck#GetCommand'), \ 'callback': 'ale_linters#rst#rstcheck#Handle', \ 'output_stream': 'both', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim index 122e0b5b..a8088080 100644 --- a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim +++ b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim @@ -44,8 +44,8 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'brakeman', -\ 'executable_callback': ale#VarFunc('ruby_brakeman_executable'), -\ 'command_callback': 'ale_linters#ruby#brakeman#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ruby_brakeman_executable')}, +\ 'command': function('ale_linters#ruby#brakeman#GetCommand'), \ 'callback': 'ale_linters#ruby#brakeman#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim index 20cadca8..680cc364 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim @@ -42,8 +42,8 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'rails_best_practices', -\ 'executable_callback': ale#VarFunc('ruby_rails_best_practices_executable'), -\ 'command_callback': 'ale_linters#ruby#rails_best_practices#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ruby_rails_best_practices_executable')}, +\ 'command': function('ale_linters#ruby#rails_best_practices#GetCommand'), \ 'callback': 'ale_linters#ruby#rails_best_practices#Handle', \ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/reek.vim b/sources_non_forked/ale/ale_linters/ruby/reek.vim index 53363d31..26f6e36c 100644 --- a/sources_non_forked/ale/ale_linters/ruby/reek.vim +++ b/sources_non_forked/ale/ale_linters/ruby/reek.vim @@ -69,7 +69,7 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'reek', -\ 'executable_callback': ale#VarFunc('ruby_reek_executable'), +\ 'executable': {b -> ale#Var(b, 'ruby_reek_executable')}, \ 'command_chain': [ \ {'callback': 'ale_linters#ruby#reek#VersionCheck'}, \ {'callback': 'ale_linters#ruby#reek#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim index 790ca82c..8b9e9c84 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim @@ -25,7 +25,7 @@ endfunction call ale#linter#Define('ruby', { \ 'name': 'rubocop', -\ 'executable_callback': ale#VarFunc('ruby_rubocop_executable'), -\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ruby_rubocop_executable')}, +\ 'command': function('ale_linters#ruby#rubocop#GetCommand'), \ 'callback': 'ale#ruby#HandleRubocopOutput', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/ruby.vim b/sources_non_forked/ale/ale_linters/ruby/ruby.vim index 2bc4ec4b..2dc55eb0 100644 --- a/sources_non_forked/ale/ale_linters/ruby/ruby.vim +++ b/sources_non_forked/ale/ale_linters/ruby/ruby.vim @@ -5,7 +5,7 @@ call ale#Set('ruby_ruby_executable', 'ruby') call ale#linter#Define('ruby', { \ 'name': 'ruby', -\ 'executable_callback': ale#VarFunc('ruby_ruby_executable'), +\ 'executable': {b -> ale#Var(b, '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/ruby/solargraph.vim b/sources_non_forked/ale/ale_linters/ruby/solargraph.vim index 5ff0a759..bf54a55c 100644 --- a/sources_non_forked/ale/ale_linters/ruby/solargraph.vim +++ b/sources_non_forked/ale/ale_linters/ruby/solargraph.vim @@ -15,8 +15,8 @@ call ale#linter#Define('ruby', { \ 'name': 'solargraph', \ 'lsp': 'stdio', \ 'language': 'ruby', -\ 'executable_callback': ale#VarFunc('ruby_solargraph_executable'), -\ 'command_callback': 'ale_linters#ruby#solargraph#GetCommand', -\ 'project_root_callback': 'ale#ruby#FindProjectRoot', -\ 'initialization_options_callback': ale#VarFunc('ruby_solargraph_options'), +\ 'executable': {b -> ale#Var(b, 'ruby_solargraph_executable')}, +\ 'command': function('ale_linters#ruby#solargraph#GetCommand'), +\ 'project_root': function('ale#ruby#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'ruby_solargraph_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim index 95e10934..f075a7d5 100644 --- a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim +++ b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim @@ -17,7 +17,7 @@ endfunction " standardrb is based on RuboCop so the callback is the same call ale#linter#Define('ruby', { \ 'name': 'standardrb', -\ 'executable_callback': ale#VarFunc('ruby_standardrb_executable'), -\ 'command_callback': 'ale_linters#ruby#standardrb#GetCommand', +\ 'executable': {b -> ale#Var(b, 'ruby_standardrb_executable')}, +\ 'command': function('ale_linters#ruby#standardrb#GetCommand'), \ 'callback': 'ale#ruby#HandleRubocopOutput', \}) diff --git a/sources_non_forked/ale/ale_linters/rust/cargo.vim b/sources_non_forked/ale/ale_linters/rust/cargo.vim index cf6187f8..b4eabfae 100644 --- a/sources_non_forked/ale/ale_linters/rust/cargo.vim +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -93,7 +93,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'cargo', -\ 'executable_callback': 'ale_linters#rust#cargo#GetCargoExecutable', +\ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#rust#cargo#VersionCheck'}, \ {'callback': 'ale_linters#rust#cargo#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/rust/rls.vim b/sources_non_forked/ale/ale_linters/rust/rls.vim index 60dd3667..0e5c326c 100644 --- a/sources_non_forked/ale/ale_linters/rust/rls.vim +++ b/sources_non_forked/ale/ale_linters/rust/rls.vim @@ -3,6 +3,7 @@ call ale#Set('rust_rls_executable', 'rls') call ale#Set('rust_rls_toolchain', 'nightly') +call ale#Set('rust_rls_config', {}) function! ale_linters#rust#rls#GetCommand(buffer) abort let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain') @@ -19,7 +20,8 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'rls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#VarFunc('rust_rls_executable'), -\ 'command_callback': 'ale_linters#rust#rls#GetCommand', -\ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot', +\ 'lsp_config': {b -> ale#Var(b, 'rust_rls_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_rls_executable')}, +\ 'command': function('ale_linters#rust#rls#GetCommand'), +\ 'project_root': function('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 33fb72f4..f140b58b 100644 --- a/sources_non_forked/ale/ale_linters/rust/rustc.vim +++ b/sources_non_forked/ale/ale_linters/rust/rustc.vim @@ -27,7 +27,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'rustc', \ 'executable': 'rustc', -\ 'command_callback': 'ale_linters#rust#rustc#RustcCommand', +\ 'command': function('ale_linters#rust#rustc#RustcCommand'), \ 'callback': 'ale#handlers#rust#HandleRustErrors', \ 'output_stream': 'stderr', \}) diff --git a/sources_non_forked/ale/ale_linters/sass/sasslint.vim b/sources_non_forked/ale/ale_linters/sass/sasslint.vim index 8d24185d..17cd3667 100644 --- a/sources_non_forked/ale/ale_linters/sass/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/sass/sasslint.vim @@ -22,7 +22,7 @@ endfunction call ale#linter#Define('sass', { \ 'name': 'sasslint', -\ 'executable_callback': 'ale_linters#sass#sasslint#GetExecutable', -\ 'command_callback': 'ale_linters#sass#sasslint#GetCommand', +\ 'executable': function('ale_linters#sass#sasslint#GetExecutable'), +\ 'command': function('ale_linters#sass#sasslint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim index b6286f18..7b14c6b4 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -5,9 +5,9 @@ call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', call ale#linter#Define('sass', { \ 'name': 'stylelint', -\ 'executable_callback': ale#node#FindExecutableFunc('sass_stylelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, '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 fbdce20e..94135235 100644 --- a/sources_non_forked/ale/ale_linters/scala/fsc.vim +++ b/sources_non_forked/ale/ale_linters/scala/fsc.vim @@ -7,7 +7,7 @@ endfunction call ale#linter#Define('scala', { \ 'name': 'fsc', -\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'fsc'}, +\ 'executable': {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/sbtserver.vim b/sources_non_forked/ale/ale_linters/scala/sbtserver.vim index 694241d7..d4f137c2 100644 --- a/sources_non_forked/ale/ale_linters/scala/sbtserver.vim +++ b/sources_non_forked/ale/ale_linters/scala/sbtserver.vim @@ -25,7 +25,7 @@ endfunction call ale#linter#Define('scala', { \ 'name': 'sbtserver', \ 'lsp': 'socket', -\ 'address_callback': 'ale_linters#scala#sbtserver#GetAddress', +\ 'address': function('ale_linters#scala#sbtserver#GetAddress'), \ 'language': 'scala', -\ 'project_root_callback': 'ale_linters#scala#sbtserver#GetProjectRoot', +\ 'project_root': function('ale_linters#scala#sbtserver#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/scala/scalac.vim b/sources_non_forked/ale/ale_linters/scala/scalac.vim index 3dbdd925..1dd579b4 100644 --- a/sources_non_forked/ale/ale_linters/scala/scalac.vim +++ b/sources_non_forked/ale/ale_linters/scala/scalac.vim @@ -8,7 +8,7 @@ endfunction call ale#linter#Define('scala', { \ 'name': 'scalac', -\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'}, +\ 'executable': {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/scala/scalastyle.vim b/sources_non_forked/ale/ale_linters/scala/scalastyle.vim index 42228cf6..6e9e4c13 100644 --- a/sources_non_forked/ale/ale_linters/scala/scalastyle.vim +++ b/sources_non_forked/ale/ale_linters/scala/scalastyle.vim @@ -81,6 +81,6 @@ call ale#linter#Define('scala', { \ 'name': 'scalastyle', \ 'executable': 'scalastyle', \ 'output_stream': 'stdout', -\ 'command_callback': 'ale_linters#scala#scalastyle#GetCommand', +\ 'command': function('ale_linters#scala#scalastyle#GetCommand'), \ 'callback': 'ale_linters#scala#scalastyle#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/scss/sasslint.vim b/sources_non_forked/ale/ale_linters/scss/sasslint.vim index 8b725ba6..cf13546e 100644 --- a/sources_non_forked/ale/ale_linters/scss/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/scss/sasslint.vim @@ -22,7 +22,7 @@ endfunction call ale#linter#Define('scss', { \ 'name': 'sasslint', -\ 'executable_callback': 'ale_linters#scss#sasslint#GetExecutable', -\ 'command_callback': 'ale_linters#scss#sasslint#GetCommand', +\ 'executable': function('ale_linters#scss#sasslint#GetExecutable'), +\ 'command': function('ale_linters#scss#sasslint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim index 2bffa8e1..b5b21536 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -11,9 +11,9 @@ endfunction call ale#linter#Define('scss', { \ 'name': 'stylelint', -\ 'executable_callback': ale#node#FindExecutableFunc('scss_stylelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'scss_stylelint', [ \ 'node_modules/.bin/stylelint', -\ ]), -\ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', +\ ])}, +\ 'command': function('ale_linters#scss#stylelint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/sh/language_server.vim b/sources_non_forked/ale/ale_linters/sh/language_server.vim index 385d1119..5a3b0e9a 100644 --- a/sources_non_forked/ale/ale_linters/sh/language_server.vim +++ b/sources_non_forked/ale/ale_linters/sh/language_server.vim @@ -26,7 +26,7 @@ endfunction call ale#linter#Define('sh', { \ 'name': 'language_server', \ 'lsp': 'stdio', -\ 'executable_callback': 'ale_linters#sh#language_server#GetExecutable', -\ 'command_callback': 'ale_linters#sh#language_server#GetCommand', -\ 'project_root_callback': 'ale_linters#sh#language_server#GetProjectRoot', +\ 'executable': function('ale_linters#sh#language_server#GetExecutable'), +\ 'command': function('ale_linters#sh#language_server#GetCommand'), +\ 'project_root': function('ale_linters#sh#language_server#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/sh/shell.vim b/sources_non_forked/ale/ale_linters/sh/shell.vim index cf5e4e6c..189dc21d 100644 --- a/sources_non_forked/ale/ale_linters/sh/shell.vim +++ b/sources_non_forked/ale/ale_linters/sh/shell.vim @@ -51,7 +51,7 @@ endfunction call ale#linter#Define('sh', { \ 'name': 'shell', \ 'output_stream': 'stderr', -\ 'executable_callback': 'ale_linters#sh#shell#GetExecutable', -\ 'command_callback': 'ale_linters#sh#shell#GetCommand', +\ 'executable': function('ale_linters#sh#shell#GetExecutable'), +\ 'command': function('ale_linters#sh#shell#GetCommand'), \ 'callback': 'ale_linters#sh#shell#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim index 0f68e62c..bb7048cd 100644 --- a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim +++ b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim @@ -8,6 +8,7 @@ " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' 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_dialect', 'auto') call ale#Set('sh_shellcheck_options', '') function! ale_linters#sh#shellcheck#GetExecutable(buffer) abort @@ -53,9 +54,13 @@ function! ale_linters#sh#shellcheck#GetCommand(buffer, version_output) abort let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') - let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) + let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') let l:external_option = ale#semver#GTE(l:version, [0, 4, 0]) ? ' -x' : '' + if l:dialect is# 'auto' + let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) + endif + return ale#path#BufferCdString(a:buffer) \ . ale#Escape(l:executable) \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') @@ -103,7 +108,7 @@ endfunction call ale#linter#Define('sh', { \ 'name': 'shellcheck', -\ 'executable_callback': 'ale_linters#sh#shellcheck#GetExecutable', +\ 'executable': function('ale_linters#sh#shellcheck#GetExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#sh#shellcheck#VersionCheck'}, \ {'callback': 'ale_linters#sh#shellcheck#GetCommand'}, diff --git a/sources_non_forked/ale/ale_linters/slim/slimlint.vim b/sources_non_forked/ale/ale_linters/slim/slimlint.vim index 00c6b26c..1a4008ae 100644 --- a/sources_non_forked/ale/ale_linters/slim/slimlint.vim +++ b/sources_non_forked/ale/ale_linters/slim/slimlint.vim @@ -11,11 +11,11 @@ function! ale_linters#slim#slimlint#GetCommand(buffer) abort " " See https://github.com/sds/slim-lint/blob/master/lib/slim_lint/linter/README.md#rubocop if !empty(l:rubocop_config) - if ale#Has('win32') - let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command - else - let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command - endif + if ale#Has('win32') + let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command + else + let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command + endif endif return l:command @@ -50,6 +50,6 @@ endfunction call ale#linter#Define('slim', { \ 'name': 'slimlint', \ 'executable': 'slim-lint', -\ 'command_callback': 'ale_linters#slim#slimlint#GetCommand', +\ 'command': function('ale_linters#slim#slimlint#GetCommand'), \ 'callback': 'ale_linters#slim#slimlint#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/sml/smlnj.vim b/sources_non_forked/ale/ale_linters/sml/smlnj.vim index f15579ea..852ea170 100644 --- a/sources_non_forked/ale/ale_linters/sml/smlnj.vim +++ b/sources_non_forked/ale/ale_linters/sml/smlnj.vim @@ -3,7 +3,7 @@ call ale#linter#Define('sml', { \ 'name': 'smlnj', -\ 'executable_callback': 'ale#handlers#sml#GetExecutableSmlnjFile', +\ 'executable': function('ale#handlers#sml#GetExecutableSmlnjFile'), \ 'command': 'sml', \ 'callback': 'ale#handlers#sml#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim b/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim index bfa4bc05..9ad24af4 100644 --- a/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim +++ b/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim @@ -12,9 +12,9 @@ endfunction call ale#linter#Define('sml', { \ 'name': 'smlnj_cm', \ 'aliases': ['smlnj-cm'], -\ 'executable_callback': 'ale#handlers#sml#GetExecutableSmlnjCm', +\ 'executable': function('ale#handlers#sml#GetExecutableSmlnjCm'), \ 'lint_file': 1, -\ 'command_callback': 'ale_linters#sml#smlnj_cm#GetCommand', +\ 'command': function('ale_linters#sml#smlnj_cm#GetCommand'), \ 'callback': 'ale#handlers#sml#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim index 486bef1e..92ef4d63 100644 --- a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim +++ b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim @@ -72,7 +72,7 @@ endfunction call ale#linter#Define('spec', { \ 'name': 'rpmlint', -\ 'executable_callback': ale#VarFunc('spec_rpmlint_executable'), -\ 'command_callback': 'ale_linters#spec#rpmlint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'spec_rpmlint_executable')}, +\ 'command': function('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 2256f3c0..ce6f9426 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -12,9 +12,9 @@ endfunction call ale#linter#Define('stylus', { \ 'name': 'stylelint', -\ 'executable_callback': ale#node#FindExecutableFunc('stylus_stylelint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'stylus_stylelint', [ \ 'node_modules/.bin/stylelint', -\ ]), -\ 'command_callback': 'ale_linters#stylus#stylelint#GetCommand', +\ ])}, +\ 'command': function('ale_linters#stylus#stylelint#GetCommand'), \ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim index a1150658..237c45d3 100644 --- a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim +++ b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim @@ -6,10 +6,10 @@ call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [ - \ 'Pods/SwiftLint/swiftlint', - \ 'ios/Pods/SwiftLint/swiftlint', - \ 'swiftlint', - \]) + \ 'Pods/SwiftLint/swiftlint', + \ 'ios/Pods/SwiftLint/swiftlint', + \ 'swiftlint', + \]) endfunction function! ale_linters#swift#swiftlint#GetCommand(buffer) abort @@ -17,7 +17,7 @@ function! ale_linters#swift#swiftlint#GetCommand(buffer) abort let l:args = 'lint --use-stdin' return ale#Escape(l:executable) - \ . ' ' .l:args + \ . ' ' .l:args endfunction function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort @@ -26,10 +26,10 @@ function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:item = { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[4] is# 'error' ? 'E' : 'W', - \ 'text': l:match[5], - \} + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'text': l:match[5], + \} if l:match[4] is# 'error' let l:item.type = 'E' @@ -63,7 +63,7 @@ endfunction call ale#linter#Define('swift', { \ 'name': 'swiftlint', -\ 'executable_callback': 'ale_linters#swift#swiftlint#GetExecutable', -\ 'command_callback': 'ale_linters#swift#swiftlint#GetCommand', +\ 'executable': function('ale_linters#swift#swiftlint#GetExecutable'), +\ 'command': function('ale_linters#swift#swiftlint#GetCommand'), \ 'callback': 'ale_linters#swift#swiftlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim index 05fe581b..5a4940e1 100644 --- a/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim +++ b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim @@ -32,8 +32,8 @@ endfunction call ale#linter#Define('tcl', { \ 'name': 'nagelfar', \ 'output_stream': 'stdout', -\ 'executable_callback': ale#VarFunc('tcl_nagelfar_executable'), -\ 'command_callback': 'ale_linters#tcl#nagelfar#GetCommand', +\ 'executable': {b -> ale#Var(b, 'tcl_nagelfar_executable')}, +\ 'command': function('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 0d77835a..6d54a8b1 100644 --- a/sources_non_forked/ale/ale_linters/terraform/tflint.vim +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -52,7 +52,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'tflint', -\ 'executable_callback': ale#VarFunc('terraform_tflint_executable'), -\ 'command_callback': 'ale_linters#terraform#tflint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'terraform_tflint_executable')}, +\ 'command': function('ale_linters#terraform#tflint#GetCommand'), \ 'callback': 'ale_linters#terraform#tflint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/tex/alex.vim b/sources_non_forked/ale/ale_linters/tex/alex.vim index 78c530f7..5d9aec66 100644 --- a/sources_non_forked/ale/ale_linters/tex/alex.vim +++ b/sources_non_forked/ale/ale_linters/tex/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for TeX files -call ale#linter#Define('tex', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('tex', '--text') diff --git a/sources_non_forked/ale/ale_linters/tex/chktex.vim b/sources_non_forked/ale/ale_linters/tex/chktex.vim index 7f1b0c72..160baf0d 100644 --- a/sources_non_forked/ale/ale_linters/tex/chktex.vim +++ b/sources_non_forked/ale/ale_linters/tex/chktex.vim @@ -49,6 +49,6 @@ endfunction call ale#linter#Define('tex', { \ 'name': 'chktex', \ 'executable': 'chktex', -\ 'command_callback': 'ale_linters#tex#chktex#GetCommand', +\ 'command': function('ale_linters#tex#chktex#GetCommand'), \ 'callback': 'ale_linters#tex#chktex#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/tex/lacheck.vim b/sources_non_forked/ale/ale_linters/tex/lacheck.vim index ee09fb41..19d69403 100644 --- a/sources_non_forked/ale/ale_linters/tex/lacheck.vim +++ b/sources_non_forked/ale/ale_linters/tex/lacheck.vim @@ -37,7 +37,7 @@ endfunction call ale#linter#Define('tex', { \ 'name': 'lacheck', -\ 'executable_callback': ale#VarFunc('tex_lacheck_executable'), +\ 'executable': {b -> ale#Var(b, 'tex_lacheck_executable')}, \ 'command': '%e %t', \ 'callback': 'ale_linters#tex#lacheck#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/texinfo/alex.vim b/sources_non_forked/ale/ale_linters/texinfo/alex.vim index 4a884579..4d245524 100644 --- a/sources_non_forked/ale/ale_linters/texinfo/alex.vim +++ b/sources_non_forked/ale/ale_linters/texinfo/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for texinfo files -call ale#linter#Define('texinfo', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('texinfo', '--text') diff --git a/sources_non_forked/ale/ale_linters/text/alex.vim b/sources_non_forked/ale/ale_linters/text/alex.vim index c696367b..d87ed915 100644 --- a/sources_non_forked/ale/ale_linters/text/alex.vim +++ b/sources_non_forked/ale/ale_linters/text/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for text files -call ale#linter#Define('text', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('text', '--text') diff --git a/sources_non_forked/ale/ale_linters/text/textlint.vim b/sources_non_forked/ale/ale_linters/text/textlint.vim index 8fafdd7d..67c4e378 100644 --- a/sources_non_forked/ale/ale_linters/text/textlint.vim +++ b/sources_non_forked/ale/ale_linters/text/textlint.vim @@ -3,7 +3,7 @@ call ale#linter#Define('text', { \ 'name': 'textlint', -\ 'executable_callback': 'ale#handlers#textlint#GetExecutable', -\ 'command_callback': 'ale#handlers#textlint#GetCommand', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), \ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', \}) diff --git a/sources_non_forked/ale/ale_linters/thrift/thrift.vim b/sources_non_forked/ale/ale_linters/thrift/thrift.vim index 36a8656e..345c7abe 100644 --- a/sources_non_forked/ale/ale_linters/thrift/thrift.vim +++ b/sources_non_forked/ale/ale_linters/thrift/thrift.vim @@ -16,7 +16,7 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort let l:generators = ['cpp'] endif - let l:output_dir = ale#engine#CreateDirectory(a:buffer) + let l:output_dir = ale#command#CreateDirectory(a:buffer) return '%e' \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val"))) @@ -80,9 +80,8 @@ endfunction call ale#linter#Define('thrift', { \ 'name': 'thrift', -\ 'executable': 'thrift', \ 'output_stream': 'both', -\ 'executable_callback': ale#VarFunc('thrift_thrift_executable'), -\ 'command_callback': 'ale_linters#thrift#thrift#GetCommand', +\ 'executable': {b -> ale#Var(b, 'thrift_thrift_executable')}, +\ 'command': function('ale_linters#thrift#thrift#GetCommand'), \ 'callback': 'ale_linters#thrift#thrift#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/eslint.vim b/sources_non_forked/ale/ale_linters/typescript/eslint.vim index f1ae54e7..bf849337 100644 --- a/sources_non_forked/ale/ale_linters/typescript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/eslint.vim @@ -3,7 +3,7 @@ call ale#linter#Define('typescript', { \ 'name': 'eslint', -\ 'executable_callback': 'ale#handlers#eslint#GetExecutable', -\ 'command_callback': 'ale#handlers#eslint#GetCommand', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tslint.vim b/sources_non_forked/ale/ale_linters/typescript/tslint.vim index ccdca936..f70c2e45 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tslint.vim @@ -69,7 +69,7 @@ endfunction call ale#linter#Define('typescript', { \ 'name': 'tslint', -\ 'executable_callback': 'ale#handlers#tslint#GetExecutable', -\ 'command_callback': 'ale_linters#typescript#tslint#GetCommand', +\ 'executable': function('ale#handlers#tslint#GetExecutable'), +\ 'command': function('ale_linters#typescript#tslint#GetCommand'), \ 'callback': 'ale_linters#typescript#tslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index bac63229..840889f3 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -8,10 +8,10 @@ call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable_callback': ale#node#FindExecutableFunc('typescript_tsserver', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [ \ 'node_modules/.bin/tsserver', -\ ]), +\ ])}, \ 'command': '%e', -\ 'project_root_callback': {-> ''}, +\ 'project_root': function('ale#handlers#tsserver#GetProjectRoot'), \ 'language': '', \}) diff --git a/sources_non_forked/ale/ale_linters/verilog/iverilog.vim b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim index c64a3be6..e081f33f 100644 --- a/sources_non_forked/ale/ale_linters/verilog/iverilog.vim +++ b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim @@ -38,6 +38,6 @@ call ale#linter#Define('verilog', { \ 'name': 'iverilog', \ 'output_stream': 'stderr', \ 'executable': 'iverilog', -\ 'command_callback': 'ale_linters#verilog#iverilog#GetCommand', +\ 'command': function('ale_linters#verilog#iverilog#GetCommand'), \ 'callback': 'ale_linters#verilog#iverilog#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim index 83d5f59d..64bb6e41 100644 --- a/sources_non_forked/ale/ale_linters/verilog/verilator.vim +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -10,7 +10,7 @@ function! ale_linters#verilog#verilator#GetCommand(buffer) abort let l:filename = ale#util#Tempname() . '_verilator_linted.v' " Create a special filename, so we can detect it in the handler. - call ale#engine#ManageFile(a:buffer, l:filename) + call ale#command#ManageFile(a:buffer, l:filename) let l:lines = getbufline(a:buffer, 1, '$') call ale#util#Writefile(a:buffer, l:lines, l:filename) @@ -53,7 +53,7 @@ call ale#linter#Define('verilog', { \ 'name': 'verilator', \ 'output_stream': 'stderr', \ 'executable': 'verilator', -\ 'command_callback': 'ale_linters#verilog#verilator#GetCommand', +\ 'command': function('ale_linters#verilog#verilator#GetCommand'), \ 'callback': 'ale_linters#verilog#verilator#Handle', \ 'read_buffer': 0, \}) 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 index 3da44206..822eb30a 100644 --- 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 @@ -25,7 +25,7 @@ endfunction function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort let l:dir = s:GetALEProjectDir(a:buffer) - let l:temp_dir = ale#engine#CreateDirectory(a:buffer) + let l:temp_dir = ale#command#CreateDirectory(a:buffer) let l:temp_file = l:temp_dir . '/example.vim' let l:lines = getbufline(a:buffer, 1, '$') @@ -58,8 +58,8 @@ 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', +\ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'), +\ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'), \ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', \ 'read_buffer': 0, \}) diff --git a/sources_non_forked/ale/ale_linters/vim/vint.vim b/sources_non_forked/ale/ale_linters/vim/vint.vim index cf2d4afd..3808c47e 100644 --- a/sources_non_forked/ale/ale_linters/vim/vint.vim +++ b/sources_non_forked/ale/ale_linters/vim/vint.vim @@ -65,7 +65,7 @@ endfunction call ale#linter#Define('vim', { \ 'name': 'vint', -\ 'executable_callback': 'ale_linters#vim#vint#GetExecutable', +\ 'executable': function('ale_linters#vim#vint#GetExecutable'), \ 'command_chain': [ \ {'callback': 'ale_linters#vim#vint#VersionCommand', 'output_stream': 'stderr'}, \ {'callback': 'ale_linters#vim#vint#GetCommand', 'output_stream': 'stdout'}, diff --git a/sources_non_forked/ale/ale_linters/vue/vls.vim b/sources_non_forked/ale/ale_linters/vue/vls.vim index 7116128b..ac451f3c 100644 --- a/sources_non_forked/ale/ale_linters/vue/vls.vim +++ b/sources_non_forked/ale/ale_linters/vue/vls.vim @@ -13,10 +13,10 @@ endfunction call ale#linter#Define('vue', { \ 'name': 'vls', \ 'lsp': 'stdio', -\ 'executable_callback': ale#node#FindExecutableFunc('vue_vls', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'vue_vls', [ \ 'node_modules/.bin/vls', -\ ]), +\ ])}, \ 'command': '%e --stdio', \ 'language': 'vue', -\ 'project_root_callback': 'ale_linters#vue#vls#GetProjectRoot', +\ 'project_root': function('ale_linters#vue#vls#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/xhtml/alex.vim b/sources_non_forked/ale/ale_linters/xhtml/alex.vim index 60a9a7c9..97f3b59a 100644 --- a/sources_non_forked/ale/ale_linters/xhtml/alex.vim +++ b/sources_non_forked/ale/ale_linters/xhtml/alex.vim @@ -1,11 +1,4 @@ " Author: Johannes Wienke " Description: alex for XHTML files -call ale#linter#Define('xhtml', { -\ 'name': 'alex', -\ 'executable': 'alex', -\ 'command': 'alex %s -t', -\ 'output_stream': 'stderr', -\ 'callback': 'ale#handlers#alex#Handle', -\ 'lint_file': 1, -\}) +call ale#handlers#alex#DefineLinter('xhtml', '--text') diff --git a/sources_non_forked/ale/ale_linters/xml/xmllint.vim b/sources_non_forked/ale/ale_linters/xml/xmllint.vim index 59f43d16..553d0883 100644 --- a/sources_non_forked/ale/ale_linters/xml/xmllint.vim +++ b/sources_non_forked/ale/ale_linters/xml/xmllint.vim @@ -29,27 +29,27 @@ function! ale_linters#xml#xmllint#Handle(buffer, lines) abort let l:match_message = matchlist(l:line, l:pattern_message) if !empty(l:match_message) - let l:line = l:match_message[2] + 0 - let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E' - let l:text = l:match_message[3] + let l:line = l:match_message[2] + 0 + let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E' + let l:text = l:match_message[3] - call add(l:output, { - \ 'lnum': l:line, - \ 'text': l:text, - \ 'type': l:type, - \}) + call add(l:output, { + \ 'lnum': l:line, + \ 'text': l:text, + \ 'type': l:type, + \}) - continue + continue endif " Parse column position let l:match_column_token = matchlist(l:line, l:pattern_column_token) if !empty(l:output) && !empty(l:match_column_token) - let l:previous = l:output[len(l:output) - 1] - let l:previous['col'] = len(l:match_column_token[0]) + let l:previous = l:output[len(l:output) - 1] + let l:previous['col'] = len(l:match_column_token[0]) - continue + continue endif endfor @@ -59,7 +59,7 @@ endfunction call ale#linter#Define('xml', { \ 'name': 'xmllint', \ 'output_stream': 'stderr', -\ 'executable_callback': ale#VarFunc('xml_xmllint_executable'), -\ 'command_callback': 'ale_linters#xml#xmllint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'xml_xmllint_executable')}, +\ 'command': function('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 7362536e..1f140e37 100644 --- a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -32,9 +32,9 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'swaglint', -\ 'executable_callback': ale#node#FindExecutableFunc('yaml_swaglint', [ +\ 'executable': {b -> ale#node#FindExecutable(b, '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 9d2cc7c2..bedb7bf1 100644 --- a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim @@ -44,7 +44,7 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'yamllint', -\ 'executable_callback': ale#VarFunc('yaml_yamllint_executable'), -\ 'command_callback': 'ale_linters#yaml#yamllint#GetCommand', +\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, +\ 'command': function('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 index 45776f98..81fcaa0e 100644 --- a/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim +++ b/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim @@ -9,7 +9,7 @@ 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', +\ 'executable': {b -> ale#Var(b, 'yang_lsp_executable')}, +\ 'project_root': function('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 f6c23d72..5aa5fbfc 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -169,11 +169,6 @@ 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 ed08ed09..6c2586a6 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -26,6 +26,11 @@ function! ale#assert#Linter(expected_executable, expected_command) abort let l:linter = s:GetLinter() let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) + while ale#command#IsDeferred(l:executable) + call ale#test#FlushJobs() + let l:executable = l:executable.value + endwhile + if has_key(l:linter, 'command_chain') let l:callbacks = map(copy(l:linter.command_chain), 'v:val.callback') @@ -54,13 +59,18 @@ function! ale#assert#Linter(expected_executable, expected_command) abort endif else let l:command = ale#linter#GetCommand(l:buffer, l:linter) + + while ale#command#IsDeferred(l:command) + call ale#test#FlushJobs() + let l:command = l:command.value + endwhile 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 + elseif type(l:command) is v:t_list call map(l:command, 'substitute(v:val, ''%e'', ''\=ale#Escape(l:executable)'', ''g'')') endif @@ -104,7 +114,7 @@ endfunction function! ale#assert#LSPProject(expected_root) abort let l:buffer = bufnr('') let l:linter = s:GetLinter() - let l:root = ale#util#GetFunction(l:linter.project_root_callback)(l:buffer) + let l:root = ale#lsp_linter#FindProjectRoot(l:buffer, l:linter) AssertEqual a:expected_root, l:root endfunction @@ -112,11 +122,22 @@ endfunction function! ale#assert#LSPAddress(expected_address) abort let l:buffer = bufnr('') let l:linter = s:GetLinter() - let l:address = ale#util#GetFunction(l:linter.address_callback)(l:buffer) + let l:address = ale#linter#GetAddress(l:buffer, l:linter) AssertEqual a:expected_address, l:address endfunction +function! ale#assert#SetUpLinterTestCommands() abort + command! -nargs=+ WithChainResults :call ale#assert#WithChainResults() + command! -nargs=+ AssertLinter :call ale#assert#Linter() + command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted() + command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions() + command! -nargs=+ AssertLSPConfig :call ale#assert#LSPConfig() + command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage() + command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject() + command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress() +endfunction + " A dummy function for making sure this module is loaded. function! ale#assert#SetUpLinterTest(filetype, name) abort " Set up a marker so ALE doesn't create real random temporary filenames. @@ -129,6 +150,12 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort let l:prefix = 'ale_' . a:filetype . '_' . a:name let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + Save g:ale_lsp_root + let g:ale_lsp_root = {} + + Save b:ale_lsp_root + unlet! b:ale_lsp_root + Save g:ale_c_build_dir unlet! g:ale_c_build_dir @@ -151,14 +178,7 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort call ale#test#SetDirectory('/testplugin/test/command_callback') endif - command! -nargs=+ WithChainResults :call ale#assert#WithChainResults() - command! -nargs=+ AssertLinter :call ale#assert#Linter() - command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted() - command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions() - command! -nargs=+ AssertLSPConfig :call ale#assert#LSPConfig() - command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage() - command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject() - command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress() + call ale#assert#SetUpLinterTestCommands() endfunction function! ale#assert#TearDownLinterTest() abort diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index 746d19b0..d759b25a 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -46,61 +46,76 @@ function! ale#c#FindProjectRoot(buffer) abort return '' endfunction -function! ale#c#ParseCFlags(path_prefix, cflag_line) abort - let l:cflags_list = [] - let l:previous_options = '' +function! ale#c#AreSpecialCharsBalanced(option) abort + " Escape \" + let l:option_escaped = substitute(a:option, '\\"', '', 'g') - let l:split_lines = split(a:cflag_line, ' ') + " Retain special chars only + let l:special_chars = substitute(l:option_escaped, '[^"''()`]', '', 'g') + let l:special_chars = split(l:special_chars, '\zs') + + " Check if they are balanced + let l:stack = [] + + for l:char in l:special_chars + if l:char is# ')' + if len(l:stack) == 0 || get(l:stack, -1) isnot# '(' + return 0 + endif + + call remove(l:stack, -1) + elseif l:char is# '(' + call add(l:stack, l:char) + else + if len(l:stack) > 0 && get(l:stack, -1) is# l:char + call remove(l:stack, -1) + else + call add(l:stack, l:char) + endif + endif + endfor + + return len(l:stack) == 0 +endfunction + +function! ale#c#ParseCFlags(path_prefix, cflag_line) abort + let l:split_lines = split(a:cflag_line) let l:option_index = 0 while l:option_index < len(l:split_lines) - let l:option = l:previous_options . l:split_lines[l:option_index] - let l:option_index = l:option_index + 1 + let l:next_option_index = l:option_index + 1 - " Check if cflag contained an unmatched characters and should not have been splitted - let l:option_special = substitute(l:option, '\\"', '', 'g') - let l:option_special = substitute(l:option_special, '[^"''()`]', '', 'g') - let l:option_special = substitute(l:option_special, '""', '', 'g') - let l:option_special = substitute(l:option_special, '''''', '', 'g') - let l:option_special = substitute(l:option_special, '``', '', 'g') - let l:option_special = substitute(l:option_special, '((', '(', 'g') - let l:option_special = substitute(l:option_special, '))', ')', 'g') - let l:option_special = substitute(l:option_special, '()', '', 'g') + " Join space-separated option + while l:next_option_index < len(l:split_lines) + \&& stridx(l:split_lines[l:next_option_index], '-') != 0 + let l:next_option_index += 1 + endwhile - if len(l:option_special) > 0 && l:option_index < len(l:split_lines) - let l:previous_options = l:option . ' ' - continue - endif + let l:option = join(l:split_lines[l:option_index : l:next_option_index-1], ' ') + call remove(l:split_lines, l:option_index, l:next_option_index-1) + call insert(l:split_lines, l:option, l:option_index) - " Check if there was spaces after -D/-I and the flag should not have been splitted - if l:option is# '-D' || l:option is# '-I' - let l:previous_options = l:option - continue - endif - - let l:previous_options = '' - - - " Fix relative paths if needed - if stridx(l:option, '-I') >= 0 && - \ stridx(l:option, '-I' . s:sep) < 0 - let l:rel_path = join(split(l:option, '\zs')[2:], '') - let l:rel_path = substitute(l:rel_path, '"', '', 'g') - let l:rel_path = substitute(l:rel_path, '''', '', 'g') - let l:option = ale#Escape('-I' . a:path_prefix . - \ s:sep . l:rel_path) - endif - - " Parse the cflag - if stridx(l:option, '-I') >= 0 || - \ stridx(l:option, '-D') >= 0 - if index(l:cflags_list, l:option) < 0 - call add(l:cflags_list, l:option) + " Ignore invalid or conflicting options + if stridx(l:option, '-') != 0 + \|| stridx(l:option, '-o') == 0 + \|| stridx(l:option, '-c') == 0 + call remove(l:split_lines, l:option_index) + let l:option_index = l:option_index - 1 + " Fix relative path + elseif stridx(l:option, '-I') == 0 + if !(stridx(l:option, ':') == 2+1 || stridx(l:option, '/') == 2+0) + let l:option = '-I' . a:path_prefix . s:sep . l:option[2:] + call remove(l:split_lines, l:option_index) + call insert(l:split_lines, l:option, l:option_index) endif endif + + let l:option_index = l:option_index + 1 endwhile - return join(l:cflags_list, ' ') + call uniq(l:split_lines) + + return join(l:split_lines, ' ') endfunction function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort @@ -187,7 +202,7 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort let l:file_lookup[l:basename] = get(l:file_lookup, l:basename, []) + [l:entry] let l:dirbasename = tolower(fnamemodify(l:entry.directory, ':p:h:t')) - let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:basename, []) + [l:entry] + let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:dirbasename, []) + [l:entry] endfor if !empty(l:file_lookup) && !empty(l:dir_lookup) @@ -200,14 +215,14 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort return l:empty endfunction -function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup) abort +function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort " Search for an exact file match first. let l:basename = tolower(expand('#' . a:buffer . ':t')) let l:file_list = get(a:file_lookup, l:basename, []) for l:item in l:file_list - if bufnr(l:item.file) is a:buffer - return ale#c#ParseCFlags(a:dir, l:item.command) + if bufnr(l:item.file) is a:buffer && has_key(l:item, 'command') + return ale#c#ParseCFlags(l:item.directory, l:item.command) endif endfor @@ -219,7 +234,8 @@ function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup) for l:item in l:dir_list if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir - return ale#c#ParseCFlags(a:dir, l:item.command) + \&& has_key(l:item, 'command') + return ale#c#ParseCFlags(l:item.directory, l:item.command) endif endfor @@ -227,12 +243,11 @@ function! ale#c#ParseCompileCommandsFlags(buffer, dir, file_lookup, dir_lookup) endfunction function! ale#c#FlagsFromCompileCommands(buffer, compile_commands_file) abort - let l:dir = ale#path#Dirname(a:compile_commands_file) let l:lookups = s:GetLookupFromCompileCommandsFile(a:compile_commands_file) let l:file_lookup = l:lookups[0] let l:dir_lookup = l:lookups[1] - return ale#c#ParseCompileCommandsFlags(a:buffer, l:dir, l:file_lookup, l:dir_lookup) + return ale#c#ParseCompileCommandsFlags(a:buffer, l:file_lookup, l:dir_lookup) endfunction function! ale#c#GetCFlags(buffer, output) abort diff --git a/sources_non_forked/ale/autoload/ale/command.vim b/sources_non_forked/ale/autoload/ale/command.vim index 543c9953..33ce577c 100644 --- a/sources_non_forked/ale/autoload/ale/command.vim +++ b/sources_non_forked/ale/autoload/ale/command.vim @@ -1,6 +1,117 @@ " Author: w0rp -" Description: Special command formatting for creating temporary files and -" passing buffer filenames easily. +" Description: Functions for formatting command strings, running commands, and +" managing files during linting and fixing cycles. + +" This dictionary holds lists of files and directories to remove later. +if !exists('s:buffer_data') + let s:buffer_data = {} +endif + +" Used to get the data in tests. +function! ale#command#GetData() abort + return deepcopy(s:buffer_data) +endfunction + +function! ale#command#ClearData() abort + let s:buffer_data = {} +endfunction + +function! ale#command#InitData(buffer) abort + if !has_key(s:buffer_data, a:buffer) + let s:buffer_data[a:buffer] = { + \ 'jobs': {}, + \ 'file_list': [], + \ 'directory_list': [], + \} + endif +endfunction + +function! ale#command#ManageFile(buffer, file) abort + call ale#command#InitData(a:buffer) + call add(s:buffer_data[a:buffer].file_list, a:file) +endfunction + +function! ale#command#ManageDirectory(buffer, directory) abort + call ale#command#InitData(a:buffer) + call add(s:buffer_data[a:buffer].directory_list, a:directory) +endfunction + +function! ale#command#CreateFile(buffer) abort + " This variable can be set to 1 in tests to stub this out. + if get(g:, 'ale_create_dummy_temporary_file') + return 'TEMP' + endif + + let l:temporary_file = ale#util#Tempname() + call ale#command#ManageFile(a:buffer, l:temporary_file) + + return l:temporary_file +endfunction + +" Create a new temporary directory and manage it in one go. +function! ale#command#CreateDirectory(buffer) abort + " This variable can be set to 1 in tests to stub this out. + if get(g:, 'ale_create_dummy_temporary_file') + return 'TEMP_DIR' + endif + + let l:temporary_directory = ale#util#Tempname() + " Create the temporary directory for the file, unreadable by 'other' + " users. + call mkdir(l:temporary_directory, '', 0750) + call ale#command#ManageDirectory(a:buffer, l:temporary_directory) + + return l:temporary_directory +endfunction + +function! ale#command#RemoveManagedFiles(buffer) abort + let l:info = get(s:buffer_data, a:buffer, {}) + + if !empty(l:info) && empty(l:info.jobs) + " We can't delete anything in a sandbox, so wait until we escape from + " it to delete temporary files and directories. + if ale#util#InSandbox() + return + endif + + " Delete files with a call akin to a plan `rm` command. + for l:filename in l:info.file_list + call delete(l:filename) + endfor + + " Delete directories like `rm -rf`. + " Directories are handled differently from files, so paths that are + " intended to be single files can be set up for automatic deletion + " without accidentally deleting entire directories. + for l:directory in l:info.directory_list + call delete(l:directory, 'rf') + endfor + + call remove(s:buffer_data, a:buffer) + endif +endfunction + +function! ale#command#CreateTempFile(buffer, temporary_file, input) abort + if empty(a:temporary_file) + " There is no file, so we didn't create anything. + return 0 + endif + + " Use an existing list of lines of input if we have it, or get the lines + " from the file. + let l:lines = a:input isnot v:null ? a:input : getbufline(a:buffer, 1, '$') + + let l:temporary_directory = fnamemodify(a:temporary_file, ':h') + " Create the temporary directory for the file, unreadable by 'other' + " users. + call mkdir(l:temporary_directory, '', 0750) + " Automatically delete the directory later. + call ale#command#ManageDirectory(a:buffer, l:temporary_directory) + " Write the buffer out to a file. + call ale#util#Writefile(a:buffer, l:lines, a:temporary_file) + + return 1 +endfunction function! s:TemporaryFilename(buffer) abort let l:filename = fnamemodify(bufname(a:buffer), ':t') @@ -16,11 +127,17 @@ function! s:TemporaryFilename(buffer) abort return ale#util#Tempname() . (has('win32') ? '\' : '/') . l:filename endfunction +" Given part of a command, replace any % with %%, so that no characters in +" the string will be replaced with filenames, etc. +function! ale#command#EscapeCommandPart(command_part) abort + return substitute(a:command_part, '%', '%%', 'g') +endfunction + " Given a command string, replace every... " %s -> with the current filename " %t -> with the name of an unused file in a temporary directory " %% -> with a literal % -function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed) abort +function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed, input) abort let l:temporary_file = '' let l:command = a:command @@ -40,7 +157,7 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne let l:command = substitute(l:command, '%s', '\=ale#Escape(l:filename)', 'g') endif - if l:command =~# '%t' + if a:input isnot v:false && l:command =~# '%t' " Create a temporary filename, / " The file itself will not be created by this function. let l:temporary_file = s:TemporaryFilename(a:buffer) @@ -58,5 +175,189 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne let l:command = l:command . ' < ' . ale#Escape(l:temporary_file) endif - return [l:temporary_file, l:command] + let l:file_created = ale#command#CreateTempFile( + \ a:buffer, + \ l:temporary_file, + \ a:input, + \) + + return [l:temporary_file, l:command, l:file_created] +endfunction + +function! ale#command#StopJobs(buffer, job_type) abort + let l:info = get(s:buffer_data, a:buffer, {}) + + if !empty(l:info) + let l:new_map = {} + + for [l:job_id, l:job_type] in items(l:info.jobs) + let l:job_id = str2nr(l:job_id) + + if a:job_type is# 'all' || a:job_type is# l:job_type + call ale#job#Stop(l:job_id) + else + let l:new_map[l:job_id] = l:job_type + endif + endfor + + let l:info.jobs = l:new_map + endif +endfunction + +function! s:GatherOutput(line_list, job_id, line) abort + call add(a:line_list, a:line) +endfunction + +function! s:ExitCallback(buffer, line_list, Callback, data) abort + if !has_key(s:buffer_data, a:buffer) + return + endif + + let l:jobs = s:buffer_data[a:buffer].jobs + + if !has_key(l:jobs, a:data.job_id) + return + endif + + let l:job_type = remove(l:jobs, a:data.job_id) + + if g:ale_history_enabled + call ale#history#SetExitCode(a:buffer, a:data.job_id, a:data.exit_code) + + " Log the output of the command for ALEInfo if we should. + if g:ale_history_log_output && a:data.log_output is 1 + call ale#history#RememberOutput( + \ a:buffer, + \ a:data.job_id, + \ a:line_list[:] + \) + endif + endif + + " If the callback starts any new jobs, use the same job type for them. + call setbufvar(a:buffer, 'ale_job_type', l:job_type) + let l:value = a:Callback(a:buffer, a:line_list, { + \ 'exit_code': a:data.exit_code, + \ 'temporary_file': a:data.temporary_file, + \}) + + let l:result = a:data.result + let l:result.value = l:value + + if get(l:result, 'result_callback', v:null) isnot v:null + call call(l:result.result_callback, [l:value]) + endif +endfunction + +function! ale#command#Run(buffer, command, Callback, ...) abort + let l:options = get(a:000, 0, {}) + + if len(a:000) > 1 + throw 'Too many arguments!' + endif + + let l:output_stream = get(l:options, 'output_stream', 'stdout') + let l:line_list = [] + + let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand( + \ a:buffer, + \ get(l:options, 'executable', ''), + \ a:command, + \ get(l:options, 'read_buffer', 0), + \ get(l:options, 'input', v:null), + \) + let l:command = ale#job#PrepareCommand(a:buffer, l:command) + let l:job_options = { + \ 'exit_cb': {job_id, exit_code -> s:ExitCallback( + \ a:buffer, + \ l:line_list, + \ a:Callback, + \ { + \ 'job_id': job_id, + \ 'exit_code': exit_code, + \ 'temporary_file': l:temporary_file, + \ 'log_output': get(l:options, 'log_output', 1), + \ 'result': l:result, + \ } + \ )}, + \ 'mode': 'nl', + \} + + if l:output_stream is# 'stdout' + let l:job_options.out_cb = function('s:GatherOutput', [l:line_list]) + elseif l:output_stream is# 'stderr' + let l:job_options.err_cb = function('s:GatherOutput', [l:line_list]) + elseif l:output_stream is# 'both' + let l:job_options.out_cb = function('s:GatherOutput', [l:line_list]) + let l:job_options.err_cb = function('s:GatherOutput', [l:line_list]) + endif + + let l:status = 'failed' + + if get(g:, 'ale_run_synchronously') == 1 + if get(g:, 'ale_emulate_job_failure') == 1 + let l:job_id = 0 + else + " Generate a fake job ID for tests. + let s:fake_job_id = get(s:, 'fake_job_id', 0) + 1 + let l:job_id = s:fake_job_id + endif + elseif has('win32') + let l:job_id = ale#job#StartWithCmd(l:command, l:job_options) + else + let l:job_id = ale#job#Start(l:command, l:job_options) + endif + + if l:job_id + let l:status = 'started' + let l:job_type = getbufvar(a:buffer, 'ale_job_type', 'all') + + call ale#command#InitData(a:buffer) + let s:buffer_data[a:buffer].jobs[l:job_id] = l:job_type + endif + + if g:ale_history_enabled + call ale#history#Add(a:buffer, l:status, l:job_id, l:command) + endif + + if !l:job_id + return 0 + endif + + " We'll return this Dictionary. A `result_callback` can be assigned to it + " later for capturing the result of a:Callback. + " + " The `_deferred_job_id` is used for both checking the type of object, and + " for checking the job ID and status. + let l:result = {'_deferred_job_id': l:job_id} + + if get(g:, 'ale_run_synchronously') == 1 && l:job_id + " Run a command synchronously if this test option is set. + call extend(l:line_list, systemlist( + \ type(l:command) is v:t_list + \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) + \ : l:command + \)) + + " Don't capture output when the callbacks aren't set. + if !has_key(l:job_options, 'out_cb') + \&& !has_key(l:job_options, 'err_cb') + let l:line_list = [] + endif + + if !exists('g:ale_run_synchronously_callbacks') + let g:ale_run_synchronously_callbacks = [] + endif + + call add( + \ g:ale_run_synchronously_callbacks, + \ {-> l:job_options.exit_cb(l:job_id, v:shell_error)} + \) + endif + + return l:result +endfunction + +function! ale#command#IsDeferred(value) abort + return type(a:value) is v:t_dict && has_key(a:value, '_deferred_job_id') endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 3bf29191..782a68e4 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -89,6 +89,10 @@ function! ale#completion#GetPrefix(filetype, line, column) abort endfunction function! ale#completion#GetTriggerCharacter(filetype, prefix) abort + if empty(a:prefix) + return '' + endif + let l:char_list = s:GetFiletypeValue(s:trigger_character_map, a:filetype) if index(l:char_list, a:prefix) >= 0 @@ -100,33 +104,38 @@ endfunction function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort let l:excluded_words = ale#Var(a:buffer, 'completion_excluded_words') - let l:triggers = s:GetFiletypeValue(s:trigger_character_map, a:filetype) - " For completing... - " foo. - " ^ - " We need to include all of the given suggestions. - if index(l:triggers, a:prefix) >= 0 + if empty(a:prefix) let l:filtered_suggestions = a:suggestions else - let l:filtered_suggestions = [] + let l:triggers = s:GetFiletypeValue(s:trigger_character_map, a:filetype) - " Filter suggestions down to those starting with the prefix we used for - " finding suggestions in the first place. - " - " Some completion tools will include suggestions which don't even start - " with the characters we have already typed. - for l:item in a:suggestions - " A List of String values or a List of completion item Dictionaries - " is accepted here. - let l:word = type(l:item) is v:t_string ? l:item : l:item.word + " For completing... + " foo. + " ^ + " We need to include all of the given suggestions. + if index(l:triggers, a:prefix) >= 0 || empty(a:prefix) + let l:filtered_suggestions = a:suggestions + else + let l:filtered_suggestions = [] - " Add suggestions if the suggestion starts with a case-insensitive - " match for the prefix. - if l:word[: len(a:prefix) - 1] is? a:prefix - call add(l:filtered_suggestions, l:item) - endif - endfor + " Filter suggestions down to those starting with the prefix we + " used for finding suggestions in the first place. + " + " Some completion tools will include suggestions which don't even + " start with the characters we have already typed. + for l:item in a:suggestions + " A List of String values or a List of completion item + " Dictionaries is accepted here. + let l:word = type(l:item) is v:t_string ? l:item : l:item.word + + " Add suggestions if the suggestion starts with a + " case-insensitive match for the prefix. + if l:word[: len(a:prefix) - 1] is? a:prefix + call add(l:filtered_suggestions, l:item) + endif + endfor + endif endif if !empty(l:excluded_words) @@ -227,7 +236,7 @@ function! ale#completion#Show(response, completion_parser) abort endfunction function! s:CompletionStillValid(request_id) abort - let [l:line, l:column] = getcurpos()[1:2] + let [l:line, l:column] = getpos('.')[1:2] return ale#util#Mode() is# 'i' \&& has_key(b:, 'ale_completion_info') @@ -307,7 +316,7 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort endfunction function! ale#completion#NullFilter(buffer, item) abort - return 1 + return 1 endfunction function! ale#completion#ParseLSPCompletions(response) abort @@ -437,10 +446,15 @@ function! ale#completion#HandleLSPResponse(conn_id, response) abort \) endfunction -function! s:OnReady(linter, lsp_details, ...) abort - let l:buffer = a:lsp_details.buffer +function! s:OnReady(linter, lsp_details) abort let l:id = a:lsp_details.connection_id + if !ale#lsp#HasCapability(l:id, 'completion') + return + endif + + let l:buffer = a:lsp_details.buffer + " If we have sent a completion request already, don't send another. if b:ale_completion_info.request_id return @@ -472,7 +486,7 @@ function! s:OnReady(linter, lsp_details, ...) abort \ min([ \ b:ale_completion_info.line_length, \ b:ale_completion_info.column, - \ ]), + \ ]) + 1, \ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix), \) endif @@ -489,37 +503,22 @@ function! s:OnReady(linter, lsp_details, ...) abort endif endfunction -function! s:GetLSPCompletions(linter) abort - let l:buffer = bufnr('') - let l:lsp_details = ale#lsp_linter#StartLSP(l:buffer, a:linter) - - if empty(l:lsp_details) - return 0 - endif - - let l:id = l:lsp_details.connection_id - - let l:OnReady = function('s:OnReady', [a:linter, l:lsp_details]) - - call ale#lsp#WaitForCapability(l:id, 'completion', l:OnReady) -endfunction - function! ale#completion#GetCompletions() abort if !g:ale_completion_enabled return endif - call ale#completion#AlwaysGetCompletions() + call ale#completion#AlwaysGetCompletions(1) endfunction " This function can be used to manually trigger autocomplete, even when " g:ale_completion_enabled is set to false -function! ale#completion#AlwaysGetCompletions() abort - let [l:line, l:column] = getcurpos()[1:2] +function! ale#completion#AlwaysGetCompletions(need_prefix) abort + let [l:line, l:column] = getpos('.')[1:2] let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) - if empty(l:prefix) + if a:need_prefix && empty(l:prefix) return endif @@ -534,9 +533,12 @@ function! ale#completion#AlwaysGetCompletions() abort \ 'request_id': 0, \} + let l:buffer = bufnr('') + let l:Callback = function('s:OnReady') + for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) - call s:GetLSPCompletions(l:linter) + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) endif endfor endfunction @@ -544,7 +546,7 @@ endfunction function! s:TimerHandler(...) abort let s:timer_id = -1 - let [l:line, l:column] = getcurpos()[1:2] + let [l:line, l:column] = getpos('.')[1:2] " When running the timer callback, we have to be sure that the cursor " hasn't moved from where it was when we requested completions by typing. @@ -567,7 +569,7 @@ function! ale#completion#Queue() abort return endif - let s:timer_pos = getcurpos()[1:2] + let s:timer_pos = getpos('.')[1:2] if s:timer_pos == s:last_done_pos " Do not ask for completions if the cursor rests on the position we @@ -591,7 +593,7 @@ function! ale#completion#Done() abort call ale#completion#RestoreCompletionOptions() - let s:last_done_pos = getcurpos()[1:2] + let s:last_done_pos = getpos('.')[1:2] endfunction function! s:Setup(enabled) abort diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim index 6672c349..eea8ffe6 100644 --- a/sources_non_forked/ale/autoload/ale/cursor.vim +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -22,7 +22,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort let l:shortmess_options = &l:shortmess try - let l:cursor_position = getcurpos() + let l:cursor_position = getpos('.') " The message is truncated and saved to the history. setlocal shortmess+=T @@ -44,7 +44,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort " Reset the cursor position if we moved off the end of the line. " Using :norm and :echomsg can move the cursor off the end of the " line. - if l:cursor_position != getcurpos() + if l:cursor_position != getpos('.') call setpos('.', l:cursor_position) endif finally @@ -114,7 +114,7 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort call s:StopCursorTimer() - let l:pos = getcurpos()[0:2] + let l:pos = getpos('.')[0:2] " Check the current buffer, line, and column number against the last " recorded position. If the position has actually changed, *then* diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index 3aed38fe..e4bf5e7e 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -31,6 +31,7 @@ let s:global_variable_list = [ \ 'ale_list_vertical', \ 'ale_list_window_size', \ 'ale_loclist_msg_format', +\ 'ale_lsp_root', \ 'ale_max_buffer_history_size', \ 'ale_max_signs', \ 'ale_maximum_file_size', diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 79d12596..521f0b45 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -57,10 +57,15 @@ 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 +function! s:OnReady(line, column, options, capability, linter, lsp_details) abort let l:id = a:lsp_details.connection_id + if !ale#lsp#HasCapability(l:id, a:capability) + return + endif + + let l:buffer = a:lsp_details.buffer + let l:Callback = a:linter.lsp is# 'tsserver' \ ? function('ale#definition#HandleTSServerResponse') \ : function('ale#definition#HandleLSPResponse') @@ -80,7 +85,14 @@ function! s:OnReady(linter, lsp_details, line, column, options, ...) abort " 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) + if a:capability is# 'definition' + let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column) + elseif a:capability is# 'typeDefinition' + let l:message = ale#lsp#message#TypeDefinition(l:buffer, a:line, a:column) + else + " XXX: log here? + return + endif endif let l:request_id = ale#lsp#Send(l:id, l:message) @@ -90,30 +102,36 @@ function! s:OnReady(linter, lsp_details, line, column, options, ...) abort \} endfunction -function! s:GoToLSPDefinition(linter, options) abort +function! s:GoToLSPDefinition(linter, options, capability) abort let l:buffer = bufnr('') - let [l:line, l:column] = getcurpos()[1:2] - let l:lsp_details = ale#lsp_linter#StartLSP(l:buffer, a:linter) + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) - if a:linter.lsp isnot# 'tsserver' - let l:column = min([l:column, len(getline(l:line))]) - endif - - if empty(l:lsp_details) - return 0 - endif - - let l:id = l:lsp_details.connection_id - - call ale#lsp#WaitForCapability(l:id, 'definition', function('s:OnReady', [ - \ a:linter, l:lsp_details, l:line, l:column, a:options - \])) + let l:Callback = function( + \ 's:OnReady', + \ [l:line, l:column, a:options, a:capability] + \) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) endfunction function! ale#definition#GoTo(options) abort for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) - call s:GoToLSPDefinition(l:linter, a:options) + call s:GoToLSPDefinition(l:linter, a:options, 'definition') + endif + endfor +endfunction + +function! ale#definition#GoToType(options) abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + " TODO: handle typeDefinition for tsserver if supported by the + " protocol + if l:linter.lsp is# 'tsserver' + continue + endif + + call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition') endif endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index b44be73c..340f6913 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -5,20 +5,10 @@ " Remapping of linter problems. let g:ale_type_map = get(g:, 'ale_type_map', {}) -" Stores information for each job including: -" -" linter: The linter dictionary for the job. -" buffer: The buffer number for the job. -" output: The array of lines for the output of the job. -if !has_key(s:, 'job_info_map') - let s:job_info_map = {} -endif - if !has_key(s:, 'executable_cache_map') let s:executable_cache_map = {} endif - function! ale#engine#CleanupEveryBuffer() abort for l:key in keys(g:ale_buffer_info) " The key could be a filename or a buffer number, so try and @@ -34,6 +24,25 @@ function! ale#engine#CleanupEveryBuffer() abort endfor endfunction +function! ale#engine#MarkLinterActive(info, linter) abort + let l:found = 0 + + for l:other_linter in a:info.active_linter_list + if l:other_linter.name is# a:linter.name + let l:found = 1 + break + endif + endfor + + if !l:found + call add(a:info.active_linter_list, a:linter) + endif +endfunction + +function! ale#engine#MarkLinterInactive(info, linter) abort + call filter(a:info.active_linter_list, 'v:val.name isnot# a:linter.name') +endfunction + function! ale#engine#ResetExecutableCache() abort let s:executable_cache_map = {} endfunction @@ -71,18 +80,12 @@ endfunction function! ale#engine#InitBufferInfo(buffer) abort if !has_key(g:ale_buffer_info, a:buffer) - " job_list will hold the list of job IDs " active_linter_list will hold the list of active linter names " loclist holds the loclist items after all jobs have completed. - " temporary_file_list holds temporary files to be cleaned up - " temporary_directory_list holds temporary directories to be cleaned up let g:ale_buffer_info[a:buffer] = { - \ 'job_list': [], \ 'active_linter_list': [], \ 'active_other_sources_list': [], \ 'loclist': [], - \ 'temporary_file_list': [], - \ 'temporary_directory_list': [], \} return 1 @@ -104,79 +107,25 @@ endfunction " Register a temporary file to be managed with the ALE engine for " a current job run. function! ale#engine#ManageFile(buffer, filename) abort - call ale#engine#InitBufferInfo(a:buffer) - call add(g:ale_buffer_info[a:buffer].temporary_file_list, a:filename) + " TODO: Emit deprecation warning here later. + call ale#command#ManageFile(a:buffer, a:filename) endfunction " Same as the above, but manage an entire directory. function! ale#engine#ManageDirectory(buffer, directory) abort - call ale#engine#InitBufferInfo(a:buffer) - call add(g:ale_buffer_info[a:buffer].temporary_directory_list, a:directory) + " TODO: Emit deprecation warning here later. + call ale#command#ManageDirectory(a:buffer, a:directory) endfunction function! ale#engine#CreateFile(buffer) abort - " This variable can be set to 1 in tests to stub this out. - if get(g:, 'ale_create_dummy_temporary_file') - return 'TEMP' - endif - - let l:temporary_file = ale#util#Tempname() - call ale#engine#ManageFile(a:buffer, l:temporary_file) - - return l:temporary_file + " TODO: Emit deprecation warning here later. + return ale#command#CreateFile(a:buffer) endfunction " Create a new temporary directory and manage it in one go. function! ale#engine#CreateDirectory(buffer) abort - " This variable can be set to 1 in tests to stub this out. - if get(g:, 'ale_create_dummy_temporary_file') - return 'TEMP_DIR' - endif - - let l:temporary_directory = ale#util#Tempname() - " Create the temporary directory for the file, unreadable by 'other' - " users. - call mkdir(l:temporary_directory, '', 0750) - call ale#engine#ManageDirectory(a:buffer, l:temporary_directory) - - return l:temporary_directory -endfunction - -function! ale#engine#RemoveManagedFiles(buffer) abort - let l:info = get(g:ale_buffer_info, a:buffer, {}) - - " We can't delete anything in a sandbox, so wait until we escape from - " it to delete temporary files and directories. - if ale#util#InSandbox() - return - endif - - " Delete files with a call akin to a plan `rm` command. - if has_key(l:info, 'temporary_file_list') - for l:filename in l:info.temporary_file_list - call delete(l:filename) - endfor - - let l:info.temporary_file_list = [] - endif - - " Delete directories like `rm -rf`. - " Directories are handled differently from files, so paths that are - " intended to be single files can be set up for automatic deletion without - " accidentally deleting entire directories. - if has_key(l:info, 'temporary_directory_list') - for l:directory in l:info.temporary_directory_list - call delete(l:directory, 'rf') - endfor - - let l:info.temporary_directory_list = [] - endif -endfunction - -function! s:GatherOutput(job_id, line) abort - if has_key(s:job_info_map, a:job_id) - call add(s:job_info_map[a:job_id].output, a:line) - endif + " TODO: Emit deprecation warning here later. + return ale#command#CreateDirectory(a:buffer) endfunction function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort @@ -189,7 +138,7 @@ function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_sour if !a:from_other_source " Remove this linter from the list of active linters. " This may have already been done when the job exits. - call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name') + call filter(l:info.active_linter_list, 'v:val.name isnot# a:linter_name') endif " Make some adjustments to the loclists to fix common problems, and also @@ -222,27 +171,19 @@ function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_sour call ale#engine#SetResults(a:buffer, l:info.loclist) endfunction -function! s:HandleExit(job_id, exit_code) abort - if !has_key(s:job_info_map, a:job_id) +function! s:HandleExit(job_info, buffer, output, data) abort + let l:buffer_info = get(g:ale_buffer_info, a:buffer) + + if empty(l:buffer_info) return endif - let l:job_info = s:job_info_map[a:job_id] - let l:linter = l:job_info.linter - let l:output = l:job_info.output - let l:buffer = l:job_info.buffer - let l:executable = l:job_info.executable - let l:next_chain_index = l:job_info.next_chain_index - - if g:ale_history_enabled - call ale#history#SetExitCode(l:buffer, a:job_id, a:exit_code) - endif + let l:linter = a:job_info.linter + let l:executable = a:job_info.executable + let l:next_chain_index = a:job_info.next_chain_index " Remove this job from the list. - call ale#job#Stop(a:job_id) - call remove(s:job_info_map, a:job_id) - call filter(g:ale_buffer_info[l:buffer].job_list, 'v:val isnot# a:job_id') - call filter(g:ale_buffer_info[l:buffer].active_linter_list, 'v:val isnot# l:linter.name') + call ale#engine#MarkLinterInactive(l:buffer_info, l:linter) " Stop here if we land in the handle for a job completing if we're in " a sandbox. @@ -250,29 +191,32 @@ function! s:HandleExit(job_id, exit_code) abort return endif - if has('nvim') && !empty(l:output) && empty(l:output[-1]) - call remove(l:output, -1) + if has('nvim') && !empty(a:output) && empty(a:output[-1]) + call remove(a:output, -1) endif if l:next_chain_index < len(get(l:linter, 'command_chain', [])) - call s:InvokeChain(l:buffer, l:executable, l:linter, l:next_chain_index, l:output) + let [l:command, l:options] = ale#engine#ProcessChain( + \ a:buffer, + \ l:executable, + \ l:linter, + \ l:next_chain_index, + \ a:output, + \) + + call s:RunJob(l:command, l:options) return endif - " Log the output of the command for ALEInfo if we should. - if g:ale_history_enabled && g:ale_history_log_output - call ale#history#RememberOutput(l:buffer, a:job_id, l:output[:]) - endif - try - let l:loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output) + let l:loclist = ale#util#GetFunction(l:linter.callback)(a:buffer, a:output) " Handle the function being unknown, or being deleted. catch /E700/ let l:loclist = [] endtry - call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist, 0) + call ale#engine#HandleLoclist(l:linter.name, a:buffer, l:loclist, 0) endfunction function! ale#engine#SetResults(buffer, loclist) abort @@ -321,7 +265,7 @@ function! ale#engine#SetResults(buffer, loclist) abort " Automatically remove all managed temporary files and directories " now that all jobs have completed. - call ale#engine#RemoveManagedFiles(a:buffer) + call ale#command#RemoveManagedFiles(a:buffer) " Call user autocommands. This allows users to hook into ALE's lint cycle. silent doautocmd User ALELintPost @@ -472,33 +416,23 @@ endfunction " Given part of a command, replace any % with %%, so that no characters in " the string will be replaced with filenames, etc. function! ale#engine#EscapeCommandPart(command_part) abort - return substitute(a:command_part, '%', '%%', 'g') -endfunction - -function! s:CreateTemporaryFileForJob(buffer, temporary_file) abort - if empty(a:temporary_file) - " There is no file, so we didn't create anything. - return 0 - endif - - let l:temporary_directory = fnamemodify(a:temporary_file, ':h') - " Create the temporary directory for the file, unreadable by 'other' - " users. - call mkdir(l:temporary_directory, '', 0750) - " Automatically delete the directory later. - call ale#engine#ManageDirectory(a:buffer, l:temporary_directory) - " Write the buffer out to a file. - let l:lines = getbufline(a:buffer, 1, '$') - call ale#util#Writefile(a:buffer, l:lines, a:temporary_file) - - return 1 + " TODO: Emit deprecation warning here later. + return ale#command#EscapeCommandPart(a:command_part) endfunction " Run a job. " -" Returns 1 when the job was started successfully. -function! s:RunJob(options) abort - let l:command = a:options.command +" Returns 1 when a job was started successfully. +function! s:RunJob(command, options) abort + if ale#command#IsDeferred(a:command) + let a:command.result_callback = { + \ command -> s:RunJob(command, a:options) + \} + + return 1 + endif + + let l:command = a:command if empty(l:command) return 0 @@ -512,201 +446,106 @@ function! s:RunJob(options) abort let l:read_buffer = a:options.read_buffer let l:info = g:ale_buffer_info[l:buffer] - let [l:temporary_file, l:command] = ale#command#FormatCommand( - \ l:buffer, - \ l:executable, - \ l:command, - \ l:read_buffer, - \) - - if s:CreateTemporaryFileForJob(l:buffer, l:temporary_file) - " If a temporary filename has been formatted in to the command, then - " we do not need to send the Vim buffer to the command. - let l:read_buffer = 0 - endif - - " Add a newline to commands which need it. - " This is only used for Flow for now, and is not documented. - if l:linter.add_newline - if has('win32') - let l:command = l:command . '; echo.' - else - let l:command = l:command . '; echo' - endif - endif - - let l:command = ale#job#PrepareCommand(l:buffer, l:command) - let l:job_options = { - \ 'mode': 'nl', - \ 'exit_cb': function('s:HandleExit'), - \} - - if l:output_stream is# 'stderr' - let l:job_options.err_cb = function('s:GatherOutput') - elseif l:output_stream is# 'both' - let l:job_options.out_cb = function('s:GatherOutput') - let l:job_options.err_cb = function('s:GatherOutput') - else - let l:job_options.out_cb = function('s:GatherOutput') - endif - - if get(g:, 'ale_run_synchronously') == 1 - " Find a unique Job value to use, which will be the same as the ID for - " running commands synchronously. This is only for test code. - let l:job_id = len(s:job_info_map) + 1 - - while has_key(s:job_info_map, l:job_id) - let l:job_id += 1 - endwhile - else - let l:job_id = ale#job#Start(l:command, l:job_options) - endif - - let l:status = 'failed' + let l:Callback = function('s:HandleExit', [{ + \ 'linter': l:linter, + \ 'executable': l:executable, + \ 'next_chain_index': l:next_chain_index, + \}]) + let l:result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'output_stream': l:output_stream, + \ 'executable': l:executable, + \ 'read_buffer': l:read_buffer, + \ 'log_output': l:next_chain_index >= len(get(l:linter, 'command_chain', [])), + \}) " Only proceed if the job is being run. - if l:job_id - " Add the job to the list of jobs, so we can track them. - call add(l:info.job_list, l:job_id) - - if index(l:info.active_linter_list, l:linter.name) < 0 - call add(l:info.active_linter_list, l:linter.name) - endif - - let l:status = 'started' - " Store the ID for the job in the map to read back again. - let s:job_info_map[l:job_id] = { - \ 'linter': l:linter, - \ 'buffer': l:buffer, - \ 'executable': l:executable, - \ 'output': [], - \ 'next_chain_index': l:next_chain_index, - \} - - silent doautocmd User ALEJobStarted + if empty(l:result) + return 0 endif - if g:ale_history_enabled - call ale#history#Add(l:buffer, l:status, l:job_id, l:command) - endif + call ale#engine#MarkLinterActive(l:info, l:linter) - if get(g:, 'ale_run_synchronously') == 1 - " Run a command synchronously if this test option is set. - let s:job_info_map[l:job_id].output = systemlist( - \ type(l:command) is v:t_list - \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) - \ : l:command - \) + silent doautocmd User ALEJobStarted - call l:job_options.exit_cb(l:job_id, v:shell_error) - endif - - return l:job_id != 0 + return 1 endfunction " Determine which commands to run for a link in a command chain, or " just a regular command. -function! ale#engine#ProcessChain(buffer, linter, chain_index, input) abort +function! ale#engine#ProcessChain(buffer, executable, linter, chain_index, input) abort let l:output_stream = get(a:linter, 'output_stream', 'stdout') let l:read_buffer = a:linter.read_buffer let l:chain_index = a:chain_index let l:input = a:input - if has_key(a:linter, 'command_chain') - while l:chain_index < len(a:linter.command_chain) - " Run a chain of commands, one asynchronous command after the other, - " so that many programs can be run in a sequence. - let l:chain_item = a:linter.command_chain[l:chain_index] + while l:chain_index < len(a:linter.command_chain) + " Run a chain of commands, one asynchronous command after the other, + " so that many programs can be run in a sequence. + let l:chain_item = a:linter.command_chain[l:chain_index] - if l:chain_index == 0 - " The first callback in the chain takes only a buffer number. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer - \) - else - " The second callback in the chain takes some input too. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer, - \ l:input - \) + if l:chain_index == 0 + " The first callback in the chain takes only a buffer number. + let l:command = ale#util#GetFunction(l:chain_item.callback)( + \ a:buffer + \) + else + " The second callback in the chain takes some input too. + let l:command = ale#util#GetFunction(l:chain_item.callback)( + \ a:buffer, + \ l:input + \) + endif + + " If we have a command to run, execute that. + if !empty(l:command) + " The chain item can override the output_stream option. + if has_key(l:chain_item, 'output_stream') + let l:output_stream = l:chain_item.output_stream endif - " If we have a command to run, execute that. - if !empty(l:command) - " The chain item can override the output_stream option. - if has_key(l:chain_item, 'output_stream') - let l:output_stream = l:chain_item.output_stream - endif - - " The chain item can override the read_buffer option. - if has_key(l:chain_item, 'read_buffer') - let l:read_buffer = l:chain_item.read_buffer - elseif l:chain_index != len(a:linter.command_chain) - 1 - " Don't read the buffer for commands besides the last one - " in the chain by default. - let l:read_buffer = 0 - endif - - break + " The chain item can override the read_buffer option. + if has_key(l:chain_item, 'read_buffer') + let l:read_buffer = l:chain_item.read_buffer + elseif l:chain_index != len(a:linter.command_chain) - 1 + " Don't read the buffer for commands besides the last one + " in the chain by default. + let l:read_buffer = 0 endif - " Command chain items can return an empty string to indicate that - " a command should be skipped, so we should try the next item - " with no input. - let l:input = [] - let l:chain_index += 1 - endwhile - else - let l:command = ale#linter#GetCommand(a:buffer, a:linter) - endif + break + endif - return { - \ 'command': l:command, + " Command chain items can return an empty string to indicate that + " a command should be skipped, so we should try the next item + " with no input. + let l:input = [] + let l:chain_index += 1 + endwhile + + return [l:command, { + \ 'executable': a:executable, \ 'buffer': a:buffer, \ 'linter': a:linter, \ 'output_stream': l:output_stream, \ 'next_chain_index': l:chain_index + 1, \ 'read_buffer': l:read_buffer, - \} + \}] endfunction -function! s:InvokeChain(buffer, executable, linter, chain_index, input) abort - let l:options = ale#engine#ProcessChain(a:buffer, a:linter, a:chain_index, a:input) - let l:options.executable = a:executable - - return s:RunJob(l:options) -endfunction - -function! s:StopCurrentJobs(buffer, include_lint_file_jobs) abort +function! s:StopCurrentJobs(buffer, clear_lint_file_jobs) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) - let l:new_job_list = [] - let l:new_active_linter_list = [] + call ale#command#StopJobs(a:buffer, 'linter') - for l:job_id in get(l:info, 'job_list', []) - let l:job_info = get(s:job_info_map, l:job_id, {}) - - if !empty(l:job_info) - if a:include_lint_file_jobs || !l:job_info.linter.lint_file - call ale#job#Stop(l:job_id) - call remove(s:job_info_map, l:job_id) - else - call add(l:new_job_list, l:job_id) - " Linters with jobs still running are still active. - call add(l:new_active_linter_list, l:job_info.linter.name) - endif - endif - endfor - - " Remove duplicates from the active linter list. - call uniq(sort(l:new_active_linter_list)) - - " Update the List, so it includes only the jobs we still need. - let l:info.job_list = l:new_job_list " Update the active linter list, clearing out anything not running. - let l:info.active_linter_list = l:new_active_linter_list + if a:clear_lint_file_jobs + call ale#command#StopJobs(a:buffer, 'file_linter') + let l:info.active_linter_list = [] + else + " Keep jobs for linting files when we're only linting buffers. + call filter(l:info.active_linter_list, 'get(v:val, ''lint_file'')') + endif endfunction - function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort " Figure out which linters are still enabled, and remove " problems for linters which are no longer enabled. @@ -757,6 +596,48 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort endif endfunction +function! s:RunIfExecutable(buffer, linter, executable) abort + if ale#command#IsDeferred(a:executable) + let a:executable.result_callback = { + \ executable -> s:RunIfExecutable(a:buffer, a:linter, executable) + \} + + return 1 + endif + + if ale#engine#IsExecutable(a:buffer, a:executable) + " Use different job types for file or linter jobs. + let l:job_type = a:linter.lint_file ? 'file_linter' : 'linter' + call setbufvar(a:buffer, 'ale_job_type', l:job_type) + + if has_key(a:linter, 'command_chain') + let [l:command, l:options] = ale#engine#ProcessChain( + \ a:buffer, + \ a:executable, + \ a:linter, + \ 0, + \ [] + \) + + return s:RunJob(l:command, l:options) + endif + + let l:command = ale#linter#GetCommand(a:buffer, a:linter) + let l:options = { + \ 'executable': a:executable, + \ 'buffer': a:buffer, + \ 'linter': a:linter, + \ 'output_stream': get(a:linter, 'output_stream', 'stdout'), + \ 'next_chain_index': 1, + \ 'read_buffer': a:linter.read_buffer, + \} + + return s:RunJob(l:command, l:options) + endif + + return 0 +endfunction + " Run a linter for a buffer. " " Returns 1 if the linter was successfully run. @@ -766,9 +647,7 @@ function! s:RunLinter(buffer, linter) abort else let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) - if ale#engine#IsExecutable(a:buffer, l:executable) - return s:InvokeChain(a:buffer, l:executable, a:linter, 0, []) - endif + return s:RunIfExecutable(a:buffer, a:linter, l:executable) endif return 0 @@ -836,90 +715,3 @@ function! ale#engine#GetLoclist(buffer) abort return g:ale_buffer_info[a:buffer].loclist endfunction - -" This function can be called with a timeout to wait for all jobs to finish. -" If the jobs to not finish in the given number of milliseconds, -" an exception will be thrown. -" -" The time taken will be a very rough approximation, and more time may be -" permitted than is specified. -function! ale#engine#WaitForJobs(deadline) abort - let l:start_time = ale#events#ClockMilliseconds() - - if l:start_time == 0 - throw 'Failed to read milliseconds from the clock!' - endif - - let l:job_list = [] - - " Gather all of the jobs from every buffer. - for l:info in values(g:ale_buffer_info) - call extend(l:job_list, get(l:info, 'job_list', [])) - endfor - - " NeoVim has a built-in API for this, so use that. - if has('nvim') - let l:nvim_code_list = jobwait(l:job_list, a:deadline) - - if index(l:nvim_code_list, -1) >= 0 - throw 'Jobs did not complete on time!' - endif - - return - endif - - let l:should_wait_more = 1 - - while l:should_wait_more - let l:should_wait_more = 0 - - for l:job_id in l:job_list - if ale#job#IsRunning(l:job_id) - let l:now = ale#events#ClockMilliseconds() - - if l:now - l:start_time > a:deadline - " Stop waiting after a timeout, so we don't wait forever. - throw 'Jobs did not complete on time!' - endif - - " Wait another 10 milliseconds - let l:should_wait_more = 1 - sleep 10ms - break - endif - endfor - endwhile - - " Sleep for a small amount of time after all jobs finish. - " This seems to be enough to let handlers after jobs end run, and - " prevents the occasional failure where this function exits after jobs - " end, but before handlers are run. - sleep 10ms - - " We must check the buffer data again to see if new jobs started - " for command_chain linters. - let l:has_new_jobs = 0 - - " Check again to see if any jobs are running. - for l:info in values(g:ale_buffer_info) - for l:job_id in get(l:info, 'job_list', []) - if ale#job#IsRunning(l:job_id) - let l:has_new_jobs = 1 - break - endif - endfor - endfor - - if l:has_new_jobs - " We have to wait more. Offset the timeout by the time taken so far. - let l:now = ale#events#ClockMilliseconds() - let l:new_deadline = a:deadline - (l:now - l:start_time) - - if l:new_deadline <= 0 - " Enough time passed already, so stop immediately. - throw 'Jobs did not complete on time!' - endif - - call ale#engine#WaitForJobs(l:new_deadline) - endif -endfunction diff --git a/sources_non_forked/ale/autoload/ale/filetypes.vim b/sources_non_forked/ale/autoload/ale/filetypes.vim index 6174aa0e..6cdc9ece 100644 --- a/sources_non_forked/ale/autoload/ale/filetypes.vim +++ b/sources_non_forked/ale/autoload/ale/filetypes.vim @@ -5,7 +5,7 @@ function! ale#filetypes#LoadExtensionMap() abort " Output includes: " '*.erl setf erlang' redir => l:output - silent exec 'autocmd' + silent exec 'autocmd' redir end let l:map = {} diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index 423e85be..b8674606 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -1,13 +1,3 @@ -if !has_key(s:, 'job_info_map') - let s:job_info_map = {} -endif - -function! s:GatherOutput(job_id, line) abort - if has_key(s:job_info_map, a:job_id) - call add(s:job_info_map[a:job_id].output, a:line) - endif -endfunction - " Apply fixes queued up for buffers which may be hidden. " Vim doesn't let you modify hidden buffers. function! ale#fix#ApplyQueuedFixes() abort @@ -66,11 +56,17 @@ function! ale#fix#ApplyQueuedFixes() abort endfunction function! ale#fix#ApplyFixes(buffer, output) abort - call ale#fix#RemoveManagedFiles(a:buffer) - let l:data = g:ale_fix_buffer_data[a:buffer] let l:data.output = a:output let l:data.changes_made = l:data.lines_before != l:data.output + let l:data.done = 1 + + call ale#command#RemoveManagedFiles(a:buffer) + + if !bufexists(a:buffer) + " Remove the buffer data when it doesn't exist. + call remove(g:ale_fix_buffer_data, a:buffer) + endif if l:data.changes_made && bufexists(a:buffer) let l:lines = getbufline(a:buffer, 1, '$') @@ -83,279 +79,174 @@ function! ale#fix#ApplyFixes(buffer, output) abort endif endif - if !bufexists(a:buffer) - " Remove the buffer data when it doesn't exist. - call remove(g:ale_fix_buffer_data, a:buffer) - endif - - let l:data.done = 1 - " We can only change the lines of a buffer which is currently open, " so try and apply the fixes to the current buffer. call ale#fix#ApplyQueuedFixes() endfunction -function! s:HandleExit(job_id, exit_code) abort - if !has_key(s:job_info_map, a:job_id) +function! s:HandleExit(job_info, buffer, job_output, data) abort + let l:buffer_info = get(g:ale_fix_buffer_data, a:buffer, {}) + + if empty(l:buffer_info) return endif - let l:job_info = remove(s:job_info_map, a:job_id) - let l:buffer = l:job_info.buffer - - if g:ale_history_enabled - call ale#history#SetExitCode(l:buffer, a:job_id, a:exit_code) + if a:job_info.read_temporary_file + let l:output = !empty(a:data.temporary_file) + \ ? readfile(a:data.temporary_file) + \ : [] + else + let l:output = a:job_output endif - if has_key(l:job_info, 'file_to_read') - let l:job_info.output = readfile(l:job_info.file_to_read) - endif - - let l:ChainCallback = get(l:job_info, 'chain_with', v:null) - let l:ProcessWith = get(l:job_info, 'process_with', v:null) + let l:ChainCallback = get(a:job_info, 'chain_with', v:null) + let l:ProcessWith = get(a:job_info, 'process_with', v:null) " Post-process the output with a function if we have one. if l:ProcessWith isnot v:null - let l:job_info.output = call( - \ ale#util#GetFunction(l:ProcessWith), - \ [l:buffer, l:job_info.output] - \) + let l:output = call(l:ProcessWith, [a:buffer, l:output]) endif " Use the output of the job for changing the file if it isn't empty, " otherwise skip this job and use the input from before. " " We'll use the input from before for chained commands. - if l:ChainCallback is v:null && !empty(split(join(l:job_info.output))) - let l:input = l:job_info.output + if l:ChainCallback is v:null && !empty(split(join(l:output))) + let l:input = l:output else - let l:input = l:job_info.input + let l:input = a:job_info.input endif let l:next_index = l:ChainCallback is v:null - \ ? l:job_info.callback_index + 1 - \ : l:job_info.callback_index + \ ? a:job_info.callback_index + 1 + \ : a:job_info.callback_index call s:RunFixer({ - \ 'buffer': l:buffer, + \ 'buffer': a:buffer, \ 'input': l:input, - \ 'output': l:job_info.output, - \ 'callback_list': l:job_info.callback_list, + \ 'output': l:output, + \ 'callback_list': a:job_info.callback_list, \ 'callback_index': l:next_index, \ 'chain_callback': l:ChainCallback, \}) endfunction -function! ale#fix#ManageDirectory(buffer, directory) abort - call add(g:ale_fix_buffer_data[a:buffer].temporary_directory_list, a:directory) -endfunction +function! s:RunJob(result, options) abort + if ale#command#IsDeferred(a:result) + let a:result.result_callback = {x -> s:RunJob(x, a:options)} -function! ale#fix#RemoveManagedFiles(buffer) abort - if !has_key(g:ale_fix_buffer_data, a:buffer) return endif - " We can't delete anything in a sandbox, so wait until we escape from - " it to delete temporary files and directories. - if ale#util#InSandbox() - return - endif - - " Delete directories like `rm -rf`. - " Directories are handled differently from files, so paths that are - " intended to be single files can be set up for automatic deletion without - " accidentally deleting entire directories. - for l:directory in g:ale_fix_buffer_data[a:buffer].temporary_directory_list - call delete(l:directory, 'rf') - endfor - - let g:ale_fix_buffer_data[a:buffer].temporary_directory_list = [] -endfunction - -function! s:CreateTemporaryFileForJob(buffer, temporary_file, input) abort - if empty(a:temporary_file) - " There is no file, so we didn't create anything. - return 0 - endif - - let l:temporary_directory = fnamemodify(a:temporary_file, ':h') - " Create the temporary directory for the file, unreadable by 'other' - " users. - call mkdir(l:temporary_directory, '', 0750) - " Automatically delete the directory later. - call ale#fix#ManageDirectory(a:buffer, l:temporary_directory) - " Write the buffer out to a file. - call ale#util#Writefile(a:buffer, a:input, a:temporary_file) - - return 1 -endfunction - -function! s:RunJob(options) abort let l:buffer = a:options.buffer - let l:command = a:options.command let l:input = a:options.input - let l:output_stream = a:options.output_stream - let l:read_temporary_file = a:options.read_temporary_file - let l:ChainWith = a:options.chain_with - let l:read_buffer = a:options.read_buffer - if empty(l:command) - " If there's nothing further to chain the command with, stop here. - if l:ChainWith is v:null - return 0 + if a:result is 0 || type(a:result) is v:t_list + if type(a:result) is v:t_list + let l:input = a:result endif - " If there's another chained callback to run, then run that. call s:RunFixer({ \ 'buffer': l:buffer, \ 'input': l:input, - \ 'callback_index': a:options.callback_index, + \ 'callback_index': a:options.callback_index + 1, + \ 'callback_list': a:options.callback_list, + \}) + + return + endif + + let l:command = get(a:result, 'command', '') + let l:ChainWith = get(a:result, 'chain_with', v:null) + + if empty(l:command) + " If the command is empty, skip to the next item, or call the + " chain_with function. + call s:RunFixer({ + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_index': a:options.callback_index + (l:ChainWith is v:null), \ 'callback_list': a:options.callback_list, \ 'chain_callback': l:ChainWith, \ 'output': [], \}) - return 1 + return endif - let [l:temporary_file, l:command] = ale#command#FormatCommand( - \ l:buffer, - \ '', - \ l:command, - \ l:read_buffer, - \) - call s:CreateTemporaryFileForJob(l:buffer, l:temporary_file, l:input) + let l:read_temporary_file = get(a:result, 'read_temporary_file', 0) + " Default to piping the buffer for the last fixer in the chain. + let l:read_buffer = get(a:result, 'read_buffer', l:ChainWith is v:null) + let l:output_stream = get(a:result, 'output_stream', 'stdout') - let l:command = ale#job#PrepareCommand(l:buffer, l:command) - let l:job_options = { - \ 'mode': 'nl', - \ 'exit_cb': function('s:HandleExit'), - \} + if l:read_temporary_file + let l:output_stream = 'none' + endif - let l:job_info = { - \ 'buffer': l:buffer, + let l:Callback = function('s:HandleExit', [{ \ 'input': l:input, - \ 'output': [], \ 'chain_with': l:ChainWith, \ 'callback_index': a:options.callback_index, \ 'callback_list': a:options.callback_list, - \ 'process_with': a:options.process_with, - \} + \ 'process_with': get(a:result, 'process_with', v:null), + \ 'read_temporary_file': l:read_temporary_file, + \}]) + let l:run_result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'output_stream': l:output_stream, + \ 'executable': '', + \ 'read_buffer': l:read_buffer, + \ 'input': l:input, + \ 'log_output': 0, + \}) - if l:read_temporary_file - " TODO: Check that a temporary file is set here. - let l:job_info.file_to_read = l:temporary_file - elseif l:output_stream is# 'stderr' - let l:job_options.err_cb = function('s:GatherOutput') - elseif l:output_stream is# 'both' - let l:job_options.out_cb = function('s:GatherOutput') - let l:job_options.err_cb = function('s:GatherOutput') - else - let l:job_options.out_cb = function('s:GatherOutput') + if empty(l:run_result) + call s:RunFixer({ + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_index': a:options.callback_index + 1, + \ 'callback_list': a:options.callback_list, + \}) endif - - if get(g:, 'ale_emulate_job_failure') == 1 - let l:job_id = 0 - elseif get(g:, 'ale_run_synchronously') == 1 - " Find a unique Job value to use, which will be the same as the ID for - " running commands synchronously. This is only for test code. - let l:job_id = len(s:job_info_map) + 1 - - while has_key(s:job_info_map, l:job_id) - let l:job_id += 1 - endwhile - else - let l:job_id = ale#job#Start(l:command, l:job_options) - endif - - let l:status = l:job_id ? 'started' : 'failed' - - if g:ale_history_enabled - call ale#history#Add(l:buffer, l:status, l:job_id, l:command) - endif - - if l:job_id == 0 - return 0 - endif - - let s:job_info_map[l:job_id] = l:job_info - - if get(g:, 'ale_run_synchronously') == 1 - " Run a command synchronously if this test option is set. - let l:output = systemlist( - \ type(l:command) is v:t_list - \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) - \ : l:command - \) - - if !l:read_temporary_file - let s:job_info_map[l:job_id].output = l:output - endif - - call l:job_options.exit_cb(l:job_id, v:shell_error) - endif - - return 1 endfunction function! s:RunFixer(options) abort let l:buffer = a:options.buffer let l:input = a:options.input let l:index = a:options.callback_index + + if len(a:options.callback_list) <= l:index + call ale#fix#ApplyFixes(l:buffer, l:input) + + return + endif + let l:ChainCallback = get(a:options, 'chain_callback', v:null) - while len(a:options.callback_list) > l:index - let l:Function = l:ChainCallback isnot v:null - \ ? ale#util#GetFunction(l:ChainCallback) - \ : a:options.callback_list[l:index] + let l:Function = l:ChainCallback isnot v:null + \ ? ale#util#GetFunction(l:ChainCallback) + \ : a:options.callback_list[l:index] - if l:ChainCallback isnot v:null - " Chained commands accept (buffer, output, [input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 2 - \ ? call(l:Function, [l:buffer, a:options.output]) - \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) - else - " Chained commands accept (buffer, [done, input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 1 - \ ? call(l:Function, [l:buffer]) - \ : call(l:Function, [l:buffer, v:null, copy(l:input)]) - endif + " Record new jobs started as fixer jobs. + call setbufvar(l:buffer, 'ale_job_type', 'fixer') - if type(l:result) is v:t_number && l:result == 0 - " When `0` is returned, skip this item. - let l:index += 1 - elseif type(l:result) is v:t_list - let l:input = l:result - let l:index += 1 - else - let l:ChainWith = get(l:result, 'chain_with', v:null) - " Default to piping the buffer for the last fixer in the chain. - let l:read_buffer = get(l:result, 'read_buffer', l:ChainWith is v:null) + if l:ChainCallback isnot v:null + " Chained commands accept (buffer, output, [input]) + let l:result = ale#util#FunctionArgCount(l:Function) == 2 + \ ? call(l:Function, [l:buffer, a:options.output]) + \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) + else + " Regular fixer commands accept (buffer, [input]) + let l:result = ale#util#FunctionArgCount(l:Function) == 1 + \ ? call(l:Function, [l:buffer]) + \ : call(l:Function, [l:buffer, copy(l:input)]) + endif - let l:job_ran = s:RunJob({ - \ 'buffer': l:buffer, - \ 'command': l:result.command, - \ 'input': l:input, - \ 'output_stream': get(l:result, 'output_stream', 'stdout'), - \ 'read_temporary_file': get(l:result, 'read_temporary_file', 0), - \ 'read_buffer': l:read_buffer, - \ 'chain_with': l:ChainWith, - \ 'callback_list': a:options.callback_list, - \ 'callback_index': l:index, - \ 'process_with': get(l:result, 'process_with', v:null), - \}) - - if !l:job_ran - " The job failed to run, so skip to the next item. - let l:index += 1 - else - " Stop here, we will handle exit later on. - return - endif - endif - endwhile - - call ale#fix#ApplyFixes(l:buffer, l:input) + call s:RunJob(l:result, { + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_list': a:options.callback_list, + \ 'callback_index': l:index, + \}) endfunction function! s:AddSubCallbacks(full_list, callbacks) abort @@ -464,13 +355,9 @@ function! ale#fix#Fix(buffer, fixing_flag, ...) abort return 0 endif - for l:job_id in keys(s:job_info_map) - call remove(s:job_info_map, l:job_id) - call ale#job#Stop(l:job_id) - endfor - + call ale#command#StopJobs(a:buffer, 'fixer') " Clean up any files we might have left behind from a previous run. - call ale#fix#RemoveManagedFiles(a:buffer) + call ale#command#RemoveManagedFiles(a:buffer) call ale#fix#InitBufferData(a:buffer, a:fixing_flag) silent doautocmd User ALEFixPre diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 6a8fd382..34cb771f 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -122,7 +122,7 @@ let s:default_registry = { \ }, \ 'stylelint': { \ 'function': 'ale#fixers#stylelint#Fix', -\ 'suggested_filetypes': ['css', 'sass', 'scss', 'stylus'], +\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'], \ 'description': 'Fix stylesheet files using stylelint --fix.', \ }, \ 'swiftformat': { @@ -145,6 +145,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['c', 'cpp'], \ 'description': 'Fix C/C++ files with clang-format.', \ }, +\ 'cmakeformat': { +\ 'function': 'ale#fixers#cmakeformat#Fix', +\ 'suggested_filetypes': ['cmake'], +\ 'description': 'Fix CMake files with cmake-format.', +\ }, \ 'gofmt': { \ 'function': 'ale#fixers#gofmt#Fix', \ 'suggested_filetypes': ['go'], @@ -170,6 +175,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['rust'], \ 'description': 'Fix Rust files with Rustfmt.', \ }, +\ 'textlint': { +\ 'function': 'ale#fixers#textlint#Fix', +\ 'suggested_filetypes': ['text','markdown','asciidoc','tex'], +\ 'description': 'Fix text files with textlint --fix', +\ }, \ 'hackfmt': { \ 'function': 'ale#fixers#hackfmt#Fix', \ 'suggested_filetypes': ['hack'], @@ -265,6 +275,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['hcl', 'terraform'], \ 'description': 'Fix tf and hcl files with terraform fmt.', \ }, +\ 'ktlint': { +\ 'function': 'ale#fixers#ktlint#Fix', +\ 'suggested_filetypes': ['kt'], +\ 'description': 'Fix Kotlin files with ktlint.', +\ }, \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim index 27249c55..367b8d52 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/black.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -5,6 +5,7 @@ call ale#Set('python_black_executable', 'black') call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_black_options', '') call ale#Set('python_black_auto_pipenv', 0) +call ale#Set('python_black_change_directory', 1) function! ale#fixers#black#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv')) @@ -16,6 +17,10 @@ function! ale#fixers#black#GetExecutable(buffer) abort endfunction function! ale#fixers#black#Fix(buffer) abort + let l:cd_string = ale#Var(a:buffer, 'python_black_change_directory') + \ ? ale#path#BufferCdString(a:buffer) + \ : '' + let l:executable = ale#fixers#black#GetExecutable(a:buffer) let l:exec_args = l:executable =~? 'pipenv$' @@ -25,7 +30,7 @@ function! ale#fixers#black#Fix(buffer) abort let l:options = ale#Var(a:buffer, 'python_black_options') return { - \ 'command': ale#Escape(l:executable) . l:exec_args + \ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic.vim b/sources_non_forked/ale/autoload/ale/fixers/generic.vim index 1d88553e..cb8865b4 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/generic.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/generic.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: Generic functions for fixing files with. -function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort +function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort let l:end_index = len(a:lines) - 1 while l:end_index > 0 && empty(a:lines[l:end_index]) @@ -12,7 +12,7 @@ function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort endfunction " Remove all whitespaces at the end of lines -function! ale#fixers#generic#TrimWhitespace(buffer, done, lines) abort +function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort let l:index = 0 let l:lines_new = range(len(a:lines)) diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim index 9a929b96..d55a23c3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim @@ -2,7 +2,7 @@ " Description: Generic fixer functions for Python. " Add blank lines before control statements. -function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, done, lines) abort +function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort let l:new_lines = [] let l:last_indent_size = 0 let l:last_line_is_blank = 0 @@ -41,7 +41,7 @@ endfunction " This function breaks up long lines so that autopep8 or other tools can " fix the badly-indented code which is produced as a result. -function! ale#fixers#generic_python#BreakUpLongLines(buffer, done, lines) abort +function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort " Default to a maximum line length of 79 let l:max_line_length = 79 let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg') diff --git a/sources_non_forked/ale/autoload/ale/fixers/help.vim b/sources_non_forked/ale/autoload/ale/fixers/help.vim index 9fb0717b..b20740fe 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/help.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/help.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: Generic fixer functions for Vim help documents. -function! ale#fixers#help#AlignTags(buffer, done, lines) abort +function! ale#fixers#help#AlignTags(buffer, lines) abort let l:new_lines = [] for l:line in a:lines diff --git a/sources_non_forked/ale/autoload/ale/fixers/jq.vim b/sources_non_forked/ale/autoload/ale/fixers/jq.vim index 1b743e49..cd9b9138 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/jq.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/jq.vim @@ -7,16 +7,16 @@ function! ale#fixers#jq#GetExecutable(buffer) abort endfunction function! ale#fixers#jq#Fix(buffer) abort - let l:options = ale#Var(a:buffer, 'json_jq_options') - let l:filters = ale#Var(a:buffer, 'json_jq_filters') + let l:options = ale#Var(a:buffer, 'json_jq_options') + let l:filters = ale#Var(a:buffer, 'json_jq_filters') - if empty(l:filters) - return 0 - endif + if empty(l:filters) + return 0 + endif - return { - \ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer)) - \ . ' ' . l:filters . ' ' - \ . l:options, - \} + return { + \ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer)) + \ . ' ' . l:filters . ' ' + \ . l:options, + \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index 58dea159..0f99ae97 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -47,6 +47,15 @@ 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 + " Mimic Prettier's defaults. In cases without a file extension or + " filetype (scratch buffer), Prettier needs `parser` set to know how + " to process the buffer. + if ale#semver#GTE(l:version, [1, 16, 0]) + let l:parser = 'babel' + else + let l:parser = 'babylon' + endif + let l:prettier_parsers = { \ 'typescript': 'typescript', \ 'css': 'css', @@ -60,7 +69,6 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version_output) abort \ 'yaml': 'yaml', \ 'html': 'html', \} - let l:parser = '' for l:filetype in split(getbufvar(a:buffer, '&filetype'), '\.') if has_key(l:prettier_parsers, l:filetype) diff --git a/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim index d750d1c4..90b25679 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim @@ -5,7 +5,7 @@ function! ale#fixers#qmlfmt#GetExecutable(buffer) abort endfunction function! ale#fixers#qmlfmt#Fix(buffer) abort - return { - \ 'command': ale#Escape(ale#fixers#qmlfmt#GetExecutable(a:buffer)), - \} + return { + \ 'command': ale#Escape(ale#fixers#qmlfmt#GetExecutable(a:buffer)), + \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim index 30309c7e..6bfb2fde 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -5,13 +5,12 @@ call ale#Set('stylelint_executable', 'stylelint') call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'stylelint', [ - \ 'node_modules/stylelint/bin/stylelint.js', - \ 'node_modules/.bin/stylelint', - \]) + return ale#node#FindExecutable(a:buffer, 'stylelint', [ + \ 'node_modules/stylelint/bin/stylelint.js', + \ 'node_modules/.bin/stylelint', + \]) endfunction - function! ale#fixers#stylelint#Fix(buffer) abort let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) diff --git a/sources_non_forked/ale/autoload/ale/go.vim b/sources_non_forked/ale/autoload/ale/go.vim index a166480a..cd7d9503 100644 --- a/sources_non_forked/ale/autoload/ale/go.vim +++ b/sources_non_forked/ale/autoload/ale/go.vim @@ -9,18 +9,18 @@ function! ale#go#FindProjectRoot(buffer) abort let l:filename = ale#path#Simplify(expand('#' . a:buffer . ':p')) for l:name in split($GOPATH, l:sep) - let l:path_dir = ale#path#Simplify(l:name) + let l:path_dir = ale#path#Simplify(l:name) - " Use the directory from GOPATH if the current filename starts with it. - if l:filename[: len(l:path_dir) - 1] is? l:path_dir - return l:path_dir - endif + " Use the directory from GOPATH if the current filename starts with it. + if l:filename[: len(l:path_dir) - 1] is? l:path_dir + return l:path_dir + endif endfor let l:default_go_path = ale#path#Simplify(expand('~/go')) if isdirectory(l:default_go_path) - return l:default_go_path + return l:default_go_path endif return '' diff --git a/sources_non_forked/ale/autoload/ale/handlers/alex.vim b/sources_non_forked/ale/autoload/ale/handlers/alex.vim index 853d3137..9cb546ec 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/alex.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/alex.vim @@ -1,10 +1,23 @@ " Author: Johannes Wienke " Description: Error handling for errors in alex output format +function! ale#handlers#alex#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'alex', [ + \ 'node_modules/.bin/alex', + \ 'node_modules/alex/cli.js', + \]) +endfunction + +function! ale#handlers#alex#CreateCommandCallback(flags) abort + return {b -> ale#node#Executable(b, ale#handlers#alex#GetExecutable(b)) + \ . ' %s ' + \ . a:flags} +endfunction + function! ale#handlers#alex#Handle(buffer, lines) abort " Example output: " 6:256-6:262 warning Be careful with “killed”, it’s profane in some cases killed retext-profanities - let l:pattern = '^ *\(\d\+\):\(\d\+\)-\(\d\+\):\(\d\+\) \+warning \+\(.\{-\}\) \+\(.\{-\}\) \+\(.\{-\}\)$' + let l:pattern = '\v^ *(\d+):(\d+)-(\d+):(\d+) +warning +(.{-}) +(.{-}) +(.{-})$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -20,3 +33,21 @@ function! ale#handlers#alex#Handle(buffer, lines) abort return l:output endfunction + +" Define a linter for a specific filetype. Accept flags to adapt to the filetype. +" no flags treat input as markdown +" --html treat input as HTML +" --text treat input as plaintext +function! ale#handlers#alex#DefineLinter(filetype, flags) abort + call ale#Set('alex_executable', 'alex') + call ale#Set('alex_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'alex', + \ 'executable_callback': 'ale#handlers#alex#GetExecutable', + \ 'command_callback': ale#handlers#alex#CreateCommandCallback(a:flags), + \ 'output_stream': 'stderr', + \ 'callback': 'ale#handlers#alex#Handle', + \ 'lint_file': 1, + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim index eda033e4..bc7c0321 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -121,7 +121,7 @@ function! ale#handlers#eslint#Handle(buffer, lines) abort let l:text = l:match[3] if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore') - if l:text is# 'File ignored because of a matching ignore pattern. Use "--no-ignore" to override.' + if l:text =~# '^File ignored' continue endif endif diff --git a/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim b/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim index a650d6dd..b7d2bec3 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim @@ -1,3 +1,4 @@ +scriptencoding utf-8 " Author: Christian Gibbons " Description: This file defines a handler function that should work for the " flawfinder format with the -CDQS flags. @@ -30,7 +31,7 @@ function! ale#handlers#flawfinder#HandleFlawfinderFormat(buffer, lines) abort \ 'lnum': str2nr(l:match[2]), \ 'col': str2nr(l:match[3]), \ 'type': (l:severity < ale#Var(a:buffer, 'c_flawfinder_error_severity')) - \ ? 'W' : 'E', + \ ? 'W' : 'E', \ 'text': s:RemoveUnicodeQuotes(join(split(l:match[4])[1:]) . ': ' . l:match[5]), \} diff --git a/sources_non_forked/ale/autoload/ale/handlers/haskell.vim b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim index 9e495b36..3613b1bb 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/haskell.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim @@ -66,11 +66,11 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort let l:errors = matchlist(l:match[4], '\v([wW]arning|[eE]rror): ?(.*)') if len(l:errors) > 0 - let l:ghc_type = l:errors[1] - let l:text = l:errors[2] + let l:ghc_type = l:errors[1] + let l:text = l:errors[2] else - let l:ghc_type = '' - let l:text = l:match[4][:0] is# ' ' ? l:match[4][1:] : l:match[4] + let l:ghc_type = '' + let l:text = l:match[4][:0] is# ' ' ? l:match[4][1:] : l:match[4] endif if l:ghc_type is? 'Warning' diff --git a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim index 12fc501c..daaa1d66 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim @@ -7,10 +7,10 @@ function! ale#handlers#markdownlint#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], - \ 'type': 'W', - \ }) + \ 'lnum': l:match[1] + 0, + \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], + \ 'type': 'W', + \}) endfor return l:output diff --git a/sources_non_forked/ale/autoload/ale/handlers/sh.vim b/sources_non_forked/ale/autoload/ale/handlers/sh.vim index e96dd3ce..75eaf71f 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/sh.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/sh.vim @@ -9,7 +9,7 @@ function! ale#handlers#sh#GetShellType(buffer) abort " Remove options like -e, etc. let l:command = substitute(l:bang_line, ' --\?[a-zA-Z0-9]\+', '', 'g') - for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'sh'] + for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] if l:command =~# l:possible_shell . '\s*$' return l:possible_shell endif diff --git a/sources_non_forked/ale/autoload/ale/handlers/sml.vim b/sources_non_forked/ale/autoload/ale/handlers/sml.vim index 92c5f83b..e5e528a5 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/sml.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/sml.vim @@ -64,26 +64,27 @@ function! ale#handlers#sml#Handle(buffer, lines) abort let l:match2 = matchlist(l:line, l:pattern2) if len(l:match2) != 0 - call add(l:out, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match2[1] + 0, - \ 'col' : l:match2[2] - 1, - \ 'text': l:match2[3], - \ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E', - \}) - continue + call add(l:out, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match2[1] + 0, + \ 'col' : l:match2[2] - 1, + \ 'text': l:match2[3], + \ 'type': l:match2[3] =~# '^Warning' ? 'W' : 'E', + \}) + + continue endif let l:match = matchlist(l:line, l:pattern) if len(l:match) != 0 - call add(l:out, { - \ 'bufnr': a:buffer, - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[2] . ': ' . l:match[3], - \ 'type': l:match[2] is# 'error' ? 'E' : 'W', - \}) - continue + call add(l:out, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[2] . ': ' . l:match[3], + \ 'type': l:match[2] is# 'error' ? 'E' : 'W', + \}) + continue endif endfor diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 490cc406..2af35aa4 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -57,7 +57,7 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort " If the call did __not__ come from balloonexpr... if !get(l:options, 'hover_from_balloonexpr', 0) let l:buffer = bufnr('') - let [l:line, l:column] = getcurpos()[1:2] + let [l:line, l:column] = getpos('.')[1:2] let l:end = len(getline(l:line)) if l:buffer isnot l:options.buffer @@ -78,8 +78,8 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort let l:result = l:result.contents if type(l:result) is v:t_string - " The result can be just a string. - let l:result = [l:result] + " The result can be just a string. + let l:result = [l:result] endif if type(l:result) is v:t_dict @@ -106,10 +106,15 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort endif endfunction -function! s:OnReady(linter, lsp_details, line, column, opt, ...) abort - let l:buffer = a:lsp_details.buffer +function! s:OnReady(line, column, opt, linter, lsp_details) abort let l:id = a:lsp_details.connection_id + if !ale#lsp#HasCapability(l:id, 'hover') + return + endif + + let l:buffer = a:lsp_details.buffer + let l:Callback = a:linter.lsp is# 'tsserver' \ ? function('ale#hover#HandleTSServerResponse') \ : function('ale#hover#HandleLSPResponse') @@ -144,20 +149,6 @@ function! s:OnReady(linter, lsp_details, line, column, opt, ...) abort \} 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) - return 0 - endif - - let l:id = l:lsp_details.connection_id - - 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 " Pass optional arguments in the dictionary opt. " Currently, only one key/value is useful: @@ -169,12 +160,13 @@ endfunction " - as status message otherwise function! ale#hover#Show(buffer, line, col, opt) abort let l:show_documentation = get(a:opt, 'show_documentation', 0) + let l:Callback = function('s:OnReady', [a:line, a:col, a:opt]) for l:linter in ale#linter#Get(getbufvar(a:buffer, '&filetype')) " Only tsserver supports documentation requests at the moment. if !empty(l:linter.lsp) \&& (!l:show_documentation || l:linter.lsp is# 'tsserver') - call s:ShowDetails(l:linter, a:buffer, a:line, a:col, a:opt) + call ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback) endif endfor endfunction @@ -182,7 +174,7 @@ endfunction " This function implements the :ALEHover command. function! ale#hover#ShowAtCursor() abort let l:buffer = bufnr('') - let l:pos = getcurpos() + let l:pos = getpos('.') call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {}) endfunction @@ -190,7 +182,7 @@ endfunction " This function implements the :ALEDocumentation command. function! ale#hover#ShowDocumentationAtCursor() abort let l:buffer = bufnr('') - let l:pos = getcurpos() + let l:pos = getpos('.') let l:options = {'show_documentation': 1} call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], l:options) diff --git a/sources_non_forked/ale/autoload/ale/job.vim b/sources_non_forked/ale/autoload/ale/job.vim index f9a917e1..14b3e484 100644 --- a/sources_non_forked/ale/autoload/ale/job.vim +++ b/sources_non_forked/ale/autoload/ale/job.vim @@ -99,7 +99,8 @@ function! s:VimCloseCallback(channel) abort if job_status(l:job) is# 'dead' try if !empty(l:info) && has_key(l:info, 'exit_cb') - call ale#util#GetFunction(l:info.exit_cb)(l:job_id, get(l:info, 'exit_code', 1)) + " We have to remove the callback, so we don't call it twice. + call ale#util#GetFunction(remove(l:info, 'exit_cb'))(l:job_id, get(l:info, 'exit_code', 1)) endif finally " Automatically forget about the job after it's done. @@ -124,7 +125,8 @@ function! s:VimExitCallback(job, exit_code) abort if ch_status(job_getchannel(a:job)) is# 'closed' try if !empty(l:info) && has_key(l:info, 'exit_cb') - call ale#util#GetFunction(l:info.exit_cb)(l:job_id, a:exit_code) + " We have to remove the callback, so we don't call it twice. + call ale#util#GetFunction(remove(l:info, 'exit_cb'))(l:job_id, a:exit_code) endif finally " Automatically forget about the job after it's done. @@ -274,12 +276,34 @@ function! ale#job#Start(command, options) abort return l:job_id endfunction +" Force running commands in a Windows CMD command line. +" This means the same command syntax works everywhere. +function! ale#job#StartWithCmd(command, options) abort + let l:shell = &l:shell + let l:shellcmdflag = &l:shellcmdflag + let &l:shell = 'cmd' + let &l:shellcmdflag = '/c' + + try + let l:job_id = ale#job#Start(a:command, a:options) + finally + let &l:shell = l:shell + let &l:shellcmdflag = l:shellcmdflag + endtry + + return l:job_id +endfunction + " Send raw data to the job. function! ale#job#SendRaw(job_id, string) abort if has('nvim') call jobsend(a:job_id, a:string) else - call ch_sendraw(job_getchannel(s:job_map[a:job_id].job), a:string) + let l:job = s:job_map[a:job_id].job + + if ch_status(l:job) is# 'open' + call ch_sendraw(job_getchannel(l:job), a:string) + endif endif endfunction @@ -303,6 +327,20 @@ function! ale#job#IsRunning(job_id) abort return 0 endfunction +function! ale#job#HasOpenChannel(job_id) abort + if ale#job#IsRunning(a:job_id) + if has('nvim') + " TODO: Implement a check for NeoVim. + return 1 + endif + + " Check if the Job's channel can be written to. + return ch_status(s:job_map[a:job_id].job) is# 'open' + endif + + return 0 +endfunction + " Given a Job ID, stop that job. " Invalid job IDs will be ignored. function! ale#job#Stop(job_id) abort diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 1cbc9ffe..4937a6d7 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -80,7 +80,6 @@ function! ale#linter#PreProcess(filetype, linter) abort endif let l:obj = { - \ 'add_newline': get(a:linter, 'add_newline', 0), \ 'name': get(a:linter, 'name'), \ 'lsp': get(a:linter, 'lsp', ''), \} @@ -121,7 +120,8 @@ function! ale#linter#PreProcess(filetype, linter) abort let l:obj.executable = a:linter.executable if type(l:obj.executable) isnot v:t_string - throw '`executable` must be a string if defined' + \&& type(l:obj.executable) isnot v:t_func + throw '`executable` must be a String or Function if defined' endif else throw 'Either `executable` or `executable_callback` must be defined' @@ -177,7 +177,8 @@ function! ale#linter#PreProcess(filetype, linter) abort let l:obj.command = a:linter.command if type(l:obj.command) isnot v:t_string - throw '`command` must be a string if defined' + \&& type(l:obj.command) isnot v:t_func + throw '`command` must be a String or Function if defined' endif else throw 'Either `command`, `executable_callback`, `command_chain` ' @@ -194,9 +195,16 @@ function! ale#linter#PreProcess(filetype, linter) abort endif if !l:needs_address - if has_key(a:linter, 'address_callback') - throw '`address_callback` cannot be used when lsp != ''socket''' + if has_key(a:linter, 'address') || has_key(a:linter, 'address_callback') + throw '`address` or `address_callback` cannot be used when lsp != ''socket''' endif + elseif has_key(a:linter, 'address') + if type(a:linter.address) isnot v:t_string + \&& type(a:linter.address) isnot v:t_func + throw '`address` must be a String or Function if defined' + endif + + let l:obj.address = a:linter.address elseif has_key(a:linter, 'address_callback') let l:obj.address_callback = a:linter.address_callback @@ -204,7 +212,7 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`address_callback` must be a callback if defined' endif else - throw '`address_callback` must be defined for getting the LSP address' + throw '`address` or `address_callback` must be defined for getting the LSP address' endif if l:needs_lsp_details @@ -221,20 +229,34 @@ function! ale#linter#PreProcess(filetype, linter) abort endif else " Default to using the filetype as the language. - let l:obj.language = get(a:linter, 'language', a:filetype) + let l:Language = get(a:linter, 'language', a:filetype) - if type(l:obj.language) isnot v:t_string - throw '`language` must be a string' + if type(l:Language) is v:t_string + " Make 'language_callback' return the 'language' value. + let l:obj.language = l:Language + let l:obj.language_callback = function('s:LanguageGetter') + elseif type(l:Language) is v:t_func + let l:obj.language_callback = l:Language + else + throw '`language` must be a String or Funcref' endif - - " Make 'language_callback' return the 'language' value. - let l:obj.language_callback = function('s:LanguageGetter') endif - let l:obj.project_root_callback = get(a:linter, 'project_root_callback') + if has_key(a:linter, 'project_root') + let l:obj.project_root = a:linter.project_root - if !s:IsCallback(l:obj.project_root_callback) - throw '`project_root_callback` must be a callback for LSP linters' + if type(l:obj.project_root) isnot v:t_string + \&& type(l:obj.project_root) isnot v:t_func + throw '`project_root` must be a String or Function if defined' + endif + elseif has_key(a:linter, 'project_root_callback') + let l:obj.project_root_callback = a:linter.project_root_callback + + if !s:IsCallback(l:obj.project_root_callback) + throw '`project_root_callback` must be a callback if defined' + endif + else + throw '`project_root` or `project_root_callback` must be defined for LSP linters' endif if has_key(a:linter, 'completion_filter') @@ -258,6 +280,11 @@ function! ale#linter#PreProcess(filetype, linter) abort endif elseif has_key(a:linter, 'initialization_options') let l:obj.initialization_options = a:linter.initialization_options + + if type(l:obj.initialization_options) isnot v:t_dict + \&& type(l:obj.initialization_options) isnot v:t_func + throw '`initialization_options` must be a String or Function if defined' + endif endif if has_key(a:linter, 'lsp_config_callback') @@ -272,7 +299,8 @@ function! ale#linter#PreProcess(filetype, linter) abort endif elseif has_key(a:linter, 'lsp_config') if type(a:linter.lsp_config) isnot v:t_dict - throw '`lsp_config` must be a Dictionary' + \&& type(a:linter.lsp_config) isnot v:t_func + throw '`lsp_config` must be a Dictionary or Function if defined' endif let l:obj.lsp_config = a:linter.lsp_config @@ -312,6 +340,8 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`aliases` must be a List of String values' endif + " TODO: Emit deprecation warnings for deprecated options later. + return l:obj endfunction @@ -477,22 +507,34 @@ endfunction " Given a buffer and linter, get the executable String for the linter. function! ale#linter#GetExecutable(buffer, linter) abort - return has_key(a:linter, 'executable_callback') - \ ? ale#util#GetFunction(a:linter.executable_callback)(a:buffer) + let l:Executable = has_key(a:linter, 'executable_callback') + \ ? function(a:linter.executable_callback) \ : a:linter.executable + + return type(l:Executable) is v:t_func + \ ? l:Executable(a:buffer) + \ : l:Executable endfunction " Given a buffer and linter, get the command String for the linter. " The command_chain key is not supported. function! ale#linter#GetCommand(buffer, linter) abort - return has_key(a:linter, 'command_callback') - \ ? ale#util#GetFunction(a:linter.command_callback)(a:buffer) + let l:Command = has_key(a:linter, 'command_callback') + \ ? function(a:linter.command_callback) \ : a:linter.command + + return type(l:Command) is v:t_func + \ ? l:Command(a:buffer) + \ : l:Command endfunction " Given a buffer and linter, get the address for connecting to the server. function! ale#linter#GetAddress(buffer, linter) abort - return has_key(a:linter, 'address_callback') - \ ? ale#util#GetFunction(a:linter.address_callback)(a:buffer) + let l:Address = has_key(a:linter, 'address_callback') + \ ? function(a:linter.address_callback) \ : a:linter.address + + return type(l:Address) is v:t_func + \ ? l:Address(a:buffer) + \ : l:Address endfunction diff --git a/sources_non_forked/ale/autoload/ale/loclist_jumping.vim b/sources_non_forked/ale/autoload/ale/loclist_jumping.vim index fd5ff922..1d3ef7e5 100644 --- a/sources_non_forked/ale/autoload/ale/loclist_jumping.vim +++ b/sources_non_forked/ale/autoload/ale/loclist_jumping.vim @@ -9,14 +9,26 @@ " If there are no items or we have hit the end with wrapping off, an empty " List will be returned, otherwise a pair of [line_number, column_number] will " be returned. -function! ale#loclist_jumping#FindNearest(direction, wrap) abort +function! ale#loclist_jumping#FindNearest(direction, wrap, ...) abort let l:buffer = bufnr('') - let l:pos = getcurpos() + let l:pos = getpos('.') let l:info = get(g:ale_buffer_info, bufnr('%'), {'loclist': []}) " Copy the list and filter to only the items in this buffer. let l:loclist = filter(copy(l:info.loclist), 'v:val.bufnr == l:buffer') let l:search_item = {'bufnr': l:buffer, 'lnum': l:pos[1], 'col': l:pos[2]} + if a:0 > 0 + let l:filter = a:1 + else + let l:filter = 'any' + endif + + if a:0 > 1 + let l:subtype_filter = a:2 + else + let l:subtype_filter = 'any' + endif + " When searching backwards, so we can find the next smallest match. if a:direction is# 'before' call reverse(l:loclist) @@ -41,29 +53,61 @@ function! ale#loclist_jumping#FindNearest(direction, wrap) abort \ l:search_item \) - if a:direction is# 'before' && l:cmp_value < 0 - return [l:item.lnum, l:item.col] - endif + if (l:filter is# 'any' || l:filter is# l:item.type) + \&& ( + \ l:subtype_filter is# 'any' + \ || l:subtype_filter is# get(l:item, 'sub_type', '') + \) - if a:direction is# 'after' && l:cmp_value > 0 - return [l:item.lnum, l:item.col] + if a:direction is# 'before' && l:cmp_value < 0 + return [l:item.lnum, l:item.col] + endif + + if a:direction is# 'after' && l:cmp_value > 0 + return [l:item.lnum, l:item.col] + endif endif endfor " If we found nothing, and the wrap option is set to 1, then we should " wrap around the list of warnings/errors - if a:wrap && !empty(l:loclist) - let l:item = l:loclist[0] - - return [l:item.lnum, l:item.col] + if a:wrap + for l:item in l:loclist + if (l:filter is# 'any' || l:filter is# l:item.type) + \&& ( + \ l:subtype_filter is# 'any' + \ || l:subtype_filter is# get(l:item, 'sub_type', '') + \) + return [l:item.lnum, l:item.col] + endif + endfor endif return [] endfunction " As before, find the nearest match, but position the cursor at it. -function! ale#loclist_jumping#Jump(direction, wrap) abort - let l:nearest = ale#loclist_jumping#FindNearest(a:direction, a:wrap) +function! ale#loclist_jumping#Jump(direction, ...) abort + if a:0 > 0 + let l:wrap = a:1 + else + let l:wrap = 0 + endif + + if a:0 > 1 + let l:filter = a:2 + else + let l:filter = 'any' + endif + + if a:0 > 2 + let l:subtype_filter = a:3 + else + let l:subtype_filter = 'any' + endif + + let l:nearest = ale#loclist_jumping#FindNearest(a:direction, + \ l:wrap, l:filter, l:subtype_filter) if !empty(l:nearest) normal! m` @@ -71,6 +115,36 @@ function! ale#loclist_jumping#Jump(direction, wrap) abort endif endfunction +function! ale#loclist_jumping#WrapJump(direction, sargs) abort + let [l:args, l:rest] = ale#args#Parse(['error', 'warning', 'info', 'wrap', + \ 'style', 'nostyle'], a:sargs) + + let l:wrap = 0 + let l:type_filter = 'any' + let l:subtype_filter = 'any' + + if get(l:args, 'wrap', 'nil') is# '' + let l:wrap = 1 + endif + + if get(l:args, 'error', 'nil') is# '' + let l:type_filter = 'E' + elseif get(l:args, 'warning', 'nil') is# '' + let l:type_filter = 'W' + elseif get(l:args, 'info', 'nil') is# '' + let l:type_filter = 'I' + endif + + if get(l:args, 'nostyle', 'nil') is# '' + let l:subtype_filter = 'style' + elseif get(l:args, 'style', 'nil') is# '' + let l:subtype_filter = '' + endif + + call ale#loclist_jumping#Jump(a:direction, l:wrap, l:type_filter, + \ l:subtype_filter) +endfunction + function! ale#loclist_jumping#JumpToIndex(index) abort let l:buffer = bufnr('') let l:info = get(g:ale_buffer_info, l:buffer, {'loclist': []}) diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index f55096c2..7186d2a9 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -21,7 +21,6 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort " init_options: Options to send to the server. " config: Configuration settings 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] = { @@ -35,14 +34,14 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort \ 'init_options': a:init_options, \ 'config': {}, \ 'callback_list': [], - \ 'message_queue': [], - \ 'capabilities_queue': [], + \ 'init_queue': [], \ 'capabilities': { \ 'hover': 0, \ 'references': 0, \ 'completion': 0, \ 'completion_trigger_characters': [], \ 'definition': 0, + \ 'typeDefinition': 0, \ 'symbol_search': 0, \ }, \} @@ -58,6 +57,15 @@ function! ale#lsp#RemoveConnectionWithID(id) abort endif endfunction +function! ale#lsp#ResetConnections() abort + let s:connections = {} +endfunction + +" Used only in tests. +function! ale#lsp#GetConnections() abort + return s:connections +endfunction + " This is only needed for tests function! ale#lsp#MarkDocumentAsOpen(id, buffer) abort let l:conn = get(s:connections, a:id, {}) @@ -207,6 +215,10 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.definition = 1 endif + if get(a:capabilities, 'typeDefinitionProvider') is v:true + let a:conn.capabilities.typeDefinition = 1 + endif + if get(a:capabilities, 'workspaceSymbolProvider') is v:true let a:conn.capabilities.symbol_search = 1 endif @@ -245,22 +257,15 @@ function! ale#lsp#HandleInitResponse(conn, response) abort return endif - " 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 - - " Remove the messages now. - let a:conn.message_queue = [] + " The initialized message must be sent before everything else. + call ale#lsp#Send(a:conn.id, ale#lsp#message#Initialized()) " 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 + for l:Callback in a:conn.init_queue + call l:Callback() endfor - let a:conn.capabilities_queue = [] + let a:conn.init_queue = [] endfunction function! ale#lsp#HandleMessage(conn_id, message) abort @@ -314,19 +319,35 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort let l:conn.capabilities.symbol_search = 1 endfunction +function! s:SendInitMessage(conn) abort + let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( + \ ale#lsp#message#Initialize(a:conn.root, a:conn.init_options), + \) + let a:conn.init_request_id = l:init_id + call s:SendMessageData(a:conn, l:init_data) +endfunction + " Start a program for LSP servers. " " 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] + let l:started = 0 - if !has_key(l:conn, 'job_id') || !ale#job#IsRunning(l:conn.job_id) + if !has_key(l:conn, 'job_id') || !ale#job#HasOpenChannel(l:conn.job_id) let l:options = { \ 'mode': 'raw', \ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)}, \} - let l:job_id = ale#job#Start(a:command, l:options) + + if has('win32') + let l:job_id = ale#job#StartWithCmd(a:command, l:options) + else + let l:job_id = ale#job#Start(a:command, l:options) + endif + + let l:started = 1 else let l:job_id = l:conn.job_id endif @@ -335,6 +356,10 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort let l:conn.job_id = l:job_id endif + if l:started && !l:conn.is_tsserver + call s:SendInitMessage(l:conn) + endif + return l:job_id > 0 endfunction @@ -344,11 +369,14 @@ endfunction " not be opened. function! ale#lsp#ConnectToAddress(conn_id, address) abort let l:conn = s:connections[a:conn_id] + let l:started = 0 if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id) let l:channel_id = ale#socket#Open(a:address, { \ 'callback': {_, mess -> ale#lsp#HandleMessage(a:conn_id, mess)}, \}) + + let l:started = 1 else let l:channel_id = l:conn.channel_id endif @@ -357,6 +385,10 @@ function! ale#lsp#ConnectToAddress(conn_id, address) abort let l:conn.channel_id = l:channel_id endif + if l:started + call s:SendInitMessage(l:conn) + endif + return l:channel_id >= 0 endfunction @@ -421,26 +453,12 @@ function! ale#lsp#Send(conn_id, message) abort return 0 endif - " If we haven't initialized the server yet, then send the message for it. - 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:conn.init_request_id = l:init_id - - call s:SendMessageData(l:conn, l:init_data) + if !l:conn.initialized + throw 'LSP server not initialized yet!' endif let [l:id, l:data] = ale#lsp#CreateMessageData(a:message) - - 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:conn.message_queue, l:data) - endif + call s:SendMessageData(l:conn, l:data) return l:id == 0 ? -1 : l:id endfunction @@ -491,26 +509,32 @@ function! ale#lsp#NotifyForChanges(conn_id, buffer) abort return l:notified endfunction -" Given some LSP details that must contain at least `connection_id` and -" `project_root` keys, -function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort +" Wait for an LSP server to be initialized. +function! ale#lsp#OnInit(conn_id, Callback) abort let l:conn = get(s:connections, a:conn_id, {}) if empty(l:conn) return endif + if l:conn.initialized + call a:Callback() + else + call add(l:conn.init_queue, a:Callback) + endif +endfunction + +" Check if an LSP has a given capability. +function! ale#lsp#HasCapability(conn_id, capability) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return 0 + endif + if type(get(l:conn.capabilities, a:capability, v:null)) isnot v:t_number throw 'Invalid capability ' . a:capability endif - 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]) - endif - else - " Call the callback later, once we have the information we need. - call add(l:conn.capabilities_queue, [a:capability, a:callback]) - endif + return l:conn.capabilities[a:capability] endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim index 9fffb83a..646dbd20 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -3,6 +3,10 @@ " " Messages in this movie will be returned in the format " [is_notification, method_name, params?] +" +" All functions which accept line and column arguments expect them to be 1-based +" (the same format as being returned by getpos() and friends), those then +" will be converted to 0-based as specified by LSP. let g:ale_lsp_next_version_id = 1 " The LSP protocols demands that we send every change to a document, including @@ -37,7 +41,7 @@ function! ale#lsp#message#Initialize(root_path, initialization_options) abort endfunction function! ale#lsp#message#Initialized() abort - return [1, 'initialized'] + return [1, 'initialized', {}] endfunction function! ale#lsp#message#Shutdown() abort @@ -98,7 +102,7 @@ function! ale#lsp#message#Completion(buffer, line, column, trigger_character) ab \ 'textDocument': { \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), \ }, - \ 'position': {'line': a:line - 1, 'character': a:column}, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] if !empty(a:trigger_character) @@ -116,7 +120,16 @@ function! ale#lsp#message#Definition(buffer, line, column) abort \ 'textDocument': { \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), \ }, - \ 'position': {'line': a:line - 1, 'character': a:column}, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#TypeDefinition(buffer, line, column) abort + return [0, 'textDocument/typeDefinition', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] endfunction @@ -125,7 +138,7 @@ function! ale#lsp#message#References(buffer, line, column) abort \ 'textDocument': { \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), \ }, - \ 'position': {'line': a:line - 1, 'character': a:column}, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \ 'context': {'includeDeclaration': v:false}, \}] endfunction @@ -141,7 +154,7 @@ function! ale#lsp#message#Hover(buffer, line, column) abort \ 'textDocument': { \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), \ }, - \ 'position': {'line': a:line - 1, 'character': a:column}, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, \}] endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim index 08b36808..b91d875b 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/response.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -33,7 +33,7 @@ function! ale#lsp#response#ReadDiagnostics(response) abort \ 'lnum': l:diagnostic.range.start.line + 1, \ 'col': l:diagnostic.range.start.character + 1, \ 'end_lnum': l:diagnostic.range.end.line + 1, - \ 'end_col': l:diagnostic.range.end.character + 1, + \ 'end_col': l:diagnostic.range.end.character, \} if l:severity == s:SEVERITY_WARNING @@ -58,16 +58,20 @@ function! ale#lsp#response#ReadDiagnostics(response) abort 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 - \ }) + \ 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 if has_key(l:diagnostic, 'source') - let l:loclist_item.detail = printf('[%s] %s', l:diagnostic.source, l:diagnostic.message) + let l:loclist_item.detail = printf( + \ '[%s] %s', + \ l:diagnostic.source, + \ l:diagnostic.message + \) endif call add(l:loclist, l:loclist_item) diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index 42d67398..d544916a 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -129,113 +129,242 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort endfunction function! ale#lsp_linter#GetOptions(buffer, linter) abort - let l:initialization_options = {} - if has_key(a:linter, 'initialization_options_callback') - let l:initialization_options = ale#util#GetFunction(a:linter.initialization_options_callback)(a:buffer) - elseif has_key(a:linter, 'initialization_options') - let l:initialization_options = a:linter.initialization_options + return ale#util#GetFunction(a:linter.initialization_options_callback)(a:buffer) endif - return l:initialization_options + if has_key(a:linter, 'initialization_options') + let l:Options = a:linter.initialization_options + + if type(l:Options) is v:t_func + let l:Options = l:Options(a:buffer) + endif + + return l:Options + endif + + return {} endfunction function! ale#lsp_linter#GetConfig(buffer, linter) abort - let l:config = {} - if has_key(a:linter, 'lsp_config_callback') - let l:config = ale#util#GetFunction(a:linter.lsp_config_callback)(a:buffer) - elseif has_key(a:linter, 'lsp_config') - let l:config = a:linter.lsp_config + return ale#util#GetFunction(a:linter.lsp_config_callback)(a:buffer) endif - return l:config + if has_key(a:linter, 'lsp_config') + let l:Config = a:linter.lsp_config + + if type(l:Config) is v:t_func + let l:Config = l:Config(a:buffer) + endif + + return l:Config + endif + + return {} endfunction -" Given a buffer, an LSP linter, start up an LSP linter and get ready to -" receive messages for the document. -function! ale#lsp_linter#StartLSP(buffer, linter) abort - let l:command = '' - let l:address = '' - let l:root = ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) +function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort + let l:buffer_ale_root = getbufvar(a:buffer, 'ale_lsp_root', {}) - if empty(l:root) && a:linter.lsp isnot# 'tsserver' - " If there's no project root, then we can't check files with LSP, - " unless we are using tsserver, which doesn't use project roots. - return {} + if type(l:buffer_ale_root) is v:t_string + return l:buffer_ale_root endif - let l:init_options = ale#lsp_linter#GetOptions(a:buffer, a:linter) + " Try to get a buffer-local setting for the root + if has_key(l:buffer_ale_root, a:linter.name) + let l:Root = l:buffer_ale_root[a:linter.name] - if a:linter.lsp is# 'socket' - let l:address = ale#linter#GetAddress(a:buffer, a:linter) - 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) - - if empty(l:executable) || !executable(l:executable) - return {} + if type(l:Root) is v:t_func + return l:Root(a:buffer) + else + return l:Root 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:ready = ale#lsp#StartProgram(l:conn_id, l:executable, l:command) endif - if !l:ready - if g:ale_history_enabled && !empty(l:command) - call ale#history#Add(a:buffer, 'failed', l:conn_id, l:command) + " Try to get a global setting for the root + if has_key(g:ale_lsp_root, a:linter.name) + let l:Root = g:ale_lsp_root[a:linter.name] + + if type(l:Root) is v:t_func + return l:Root(a:buffer) + else + return l:Root endif - - return {} endif - " tsserver behaves differently, so tell the LSP API that it is tsserver. - if a:linter.lsp is# 'tsserver' - call ale#lsp#MarkConnectionAsTsserver(l:conn_id) + " Fall back to the linter-specific configuration + if has_key(a:linter, 'project_root') + let l:Root = a:linter.project_root + + return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root endif - let l:config = ale#lsp_linter#GetConfig(a:buffer, a:linter) - let l:language_id = ale#util#GetFunction(a:linter.language_callback)(a:buffer) + return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) +endfunction - let l:details = { - \ 'buffer': a:buffer, - \ 'connection_id': l:conn_id, - \ 'command': l:command, - \ 'project_root': l:root, - \ 'language_id': l:language_id, - \} +" This function is accessible so tests can call it. +function! ale#lsp_linter#OnInit(linter, details, Callback) abort + let l:buffer = a:details.buffer + let l:conn_id = a:details.connection_id + let l:command = a:details.command - call ale#lsp#UpdateConfig(l:conn_id, a:buffer, l:config) + let l:config = ale#lsp_linter#GetConfig(l:buffer, a:linter) + let l:language_id = ale#util#GetFunction(a:linter.language_callback)(l:buffer) - if ale#lsp#OpenDocument(l:conn_id, a:buffer, l:language_id) + call ale#lsp#UpdateConfig(l:conn_id, l:buffer, l:config) + + if ale#lsp#OpenDocument(l:conn_id, l:buffer, l:language_id) if g:ale_history_enabled && !empty(l:command) - call ale#history#Add(a:buffer, 'started', l:conn_id, l:command) + call ale#history#Add(l:buffer, 'started', l:conn_id, l:command) endif endif " 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, a:buffer) + call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) endif - return l:details + call a:Callback(a:linter, a:details) endfunction -function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort - let l:info = g:ale_buffer_info[a:buffer] - let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter) +function! s:StartLSP(options, address, executable, command) abort + let l:buffer = a:options.buffer + let l:linter = a:options.linter + let l:root = a:options.root + let l:Callback = a:options.callback + + let l:init_options = ale#lsp_linter#GetOptions(l:buffer, l:linter) + + if l:linter.lsp is# 'socket' + let l:conn_id = ale#lsp#Register(a:address, l:root, l:init_options) + let l:ready = ale#lsp#ConnectToAddress(l:conn_id, a:address) + let l:command = '' + else + let l:conn_id = ale#lsp#Register(a:executable, l:root, l:init_options) + + " tsserver behaves differently, so tell the LSP API that it is tsserver. + if l:linter.lsp is# 'tsserver' + call ale#lsp#MarkConnectionAsTsserver(l:conn_id) + endif + + let l:command = ale#command#FormatCommand(l:buffer, a:executable, a:command, 0, v:false)[1] + let l:command = ale#job#PrepareCommand(l:buffer, l:command) + let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command) + endif + + if !l:ready + if g:ale_history_enabled && !empty(a:command) + call ale#history#Add(l:buffer, 'failed', l:conn_id, a:command) + endif - if empty(l:lsp_details) return 0 endif - let l:id = l:lsp_details.connection_id + let l:details = { + \ 'buffer': l:buffer, + \ 'connection_id': l:conn_id, + \ 'command': l:command, + \ 'project_root': l:root, + \} + + call ale#lsp#OnInit(l:conn_id, {-> + \ ale#lsp_linter#OnInit(l:linter, l:details, l:Callback) + \}) + + return 1 +endfunction + +function! s:StartWithAddress(options, address) abort + if ale#command#IsDeferred(a:address) + let a:address.result_callback = { + \ address -> s:StartWithAddress(a:options, address) + \} + + return 1 + endif + + if empty(a:address) + return 0 + endif + + return s:StartLSP(a:options, a:address, '', '') +endfunction + +function! s:StartWithCommand(options, executable, command) abort + if ale#command#IsDeferred(a:command) + let a:command.result_callback = { + \ command -> s:StartWithCommand(a:options, a:executable, command) + \} + + return 1 + endif + + if empty(a:command) + return 0 + endif + + return s:StartLSP(a:options, '', a:executable, a:command) +endfunction + +function! s:StartIfExecutable(options, executable) abort + if ale#command#IsDeferred(a:executable) + let a:executable.result_callback = { + \ executable -> s:StartIfExecutable(a:options, executable) + \} + + return 1 + endif + + if !ale#engine#IsExecutable(a:options.buffer, a:executable) + return 0 + endif + + let l:command = ale#linter#GetCommand(a:options.buffer, a:options.linter) + + return s:StartWithCommand(a:options, a:executable, l:command) +endfunction + +" Given a buffer, an LSP linter, start up an LSP linter and get ready to +" receive messages for the document. +function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort + let l:command = '' + let l:address = '' + let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, a:linter) + + if empty(l:root) && a:linter.lsp isnot# 'tsserver' + " If there's no project root, then we can't check files with LSP, + " unless we are using tsserver, which doesn't use project roots. + return 0 + endif + + let l:options = { + \ 'buffer': a:buffer, + \ 'linter': a:linter, + \ 'callback': a:Callback, + \ 'root': l:root, + \} + + if a:linter.lsp is# 'socket' + let l:address = ale#linter#GetAddress(a:buffer, a:linter) + + return s:StartWithAddress(l:options, l:address) + endif + + let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) + + return s:StartIfExecutable(l:options, l:executable) +endfunction + +function! s:CheckWithLSP(linter, details) abort + let l:buffer = a:details.buffer + let l:info = get(g:ale_buffer_info, l:buffer) + + if empty(l:info) + return + endif + + let l:id = a:details.connection_id " Register a callback now for handling errors now. let l:Callback = function('ale#lsp_linter#HandleLSPResponse') @@ -245,26 +374,26 @@ function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort let s:lsp_linter_map[l:id] = a:linter.name if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#Geterr(a:buffer) + let l:message = ale#lsp#tsserver_message#Geterr(l:buffer) let l:notified = ale#lsp#Send(l:id, l:message) != 0 else - let l:notified = ale#lsp#NotifyForChanges(l:id, a:buffer) + let l:notified = ale#lsp#NotifyForChanges(l:id, l: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) + \&& getbufvar(l:buffer, 'ale_save_event_fired', 0) + let l:save_message = ale#lsp#message#DidSave(l:buffer) let l:notified = ale#lsp#Send(l:id, l:save_message) != 0 endif if l:notified - if index(l:info.active_linter_list, a:linter.name) < 0 - call add(l:info.active_linter_list, a:linter.name) - endif + call ale#engine#MarkLinterActive(l:info, a:linter) endif +endfunction - return l:notified +function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort + return ale#lsp_linter#StartLSP(a:buffer, a:linter, function('s:CheckWithLSP')) endfunction " Clear LSP linter data for the linting engine. diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim index 5c579c75..f75280b7 100644 --- a/sources_non_forked/ale/autoload/ale/node.vim +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -23,11 +23,6 @@ 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/path.vim b/sources_non_forked/ale/autoload/ale/path.vim index 89b119f4..ca3afc52 100644 --- a/sources_non_forked/ale/autoload/ale/path.vim +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -197,15 +197,18 @@ function! ale#path#ToURI(path) abort endfunction function! ale#path#FromURI(uri) abort - let l:i = len('file://') - let l:encoded_path = a:uri[: l:i - 1] is# 'file://' ? a:uri[l:i :] : a:uri - - let l:path = ale#uri#Decode(l:encoded_path) - - " If the path is like /C:/foo/bar, it should be C:\foo\bar instead. - if l:path =~# '^/[a-zA-Z]:' - let l:path = substitute(l:path[1:], '/', '\\', 'g') + if a:uri[:6] is? 'file://' + let l:encoded_path = a:uri[7:] + elseif a:uri[:4] is? 'file:' + let l:encoded_path = a:uri[5:] + else + let l:encoded_path = a:uri endif - return l:path + " If the path is like /C:/foo/bar, it should be C:\foo\bar instead. + if l:encoded_path =~# '^/[a-zA-Z]:' + let l:encoded_path = substitute(l:encoded_path[1:], '/', '\\', 'g') + endif + + return ale#uri#Decode(l:encoded_path) endfunction diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 1f50e0ad..6d58aca9 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -41,16 +41,24 @@ endfunction " Show a location selection preview window, given some items. " Each item should have 'filename', 'line', and 'column' keys. -function! ale#preview#ShowSelection(item_list) abort +function! ale#preview#ShowSelection(item_list, ...) abort + let l:options = get(a:000, 0, {}) + let l:sep = has('win32') ? '\' : '/' let l:lines = [] " Create lines to display to users. for l:item in a:item_list let l:match = get(l:item, 'match', '') + let l:filename = l:item.filename + + if get(l:options, 'use_relative_paths') + let l:cwd = getcwd() " no-custom-checks + let l:filename = substitute(l:filename, '^' . l:cwd . l:sep, '', '') + endif call add( \ l:lines, - \ l:item.filename + \ l:filename \ . ':' . l:item.line \ . ':' . l:item.column \ . (!empty(l:match) ? ' ' . l:match : ''), @@ -63,7 +71,7 @@ endfunction function! s:Open(open_in_tab) abort let l:item_list = get(b:, 'ale_preview_item_list', []) - let l:item = get(l:item_list, getcurpos()[1] - 1, {}) + let l:item = get(l:item_list, getpos('.')[1] - 1, {}) if empty(l:item) return diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index 8d6bf1f0..2f28214b 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -27,6 +27,9 @@ function! ale#python#FindProjectRootIni(buffer) abort \|| filereadable(l:path . '/pycodestyle.cfg') \|| filereadable(l:path . '/flake8.cfg') \|| filereadable(l:path . '/.flake8rc') + \|| filereadable(l:path . '/pylama.ini') + \|| filereadable(l:path . '/pylintrc') + \|| filereadable(l:path . '/.pylintrc') \|| filereadable(l:path . '/Pipfile') \|| filereadable(l:path . '/Pipfile.lock') return l:path @@ -48,7 +51,7 @@ function! ale#python#FindProjectRoot(buffer) abort let l:ini_root = ale#python#FindProjectRootIni(a:buffer) if !empty(l:ini_root) - return l:ini_root + return l:ini_root endif for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) @@ -110,6 +113,44 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort return ale#Var(a:buffer, a:base_var_name . '_executable') endfunction +" Handle traceback.print_exception() output starting in the first a:limit lines. +function! ale#python#HandleTraceback(lines, limit) abort + let l:nlines = len(a:lines) + let l:limit = a:limit > l:nlines ? l:nlines : a:limit + let l:start = 0 + + while l:start < l:limit + if a:lines[l:start] is# 'Traceback (most recent call last):' + break + endif + + let l:start += 1 + endwhile + + if l:start >= l:limit + return [] + endif + + let l:end = l:start + 1 + + " Traceback entries are always prefixed with 2 spaces. + " SyntaxError marker (if present) is prefixed with at least 4 spaces. + " Final exc line starts with exception class name (never a space). + while l:end < l:nlines && a:lines[l:end][0] is# ' ' + let l:end += 1 + endwhile + + let l:exc_line = l:end < l:nlines + \ ? a:lines[l:end] + \ : 'An exception was thrown.' + + return [{ + \ 'lnum': 1, + \ 'text': l:exc_line . ' (See :ALEDetail)', + \ 'detail': join(a:lines[(l:start):(l:end)], "\n"), + \}] +endfunction + " Detects whether a pipenv environment is present. function! ale#python#PipenvPresent(buffer) abort return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index 24267bb4..0e88afe2 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -17,7 +17,7 @@ endfunction function! ale#references#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'command', '') is# 'references' \&& has_key(s:references_map, a:response.request_seq) - call remove(s:references_map, a:response.request_seq) + let l:options = remove(s:references_map, a:response.request_seq) if get(a:response, 'success', v:false) is v:true let l:item_list = [] @@ -34,7 +34,7 @@ function! ale#references#HandleTSServerResponse(conn_id, response) abort if empty(l:item_list) call ale#util#Execute('echom ''No references found.''') else - call ale#preview#ShowSelection(l:item_list) + call ale#preview#ShowSelection(l:item_list, l:options) endif endif endif @@ -43,7 +43,7 @@ endfunction function! ale#references#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:references_map, a:response.id) - call remove(s:references_map, a:response.id) + let l:options = remove(s:references_map, a:response.id) " The result can be a Dictionary item, a List of the same, or null. let l:result = get(a:response, 'result', []) @@ -60,15 +60,20 @@ function! ale#references#HandleLSPResponse(conn_id, response) abort if empty(l:item_list) call ale#util#Execute('echom ''No references found.''') else - call ale#preview#ShowSelection(l:item_list) + call ale#preview#ShowSelection(l:item_list, l:options) endif endif endfunction -function! s:OnReady(linter, lsp_details, line, column, ...) abort - let l:buffer = a:lsp_details.buffer +function! s:OnReady(line, column, options, linter, lsp_details) abort let l:id = a:lsp_details.connection_id + if !ale#lsp#HasCapability(l:id, 'references') + return + endif + + let l:buffer = a:lsp_details.buffer + let l:Callback = a:linter.lsp is# 'tsserver' \ ? function('ale#references#HandleTSServerResponse') \ : function('ale#references#HandleLSPResponse') @@ -91,34 +96,30 @@ function! s:OnReady(linter, lsp_details, line, column, ...) abort let l:request_id = ale#lsp#Send(l:id, l:message) - let s:references_map[l:request_id] = {} + let s:references_map[l:request_id] = { + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \} endfunction -function! s:FindReferences(linter) abort +function! ale#references#Find(...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-relative' + let l:options.use_relative_paths = 1 + endif + endfor + endif + let l:buffer = bufnr('') - let [l:line, l:column] = getcurpos()[1:2] + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + let l:Callback = function('s:OnReady', [l:line, l:column, l:options]) - if a:linter.lsp isnot# 'tsserver' - let l:column = min([l:column, len(getline(l:line))]) - endif - - let l:lsp_details = ale#lsp_linter#StartLSP(l:buffer, a:linter) - - if empty(l:lsp_details) - return 0 - endif - - let l:id = l:lsp_details.connection_id - - 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 for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) - call s:FindReferences(l:linter) + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) endif endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/ruby.vim b/sources_non_forked/ale/autoload/ale/ruby.vim index 3d9c5a51..69d7a0c0 100644 --- a/sources_non_forked/ale/autoload/ale/ruby.vim +++ b/sources_non_forked/ale/autoload/ale/ruby.vim @@ -26,7 +26,7 @@ function! ale#ruby#FindProjectRoot(buffer) abort let l:dir = ale#ruby#FindRailsRoot(a:buffer) if isdirectory(l:dir) - return l:dir + return l:dir endif for l:name in ['.solargraph.yml', 'Rakefile', 'Gemfile'] diff --git a/sources_non_forked/ale/autoload/ale/semver.vim b/sources_non_forked/ale/autoload/ale/semver.vim index 6b0fd34a..8f549c9f 100644 --- a/sources_non_forked/ale/autoload/ale/semver.vim +++ b/sources_non_forked/ale/autoload/ale/semver.vim @@ -14,7 +14,7 @@ function! ale#semver#GetVersion(executable, version_lines) abort let l:version = get(s:version_cache, a:executable, []) for l:line in a:version_lines - let l:match = matchlist(l:line, '\v(\d+)\.(\d+)\.(\d+)') + let l:match = matchlist(l:line, '\v(\d+)\.(\d+)\.?(\d?)') if !empty(l:match) let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[3] + 0] diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index af863682..fc1ea5b6 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -116,7 +116,7 @@ endfunction " Read sign data for a buffer to a list of lines. function! ale#sign#ReadSigns(buffer) abort redir => l:output - silent execute 'sign place buffer=' . a:buffer + silent execute 'sign place buffer=' . a:buffer redir end return split(l:output, "\n") diff --git a/sources_non_forked/ale/autoload/ale/statusline.vim b/sources_non_forked/ale/autoload/ale/statusline.vim index 94fbd6c9..6b93ba51 100644 --- a/sources_non_forked/ale/autoload/ale/statusline.vim +++ b/sources_non_forked/ale/autoload/ale/statusline.vim @@ -1,4 +1,5 @@ " Author: KabbAmine +" Additions by: petpetpetpet " Description: Statusline related function(s) function! s:CreateCountDict() abort @@ -26,19 +27,42 @@ function! ale#statusline#Update(buffer, loclist) abort let l:count = s:CreateCountDict() let l:count.total = len(l:loclist) + " Allows easy access to the first instance of each problem type. + let l:first_problems = {} + for l:entry in l:loclist if l:entry.type is# 'W' if get(l:entry, 'sub_type', '') is# 'style' let l:count.style_warning += 1 + + if l:count.style_warning == 1 + let l:first_problems.style_warning = l:entry + endif else let l:count.warning += 1 + + if l:count.warning == 1 + let l:first_problems.warning = l:entry + endif endif elseif l:entry.type is# 'I' let l:count.info += 1 + + if l:count.info == 1 + let l:first_problems.info = l:entry + endif elseif get(l:entry, 'sub_type', '') is# 'style' let l:count.style_error += 1 + + if l:count.style_error == 1 + let l:first_problems.style_error = l:entry + endif else let l:count.error += 1 + + if l:count.error == 1 + let l:first_problems.error = l:entry + endif endif endfor @@ -47,24 +71,65 @@ function! ale#statusline#Update(buffer, loclist) abort let l:count[1] = l:count.total - l:count[0] let g:ale_buffer_info[a:buffer].count = l:count + let g:ale_buffer_info[a:buffer].first_problems = l:first_problems +endfunction + +" Get the counts for the buffer, and update the counts if needed. +function! s:UpdateCacheIfNecessary(buffer) abort + " Cache is cold, so manually ask for an update. + if !has_key(g:ale_buffer_info[a:buffer], 'count') + call ale#statusline#Update( + \ a:buffer, + \ g:ale_buffer_info[a:buffer].loclist + \) + endif +endfunction + +function! s:BufferCacheExists(buffer) abort + if !exists('g:ale_buffer_info') || !has_key(g:ale_buffer_info, a:buffer) + return 0 + endif + + return 1 endfunction " Get the counts for the buffer, and update the counts if needed. function! s:GetCounts(buffer) abort - if !exists('g:ale_buffer_info') || !has_key(g:ale_buffer_info, a:buffer) + if !s:BufferCacheExists(a:buffer) return s:CreateCountDict() endif - " Cache is cold, so manually ask for an update. - if !has_key(g:ale_buffer_info[a:buffer], 'count') - call ale#statusline#Update(a:buffer, g:ale_buffer_info[a:buffer].loclist) - endif + call s:UpdateCacheIfNecessary(a:buffer) return g:ale_buffer_info[a:buffer].count endfunction +" Get the dict of first_problems, update the buffer info cache if necessary. +function! s:GetFirstProblems(buffer) abort + if !s:BufferCacheExists(a:buffer) + return {} + endif + + call s:UpdateCacheIfNecessary(a:buffer) + + return g:ale_buffer_info[a:buffer].first_problems +endfunction + " Returns a Dictionary with counts for use in third party integrations. function! ale#statusline#Count(buffer) abort " The Dictionary is copied here before exposing it to other plugins. return copy(s:GetCounts(a:buffer)) endfunction + +" Returns a copy of the *first* locline instance of the specified problem +" type. (so this would allow an external integration to know all the info +" about the first style warning in the file, for example.) +function! ale#statusline#FirstProblem(buffer, type) abort + let l:first_problems = s:GetFirstProblems(a:buffer) + + if !empty(l:first_problems) && has_key(l:first_problems, a:type) + return copy(l:first_problems[a:type]) + endif + + return {} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/symbol.vim b/sources_non_forked/ale/autoload/ale/symbol.vim index 5180cb86..ae4151ab 100644 --- a/sources_non_forked/ale/autoload/ale/symbol.vim +++ b/sources_non_forked/ale/autoload/ale/symbol.vim @@ -52,12 +52,18 @@ function! ale#symbol#HandleLSPResponse(conn_id, response) abort if empty(l:item_list) call ale#util#Execute('echom ''No symbols found.''') else - call ale#preview#ShowSelection(l:item_list) + call ale#preview#ShowSelection(l:item_list, l:options) endif endif endfunction -function! s:OnReady(linter, lsp_details, query, ...) abort +function! s:OnReady(query, options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'symbol_search') + return + endif + let l:buffer = a:lsp_details.buffer " If we already made a request, stop here. @@ -65,8 +71,6 @@ function! s:OnReady(linter, lsp_details, query, ...) abort return endif - let l:id = a:lsp_details.connection_id - let l:Callback = function('ale#symbol#HandleLSPResponse') call ale#lsp#RegisterCallback(l:id, l:Callback) @@ -76,34 +80,31 @@ function! s:OnReady(linter, lsp_details, query, ...) abort call setbufvar(l:buffer, 'ale_symbol_request_made', 1) let s:symbol_map[l:request_id] = { \ 'buffer': l:buffer, + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 \} endfunction -function! s:Search(linter, buffer, query) abort - let l:lsp_details = ale#lsp_linter#StartLSP(a:buffer, a:linter) +function! ale#symbol#Search(args) abort + let [l:opts, l:query] = ale#args#Parse(['relative'], a:args) - if !empty(l:lsp_details) - call ale#lsp#WaitForCapability( - \ l:lsp_details.connection_id, - \ 'symbol_search', - \ function('s:OnReady', [a:linter, l:lsp_details, a:query]), - \) - endif -endfunction - -function! ale#symbol#Search(query) abort - if type(a:query) isnot v:t_string || empty(a:query) + if empty(l:query) throw 'A non-empty string must be provided!' endif let l:buffer = bufnr('') + let l:options = {} + + if has_key(l:opts, 'relative') + let l:options.use_relative_paths = 1 + endif " Set a flag so we only make one request. call setbufvar(l:buffer, 'ale_symbol_request_made', 0) + let l:Callback = function('s:OnReady', [l:query, l:options]) for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver' - call s:Search(l:linter, l:buffer, a:query) + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) endif endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/test.vim b/sources_non_forked/ale/autoload/ale/test.vim index e6ec70dc..082d91ff 100644 --- a/sources_non_forked/ale/autoload/ale/test.vim +++ b/sources_non_forked/ale/autoload/ale/test.vim @@ -55,9 +55,9 @@ endfunction function! s:RemoveModule(results) abort for l:item in a:results - if has_key(l:item, 'module') - call remove(l:item, 'module') - endif + if has_key(l:item, 'module') + call remove(l:item, 'module') + endif endfor endfunction @@ -85,3 +85,103 @@ function! ale#test#GetPreviewWindowText() abort endif endfor endfunction + +" This function can be called with a timeout to wait for all jobs to finish. +" If the jobs to not finish in the given number of milliseconds, +" an exception will be thrown. +" +" The time taken will be a very rough approximation, and more time may be +" permitted than is specified. +function! ale#test#WaitForJobs(deadline) abort + let l:start_time = ale#events#ClockMilliseconds() + + if l:start_time == 0 + throw 'Failed to read milliseconds from the clock!' + endif + + let l:job_list = [] + + " Gather all of the jobs from every buffer. + for [l:buffer, l:data] in items(ale#command#GetData()) + call extend(l:job_list, map(keys(l:data.jobs), 'str2nr(v:val)')) + endfor + + " NeoVim has a built-in API for this, so use that. + if has('nvim') + let l:nvim_code_list = jobwait(l:job_list, a:deadline) + + if index(l:nvim_code_list, -1) >= 0 + throw 'Jobs did not complete on time!' + endif + + return + endif + + let l:should_wait_more = 1 + + while l:should_wait_more + let l:should_wait_more = 0 + + for l:job_id in l:job_list + if ale#job#IsRunning(l:job_id) + let l:now = ale#events#ClockMilliseconds() + + if l:now - l:start_time > a:deadline + " Stop waiting after a timeout, so we don't wait forever. + throw 'Jobs did not complete on time!' + endif + + " Wait another 10 milliseconds + let l:should_wait_more = 1 + sleep 10ms + break + endif + endfor + endwhile + + " Sleep for a small amount of time after all jobs finish. + " This seems to be enough to let handlers after jobs end run, and + " prevents the occasional failure where this function exits after jobs + " end, but before handlers are run. + sleep 10ms + + " We must check the buffer data again to see if new jobs started + " for command_chain linters. + let l:has_new_jobs = 0 + + " Check again to see if any jobs are running. + for l:info in values(g:ale_buffer_info) + for [l:job_id, l:linter] in get(l:info, 'job_list', []) + if ale#job#IsRunning(l:job_id) + let l:has_new_jobs = 1 + break + endif + endfor + endfor + + if l:has_new_jobs + " We have to wait more. Offset the timeout by the time taken so far. + let l:now = ale#events#ClockMilliseconds() + let l:new_deadline = a:deadline - (l:now - l:start_time) + + if l:new_deadline <= 0 + " Enough time passed already, so stop immediately. + throw 'Jobs did not complete on time!' + endif + + call ale#test#WaitForJobs(l:new_deadline) + endif +endfunction + +function! ale#test#FlushJobs() abort + " The variable is checked for in a loop, as calling one series of + " callbacks can trigger a further series of callbacks. + while exists('g:ale_run_synchronously_callbacks') + let l:callbacks = g:ale_run_synchronously_callbacks + unlet g:ale_run_synchronously_callbacks + + for l:Callback in l:callbacks + call l:Callback() + endfor + endwhile +endfunction diff --git a/sources_non_forked/ale/autoload/ale/toggle.vim b/sources_non_forked/ale/autoload/ale/toggle.vim index 8e642b3f..1311e527 100644 --- a/sources_non_forked/ale/autoload/ale/toggle.vim +++ b/sources_non_forked/ale/autoload/ale/toggle.vim @@ -13,6 +13,10 @@ function! s:DisablePostamble() abort if g:ale_set_highlights call ale#highlight#UpdateHighlights() endif + + if g:ale_virtualtext_cursor + call ale#virtualtext#Clear() + endif endfunction function! ale#toggle#Toggle() abort diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index ee9359f8..e57307e4 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -111,6 +111,7 @@ function! ale#util#Open(filename, line, column, options) abort endif call cursor(a:line, a:column) + normal! zz endfunction let g:ale#util#error_priority = 5 @@ -469,7 +470,7 @@ endfunction function! ale#util#FindItemAtCursor(buffer) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) let l:loclist = get(l:info, 'loclist', []) - let l:pos = getcurpos() + let l:pos = getpos('.') let l:index = ale#util#BinarySearch(l:loclist, a:buffer, l:pos[1], l:pos[2]) let l:loc = l:index >= 0 ? l:loclist[l:index] : {} diff --git a/sources_non_forked/ale/autoload/ale/virtualtext.vim b/sources_non_forked/ale/autoload/ale/virtualtext.vim index c4ce37dd..532427fb 100644 --- a/sources_non_forked/ale/autoload/ale/virtualtext.vim +++ b/sources_non_forked/ale/autoload/ale/virtualtext.vim @@ -47,7 +47,6 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort return endif - let l:cursor_position = getcurpos() let l:line = line('.') let l:buffer = bufnr('') let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ') @@ -117,7 +116,7 @@ function! ale#virtualtext#ShowCursorWarningWithDelay() abort call s:StopCursorTimer() - let l:pos = getcurpos()[0:2] + let l:pos = getpos('.')[0:2] " Check the current buffer, line, and column number against the last " recorded position. If the position has actually changed, *then* diff --git a/sources_non_forked/ale/doc/ale-asciidoc.txt b/sources_non_forked/ale/doc/ale-asciidoc.txt index b6b64fd3..86629fd4 100644 --- a/sources_non_forked/ale/doc/ale-asciidoc.txt +++ b/sources_non_forked/ale/doc/ale-asciidoc.txt @@ -8,5 +8,11 @@ write-good *ale-asciidoc-write-good* See |ale-write-good-options| +=============================================================================== +textlint *ale-asciidoc-textlint* + +See |ale-text-textlint| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cmake.txt b/sources_non_forked/ale/doc/ale-cmake.txt index fb46336f..602637b1 100644 --- a/sources_non_forked/ale/doc/ale-cmake.txt +++ b/sources_non_forked/ale/doc/ale-cmake.txt @@ -21,5 +21,23 @@ g:ale_cmake_cmakelint_options *g:ale_cmake_cmakelint_options* This variable can be set to pass additional options to cmakelint. +=============================================================================== +cmake-format *ale-cmake-cmakeformat* + +g:ale_cmake_cmakeformat_executable *g:ale_cmake_cmakeformat_executable* + *b:ale_cmake_cmakeformat_executable* + Type: |String| + Default: `'cmakeformat'` + + This variable can be set to change the path the cmake-format. + + +g:ale_cmake_cmakeformat_options *g:ale_cmake_cmakeformat_options* + *b:ale_cmake_cmakeformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to cmake-format. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-development.txt b/sources_non_forked/ale/doc/ale-development.txt index 1e168130..408b176f 100644 --- a/sources_non_forked/ale/doc/ale-development.txt +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -1,4 +1,5 @@ *ale-development.txt* For Vim version 8.0. +*ale-dev* *ale-development* ALE Development Documentation @@ -143,7 +144,7 @@ Apply the following rules when writing Bash scripts. * Try to write scripts so they will run on Linux, BSD, or Mac OSX. =============================================================================== -4. Testing ALE *ale-development-tests* +4. Testing ALE *ale-development-tests* *ale-dev-tests* *ale-tests* ALE is tested with a suite of tests executed in Travis CI and AppVeyor. ALE runs tests with the following versions of Vim in the following environments. diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index a4db683b..2247eddc 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -107,6 +107,17 @@ 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. +=============================================================================== +stack-ghc *ale-haskell-stack-ghc* + +g:ale_haskell_stack_ghc_options *g:ale_haskell_stack_ghc_options* + *b:ale_haskell_stack_ghc_options* + Type: |String| + Default: `'-fno-code -v0'` + + This variable can be changed to modify flags given to ghc through `stack + ghc` + =============================================================================== stylish-haskell *ale-haskell-stylish-haskell* diff --git a/sources_non_forked/ale/doc/ale-java.txt b/sources_non_forked/ale/doc/ale-java.txt index 8e40aea0..aa226305 100644 --- a/sources_non_forked/ale/doc/ale-java.txt +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -79,14 +79,19 @@ g:ale_java_pmd_options *g:ale_java_pmd_options* javalsp *ale-java-javalsp* To enable Java LSP linter you need to download and build the vscode-javac -language server from https://github.com/georgewfraser/vscode-javac. Simply -download the source code and then build the plugin using maven: +language server from https://github.com/georgewfraser/java-language-server. +Simply download the source code and then build a distribution: - mvn package + scripts/link_mac.sh -This generates a out/fat-jar.jar file that contains the language server. To -let ALE use this language server you need to set the g:ale_java_javalsp_jar -variable to the absolute path of this jar file. +or + + scripts/link_windows.sh + +This generates a dist/mac or dist/windows directory that contains the +language server. To let ALE use this language server you need to set the +g:ale_java_javalsp_executable variable to the absolute path of the java +executable in this directory. g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* *b:ale_java_javalsp_executable* @@ -95,14 +100,6 @@ g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* This variable can be changed to use a different executable for java. -g:ale_java_javalsp_jar *g:ale_java_javalsp_jar* - *b:ale_java_javalsp_jar* - - Type: |String| - Default: `'fat-jar.jar'` - - Path to the location of the vscode-javac language server plugin. - =============================================================================== uncrustify *ale-java-uncrustify* diff --git a/sources_non_forked/ale/doc/ale-kotlin.txt b/sources_non_forked/ale/doc/ale-kotlin.txt index 9f9fd16e..4028531f 100644 --- a/sources_non_forked/ale/doc/ale-kotlin.txt +++ b/sources_non_forked/ale/doc/ale-kotlin.txt @@ -84,9 +84,17 @@ g:ale_kotlin_ktlint_rulesets *g:ale_kotlin_ktlint_rulesets* This list should contain paths to ruleset jars and/or strings of maven artifact triples. Example: > - let g:ale_kotlin_ktlint_rulesets = ['/path/to/custom-rulset.jar', + let g:ale_kotlin_ktlint_rulesets = ['/path/to/custom-ruleset.jar', 'com.ktlint.rulesets:mycustomrule:1.0.0'] +g:ale_kotlin_ktlint_options *g:ale_kotlin_ktlint_options* + Type: |String| + Default: `''` + + Additional options to pass to ktlint for both linting and fixing. Example: + > + let g:ale_kotlin_ktlint_options = '--android' + =============================================================================== languageserver *ale-kotlin-languageserver* diff --git a/sources_non_forked/ale/doc/ale-latex.txt b/sources_non_forked/ale/doc/ale-latex.txt index 87fbd4e8..bedbabcd 100644 --- a/sources_non_forked/ale/doc/ale-latex.txt +++ b/sources_non_forked/ale/doc/ale-latex.txt @@ -8,5 +8,11 @@ write-good *ale-latex-write-good* See |ale-write-good-options| +=============================================================================== +textlint *ale-latex-textlint* + +See |ale-text-textlint| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index a1ad1500..dd946ad4 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -31,6 +31,9 @@ ALE will look for configuration files with the following filenames. > pycodestyle.cfg flake8.cfg .flake8rc + pylama.ini + pylintrc + .pylintrc Pipfile Pipfile.lock < @@ -65,6 +68,56 @@ g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* See |ale-integrations-local-executables| +=============================================================================== +bandit *ale-python-bandit* + +g:ale_python_bandit_executable *g:ale_python_bandit_executable* + *b:ale_python_bandit_executable* + Type: |String| + Default: `'bandit'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `bandit'`. + + +g:ale_python_bandit_options *g:ale_python_bandit_options* + *b:ale_python_bandit_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + bandit invocation. + + +g:ale_python_bandit_use_config *g:ale_python_bandit_use_config* + *b:ale_python_bandit_use_config* + Type: |Number| + Default: `1` + + If this variable is true and a `.bandit` file exists in the directory of the + file being checked or a parent directory, an `--ini` option is added to the + `bandit` command for the nearest `.bandit` file. Set this variable false to + disable adding the `--ini` option automatically. + + +g:ale_python_bandit_use_global *g:ale_python_bandit_use_global* + *b:ale_python_bandit_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_bandit_auto_pipenv *g:ale_python_bandit_auto_pipenv* + *b:ale_python_bandit_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + =============================================================================== black *ale-python-black* @@ -100,6 +153,16 @@ g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* Detect whether the file is inside a pipenv, and set the executable to `pipenv` if true. This is overridden by a manually-set executable. +g:ale_python_black_change_directory *g:ale_python_black_change_directory* + *b:ale_python_black_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, ALE will switch to the directory the Python file being + checked with `black` is in before checking it. This helps `black` find + configuration files more easily. This option can be turned off if you want + to control the directory Python is executed from yourself. + =============================================================================== flake8 *ale-python-flake8* @@ -400,6 +463,60 @@ g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* if true. This is overridden by a manually-set executable. +=============================================================================== +pylama *ale-python-pylama* + +g:ale_python_pylama_change_directory *g:ale_python_pylama_change_directory* + *b:ale_python_pylama_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `pylama` will be run from a detected project root, per + |ale-python-root|. This is useful because `pylama` only searches for + configuration files in its current directory and applies file masks using + paths relative to its current directory. This option can be turned off if + you want to control the directory in which `pylama` is executed. + + +g:ale_python_pylama_executable *g:ale_python_pylama_executable* + *b:ale_python_pylama_executable* + Type: |String| + Default: `'pylama'` + + This variable can be changed to modify the executable used for pylama. Set + this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. + + +g:ale_python_pylama_options *g:ale_python_pylama_options* + *b:ale_python_pylama_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylama + invocation. + + +g:ale_python_pylama_use_global *g:ale_python_pylama_use_global* + *b:ale_python_pylama_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for pylama in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_python_pylama_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + + +g:ale_python_pylama_auto_pipenv *g:ale_python_pylama_auto_pipenv* + *b:ale_python_pylama_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + =============================================================================== pylint *ale-python-pylint* @@ -408,10 +525,12 @@ g:ale_python_pylint_change_directory *g:ale_python_pylint_change_directory* Type: |Number| Default: `1` - If set to `1`, ALE will switch to the directory the Python file being - checked with `pylint` is in before checking it. This helps `pylint` find - configuration files more easily. This option can be turned off if you want - to control the directory Python is executed from yourself. + If set to `1`, `pylint` will be run from a detected project root, per + |ale-python-root|. Since `pylint` only checks for `pylintrc` in the packages + above its current directory before falling back to user and global `pylintrc` + files, this is necessary for `pylint` to use a project `pylintrc` file, if + present. This option can be turned off if you want to control the directory + Python is executed from yourself. g:ale_python_pylint_executable *g:ale_python_pylint_executable* @@ -494,6 +613,24 @@ g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pyls_config *g:ale_python_pyls_config* + *b:ale_python_pyls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for pyls. For example, to disable + the pycodestyle linter: > + { + \ 'pyls': { + \ 'plugins': { + \ 'pycodestyle': { + \ 'enabled': v:false + \ } + \ } + \ }, + \ } +< + =============================================================================== pyre *ale-python-pyre* @@ -549,6 +686,15 @@ g:ale_python_vulture_executable *g:ale_python_vulture_executable* See |ale-integrations-local-executables| +g:ale_python_vulture_options *g:ale_python_vulture_options* + *b:ale_python_vulture_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the vulture + invocation. + + g:ale_python_vulture_use_global *g:ale_python_vulture_use_global* *b:ale_python_vulture_use_global* Type: |Number| diff --git a/sources_non_forked/ale/doc/ale-restructuredtext.txt b/sources_non_forked/ale/doc/ale-restructuredtext.txt index 02fbc4ad..e308b072 100644 --- a/sources_non_forked/ale/doc/ale-restructuredtext.txt +++ b/sources_non_forked/ale/doc/ale-restructuredtext.txt @@ -2,6 +2,20 @@ ALE reStructuredText Integration *ale-restructuredtext-options* +=============================================================================== +textlint *ale-restructuredtext-textlint* + +To use textlint at reStructuredText, please install `textlint-plugin-rst`. +https://github.com/jimo1001/textlint-plugin-rst +> + $ npm install textlint-plugin-rst + +To install `textlint-plugin-rst`, `docutils-ast-writer` python package +must be installed. +See: https://github.com/jimo1001/docutils-ast-writer + +See |ale-text-textlint| + =============================================================================== write-good *ale-restructuredtext-write-good* diff --git a/sources_non_forked/ale/doc/ale-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt index 7510dfbd..3393b9c0 100644 --- a/sources_non_forked/ale/doc/ale-rust.txt +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -172,6 +172,20 @@ g:ale_rust_rls_toolchain *g:ale_rust_rls_toolchain* The `rls` server will only be started once per executable. +g:ale_rust_rls_config *g:ale_rust_rls_config* + *b:ale_rust_rls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for rls. For example, to force + using clippy as linter: > + { + \ 'rust': { + \ 'clippy_preference': 'on' + \ } + \ } + + =============================================================================== rustc *ale-rust-rustc* diff --git a/sources_non_forked/ale/doc/ale-sass.txt b/sources_non_forked/ale/doc/ale-sass.txt index 735f44b2..22d7c472 100644 --- a/sources_non_forked/ale/doc/ale-sass.txt +++ b/sources_non_forked/ale/doc/ale-sass.txt @@ -1,5 +1,5 @@ =============================================================================== -ALE SASS Integration *ale-sass-options* +ALE Sass Integration *ale-sass-options* =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-sh.txt b/sources_non_forked/ale/doc/ale-sh.txt index 7557e522..64f59609 100644 --- a/sources_non_forked/ale/doc/ale-sh.txt +++ b/sources_non_forked/ale/doc/ale-sh.txt @@ -61,6 +61,18 @@ g:ale_sh_shellcheck_options *g:ale_sh_shellcheck_options* let g:ale_sh_shellcheck_options = '-x' < + +g:ale_sh_shellcheck_dialect *g:ale_sh_shellcheck_dialect* + *b:ale_sh_shellcheck_dialect* + Type: |String| + Default: `'auto'` + + This variable specifies the shellcheck dialect (`-s` option). The value + `'auto'` causes ALE to detect the dialect automatically, based on the shebang + line (if present) or the value of `b:is_bash`, `b:is_sh`, or `b:is_kornshell` + (set and used by |sh.vim|). + + g:ale_sh_shellcheck_exclusions *g:ale_sh_shellcheck_exclusions* *b:ale_sh_shellcheck_exclusions* Type: |String| diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt index 2b8ce5e2..94b820b8 100644 --- a/sources_non_forked/ale/doc/ale-verilog.txt +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -3,7 +3,7 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options* =============================================================================== -ALE can use two different linters for Verilog HDL: +ALE can use four different linters for Verilog HDL: iverilog: Using `iverilog -t null -Wall` @@ -11,6 +11,12 @@ ALE can use two different linters for Verilog HDL: verilator Using `verilator --lint-only -Wall` + ModelSim/Questa + Using `vlog -quiet -lint` + + Vivado + Using `xvlog` + By default, both 'verilog' and 'systemverilog' filetypes are checked. You can limit 'systemverilog' files to be checked using only 'verilator' by @@ -20,6 +26,20 @@ defining 'g:ale_linters' variable: \ let g:ale_linters = {'systemverilog' : ['verilator'],} < +Linters/compilers that utilize a "work" directory for analyzing designs- such +as ModelSim and Vivado- can be passed the location of these directories as +part of their respective option strings listed below. This is useful for +holistic analysis of a file (e.g. a design with components, packages, or other +code defined external to the current file as part of a larger project) or +when wanting to simply pass an alternative location for the auto-generated +work directories (such as '/tmp') so as to not muddle the current directory. +Since these type of linters often use this work directory for holding compiled +design data as part of a single build process, they sometimes cannot handle +the frequent, asynchronous application launches when linting while text is +changing. This can happen in the form of hangs or crashes. To help prevent +this when using these linters, it may help to run linting less frequently; for +example, only when a file is saved. + =============================================================================== iverilog *ale-verilog-iverilog* @@ -39,5 +59,44 @@ g:ale_verilog_verilator_options *g:ale_verilog_verilator_options* For example `'-sv --default-language "1800-2012"'` if you want to enable SystemVerilog parsing and select the 2012 version of the language. + +=============================================================================== +vlog *ale-verilog-vlog* + +g:ale_verilog_vlog_executable *g:ale_verilog_vlog_executable* + *b:ale_verilog_vlog_executable* + Type: |String| + Default: `'vlog'` + + This variable can be changed to the path to the 'vlog' executable. + + +g:ale_verilog_vlog_options *g:ale_verilog_vlog_options* + *b:ale_verilog_vlog_options* + Type: |String| + Default: `'-quiet -lint'` + + This variable can be changed to modify the flags/options passed to 'vlog'. + + +=============================================================================== +xvlog *ale-verilog-xvlog* + +g:ale_verilog_xvlog_executable *g:ale_verilog_xvlog_executable* + *b:ale_verilog_xvlog_executable* + Type: |String| + Default: `'xvlog'` + + This variable can be changed to the path to the 'xvlog' executable. + + +g:ale_verilog_xvlog_options *g:ale_verilog_xvlog_options* + *b:ale_verilog_xvlog_options* + Type: |String| + Default: `''` + + This variable can be changed to modify the flags/options passed to 'xvlog'. + + =============================================================================== 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 6bedf755..44ddb2e2 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -14,19 +14,46 @@ CONTENTS *ale-contents* 5. Language Server Protocol Support.....|ale-lsp| 5.1 Completion........................|ale-completion| 5.2 Go To Definition..................|ale-go-to-definition| - 5.3 Find References...................|ale-find-references| - 5.4 Hovering..........................|ale-hover| - 5.5 Symbol Search.....................|ale-symbol-search| + 5.3 Go To Type Definition.............|ale-go-to-type-definition| + 5.4 Find References...................|ale-find-references| + 5.5 Hovering..........................|ale-hover| + 5.6 Symbol Search.....................|ale-symbol-search| 6. Global Options.......................|ale-options| 6.1 Highlights........................|ale-highlights| - 6.2 Options for write-good Linter.....|ale-write-good-options| - 7. Integration Documentation............|ale-integrations| + 7. Linter/Fixer Options.................|ale-integration-options| + 7.1 Options for alex..................|ale-alex-options| + 7.2 Options for write-good............|ale-write-good-options| + 7.3 Other Linter/Fixer Options........|ale-other-integration-options| + 8. Commands/Keybinds....................|ale-commands| + 9. API..................................|ale-api| + 10. Special Thanks......................|ale-special-thanks| + 11. Contact.............................|ale-contact| + +=============================================================================== +1. Introduction *ale-introduction* + +ALE provides the means to run linters asynchronously in Vim in a variety of +languages and tools. ALE sends the contents of buffers to linter programs +using the |job-control| features available in Vim 8 and NeoVim. For Vim 8, +Vim must be compiled with the |job| and |channel| and |timers| features +as a minimum. + +ALE supports the following key features for linting: + +1. Running linters when text is changed. +2. Running linters when files are opened. +3. Running linters when files are saved. (When a global flag is set.) +4. Populating the |loclist| with warning and errors. +5. Setting |signs| with warnings and errors for error markers. +6. Using |echo| to show error messages when the cursor moves. +7. Setting syntax highlights for errors. ada...................................|ale-ada-options| gcc.................................|ale-ada-gcc| ansible...............................|ale-ansible-options| ansible-lint........................|ale-ansible-ansible-lint| asciidoc..............................|ale-asciidoc-options| write-good..........................|ale-asciidoc-write-good| + textlint............................|ale-asciidoc-textlint| asm...................................|ale-asm-options| gcc.................................|ale-asm-gcc| awk...................................|ale-awk-options| @@ -52,6 +79,7 @@ CONTENTS *ale-contents* cfn-python-lint.....................|ale-cloudformation-cfn-python-lint| cmake.................................|ale-cmake-options| cmakelint...........................|ale-cmake-cmakelint| + cmake-format........................|ale-cmake-cmakeformat| cpp...................................|ale-cpp-options| clang...............................|ale-cpp-clang| clangd..............................|ale-cpp-clangd| @@ -138,6 +166,7 @@ CONTENTS *ale-contents* hfmt................................|ale-haskell-hfmt| hlint...............................|ale-haskell-hlint| stack-build.........................|ale-haskell-stack-build| + stack-ghc...........................|ale-haskell-stack-ghc| stylish-haskell.....................|ale-haskell-stylish-haskell| hie.................................|ale-haskell-hie| hcl...................................|ale-hcl-options| @@ -183,6 +212,7 @@ CONTENTS *ale-contents* languageserver......................|ale-kotlin-languageserver| latex.................................|ale-latex-options| write-good..........................|ale-latex-write-good| + textlint............................|ale-latex-textlint| less..................................|ale-less-options| lessc...............................|ale-less-lessc| prettier............................|ale-less-prettier| @@ -255,6 +285,7 @@ CONTENTS *ale-contents* cython..............................|ale-pyrex-cython| python................................|ale-python-options| autopep8............................|ale-python-autopep8| + bandit..............................|ale-python-bandit| black...............................|ale-python-black| flake8..............................|ale-python-flake8| isort...............................|ale-python-isort| @@ -263,6 +294,7 @@ CONTENTS *ale-contents* pycodestyle.........................|ale-python-pycodestyle| pydocstyle..........................|ale-python-pydocstyle| pyflakes............................|ale-python-pyflakes| + pylama..............................|ale-python-pylama| pylint..............................|ale-python-pylint| pyls................................|ale-python-pyls| pyre................................|ale-python-pyre| @@ -277,6 +309,7 @@ CONTENTS *ale-contents* ols.................................|ale-reasonml-ols| refmt...............................|ale-reasonml-refmt| restructuredtext......................|ale-restructuredtext-options| + textlint............................|ale-restructuredtext-textlint| write-good..........................|ale-restructuredtext-write-good| ruby..................................|ale-ruby-options| brakeman............................|ale-ruby-brakeman| @@ -319,6 +352,8 @@ CONTENTS *ale-contents* sqlfmt..............................|ale-sql-sqlfmt| stylus................................|ale-stylus-options| stylelint...........................|ale-stylus-stylelint| + sugarss...............................|ale-sugarss-options| + stylelint...........................|ale-sugarss-stylelint| tcl...................................|ale-tcl-options| nagelfar............................|ale-tcl-nagelfar| terraform.............................|ale-terraform-options| @@ -344,6 +379,12 @@ CONTENTS *ale-contents* verilog/systemverilog.................|ale-verilog-options| iverilog............................|ale-verilog-iverilog| verilator...........................|ale-verilog-verilator| + vlog................................|ale-verilog-vlog| + xvlog...............................|ale-verilog-xvlog| + vhdl..................................|ale-vhdl-options| + ghdl................................|ale-vhdl-ghdl| + vcom................................|ale-vhdl-vcom| + xvhdl...............................|ale-vhdl-xvhdl| vim...................................|ale-vim-options| vint................................|ale-vim-vint| vim help..............................|ale-vim-help-options| @@ -361,29 +402,6 @@ CONTENTS *ale-contents* 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| - 11. Contact.............................|ale-contact| - -=============================================================================== -1. Introduction *ale-introduction* - -ALE provides the means to run linters asynchronously in Vim in a variety of -languages and tools. ALE sends the contents of buffers to linter programs -using the |job-control| features available in Vim 8 and NeoVim. For Vim 8, -Vim must be compiled with the |job| and |channel| and |timers| features -as a minimum. - -ALE supports the following key features for linting: - -1. Running linters when text is changed. -2. Running linters when files are opened. -3. Running linters when files are saved. (When a global flag is set.) -4. Populating the |loclist| with warning and errors. -5. Setting |signs| with warnings and errors for error markers. -6. Using |echo| to show error messages when the cursor moves. -7. Setting syntax highlights for errors. ALE can fix problems with files with the |ALEFix| command, using the same job control functionality used for checking for problems. Try using the @@ -396,124 +414,8 @@ developer documentation. See |ale-development| =============================================================================== 2. Supported Languages & Tools *ale-support* -The following languages and tools are supported. - -Notes: - -`^` No linters for text or Vim help filetypes are enabled by default. -`!!` These linters check only files on disk. See |ale-lint-file-linters| - -* Ada: `gcc` -* ASM: `gcc` -* Ansible: `ansible-lint` -* API Blueprint: `drafter` -* AsciiDoc: `alex`!!, `proselint`, `redpen`, `write-good`, `vale` -* Awk: `gawk` -* Bash: `language-server`, `shell` (-n flag), `shellcheck`, `shfmt` -* BibTeX: `bibclean` -* Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` -* C: `cppcheck`, `cpplint`!!, `clang`, `clangd`, `clangtidy`!!, `clang-format`, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` -* C++ (filetype cpp): `clang`, `clangd`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `clazy`!!, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc`, `uncrustify`, `ccls` -* CUDA: `nvcc`!! -* C#: `mcs`, `mcsc`!!, `uncrustify` -* Chef: `foodcritic` -* Clojure: `joker` -* CloudFormation: `cfn-python-lint` -* CMake: `cmakelint` -* CoffeeScript: `coffee`, `coffeelint` -* Crystal: `crystal`!! -* CSS: `csslint`, `prettier`, `stylelint` -* Cucumber: `cucumber` -* Cython (pyrex filetype): `cython` -* D: `dls`, `dmd`, `uncrustify` -* Dafny: `dafny`!! -* Dart: `dartanalyzer`!!, `language_server`, dartfmt!! -* Dockerfile: `dockerfile_lint`, `hadolint` -* Elixir: `credo`, `dialyxir`, `dogma`, `mix`!!, `elixir-ls` -* Elm: `elm-format, elm-make` -* Erb: `erb`, `erubi`, `erubis`, `ruumba` -* Erlang: `erlc`, `SyntaxErl` -* Fish: `fish` (-n flag) -* Fortran: `gcc`, `language_server` -* Fountain: `proselint` -* FusionScript: `fusion-lint` -* Git Commit Messages: `gitlint` -* GLSL: glslang, `glslls` -* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!, `bingo` -* GraphQL: `eslint`, `gqlint`, `prettier` -* Hack: `hack`, `hackfmt`, `hhast` -* Haml: `haml-lint` -* Handlebars: `ember-template-lint` -* Haskell: `brittany`, `ghc`, `cabal-ghc`, `stylish-haskell`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `hlint`, `hdevtools`, `hfmt`, `hie` -* HCL: `terraform-fmt` -* HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `prettier`, `write-good` -* Idris: `idris` -* ISPC: `ispc`!! -* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`, `javalsp`, `uncrustify` -* JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo` -* JSON: `fixjson`, `jsonlint`, `jq`, `prettier` -* Julia: `languageserver` -* Kotlin: `kotlinc`!!, `ktlint`!!, `languageserver` -* LaTeX (tex): `alex`!!, `chktex`, `lacheck`, `proselint`, `redpen`, `vale`, `write-good` -* Less: `lessc`, `prettier`, `stylelint` -* LLVM: `llc` -* Lua: `luac`, `luacheck` -* Mail: `alex`!!, `proselint`, `vale` -* Make: `checkmake` -* Markdown: `alex`!!, `markdownlint`!!, `mdl`, `prettier`, `proselint`, `redpen`, `remark-lint`, `textlint`, `vale`, `write-good` -* MATLAB: `mlint` -* Mercury: `mmc`!! -* NASM: `nasm`!! -* Nim: `nim check`!! -* nix: `nix-instantiate` -* nroff: `alex`!!, `proselint`, `write-good` -* Objective-C: `clang`, `clangd`, `uncrustify`, `ccls` -* Objective-C++: `clang`, `clangd`, `uncrustify` -* OCaml: `merlin` (see |ale-ocaml-merlin|), `ols`, `ocamlformat` -* Pawn: `uncrustify` -* Perl: `perl -c`, `perl-critic`, `perltidy` -* Perl6: `perl6 -c` -* PHP: `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer`, `psalm`!! -* PO: `alex`!!, `msgfmt`, `proselint`, `write-good` -* Pod: `alex`!!, `proselint`, `write-good` -* Pony: `ponyc` -* Prolog: `swipl` -* proto: `protoc-gen-lint` -* Pug: `pug-lint` -* Puppet: `languageserver`, `puppet`, `puppet-lint` -* Python: `autopep8`, `black`, `flake8`, `isort`, `mypy`, `prospector`, `pycodestyle`, `pydocstyle`, `pyls`, `pyre`, `pylint`!!, `vulture`!!, `yapf` -* QML: `qmlfmt`, `qmllint` -* R: `lintr` -* ReasonML: `merlin`, `ols`, `refmt` -* reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good` -* Re:VIEW: `redpen` -* RPM spec: `rpmlint` -* Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`, `solargraph`, `standardrb` -* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt` -* SASS: `sass-lint`, `stylelint` -* SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint` -* Scala: `fsc`, `sbtserver`, `scalac`, `scalafmt`, `scalastyle` -* Slim: `slim-lint` -* SML: `smlnj` -* Solidity: `solhint`, `solium` -* Stylus: `stylelint` -* SQL: `sqlint`, `sqlfmt` -* Swift: `swiftlint`, `swiftformat` -* Tcl: `nagelfar`!! -* Terraform: `fmt`, `tflint` -* Texinfo: `alex`!!, `proselint`, `write-good` -* Text^: `alex`!!, `proselint`, `redpen`, `textlint`, `vale`, `write-good` -* Thrift: `thrift` -* TypeScript: `eslint`, `prettier`, `tslint`, `tsserver`, `typecheck` -* VALA: `uncrustify` -* Verilog: `iverilog`, `verilator` -* Vim: `vint` -* Vim help^: `alex`!!, `proselint`, `write-good` -* Vue: `prettier`, `vls` -* XHTML: `alex`!!, `proselint`, `write-good` -* XML: `xmllint` -* YAML: `prettier`, `swaglint`, `yamllint` -* YANG: `yang-lsp` +ALE supports a wide variety of languages and tools. See |ale-supported-list| +for the full list. =============================================================================== 3. Linting *ale-lint* @@ -676,14 +578,10 @@ The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or for a function set in the ALE fixer registry. Each function for fixing errors must accept either one argument `(buffer)` or -three arguments `(buffer, done, lines)`, representing the buffer being fixed, -a function to call with results, and the lines to fix. The functions must -return either `0`, for changing nothing, a |List| for new lines to set, a -|Dictionary| for describing a command to be run in the background, or `v:true` -for indicating that results will be provided asynchronously via the `done` -callback. - -NOTE: The `done` function has not been implemented yet. +two arguments `(buffer, lines)`, representing the buffer being fixed and the +lines to fix. The functions must return either `0`, for changing nothing, a +|List| for new lines to set, a |Dictionary| for describing a command to be +run in the background, or the result of |ale#command#Run()|. Functions receiving a variable number of arguments will not receive the second argument `lines`. Functions should name two arguments if the `lines` argument @@ -713,26 +611,6 @@ are supported for running the commands. A |List| of |String|s must be returned. - `chain_with` An optional key for defining a callback to call next. - - The callback must accept two or three arguments, - `(buffer, output)` or `(buffer, output, input)` . - Functions receiving a variable number of arguments will - only receive the first two values. The `output` argument - will contain the lines of output from the command run. - The `input` argument is the List of lines for the - buffer, after applying any previous fixers. - - The callback must return the same values returned for - any fixer function. This allows fixer functions to be - chained recursively. - - When the command string returned for a fixer is an empty - string, the next command in the chain will still be run. - This allows commands to be skipped, like version checks - that are cached. An empty List will be passed to the - next callback in the chain for the `output`. - `read_buffer` An optional key for disabling reading the buffer. When set to `0`, ALE will not pipe the buffer's data @@ -740,10 +618,7 @@ are supported for running the commands. the buffer is not read when `read_temporary_file` is `1`. - This option defaults to `0` when `chain_with` is defined - as anything other than `v:null`, and defaults to `1` - otherwise. This is so earlier commands in a chain - do not receive the buffer's data by default. + This option defaults to `1`. *ale-fix-configuration* @@ -847,9 +722,23 @@ information returned by LSP servers. The following commands are supported: |ALEGoToDefinitionInSplit| - The same, but in a new split. |ALEGoToDefinitionInVSplit| - The same, but in a new vertical split. +------------------------------------------------------------------------------- +5.3 Go To Type Definition *ale-go-to-type-definition* + +ALE supports jumping to the files and locations where symbols' types are +defined through any enabled LSP linters. The locations ALE will jump to depend +on the information returned by LSP servers. The following commands are +supported: + +|ALEGoToTypeDefinition| - Open the definition of the symbol's type under + the cursor. +|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab. +|ALEGoToTypeDefinitionInSplit| - The same, but in a new split. +|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split. + ------------------------------------------------------------------------------- -5.3 Find References *ale-find-references* +5.4 Find References *ale-find-references* ALE supports finding references for symbols though any enabled LSP linters. ALE will display a preview window showing the places where a symbol is @@ -858,9 +747,11 @@ supported: |ALEFindReferences| - Find references for the word under the cursor. +Options: + `-relative` Show file paths in the results relative to the working dir ------------------------------------------------------------------------------- -5.4 Hovering *ale-hover* +5.5 Hovering *ale-hover* ALE supports "hover" information for printing brief information about symbols at the cursor taken from LSP linters. The following commands are supported: @@ -891,13 +782,15 @@ Documentation for symbols at the cursor can be retrieved using the |ALEDocumentation| command. This command is only available for `tsserver`. ------------------------------------------------------------------------------- -5.5 Symbol Search *ale-symbol-search* +5.6 Symbol Search *ale-symbol-search* ALE supports searching for workspace symbols via LSP linters. The following commands are supported: |ALESymbolSearch| - Search for symbols in the workspace. +Options: + `-relative` Show file paths in the results relative to the working dir =============================================================================== 6. Global Options *ale-options* @@ -1554,6 +1447,22 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format* The strings for configuring `%severity%` are also used for this option. +g:ale_lsp_root *g:ale_lsp_root* +b:ale_lsp_root *b:ale_lsp_root* + + Type: |Dictionary| or |String| + Default: {} + + This option is used to determine the project root for the LSP linter. If the + value is a |Dictionary|, it maps a linter to either a string containing the + project root or a |Funcref| to call to look up the root. The funcref is + provided the buffer number as its argument. + + The buffer-specific variable may additionally be a string containing the + project root itself. + + If neither variable yields a result, a linter-specific function is invoked to + detect a project root. If this, too, yields no result, the linter is disabled. g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* @@ -2170,11 +2079,67 @@ ALEWarningSign *ALEWarningSign* The highlight for warning signs. See |g:ale_set_signs|. -------------------------------------------------------------------------------- -6.2. Options for write-good *ale-write-good-options* +=============================================================================== +7. Linter/Fixer Options *ale-integration-options* -The options for the write-good linter are global because it does not make -sense to have them specified on a per-language basis. +Linter and fixer options are documented below and in individual help files. + +Every option for programs can be set globally, or individually for each +buffer. For example, `b:ale_python_flake8_executable` will override any +values set for `g:ale_python_flake8_executable`. + + *ale-integrations-local-executables* + +Some tools will prefer to search for locally-installed executables, unless +configured otherwise. For example, the `eslint` linter will search for +various executable paths in `node_modules`. The `flake8` linter will search +for virtualenv directories. + +If you prefer to use global executables for those tools, set the relevant +`_use_global` and `_executable` options for those linters. > + + " Use the global executable with a special name for eslint. + let g:ale_javascript_eslint_executable = 'special-eslint' + let g:ale_javascript_eslint_use_global = 1 + + " Use the global executable with a special name for flake8. + let g:ale_python_flake8_executable = '/foo/bar/flake8' + let g:ale_python_flake8_use_global = 1 +< +|g:ale_use_global_executables| can be set to `1` in your vimrc file to make +ALE use global executables for all linters by default. + +The option |g:ale_virtualenv_dir_names| controls the local virtualenv paths +ALE will use to search for Python executables. + + +------------------------------------------------------------------------------- +7.1. Options for alex *ale-alex-options* + +The options for `alex` are shared between all filetypes, so options can be +configured once. + +g:ale_alex_executable *g:ale_alex_executable* + *b:ale_alex_executable* + Type: |String| + Default: `'alex'` + + See |ale-integrations-local-executables| + + +g:ale_alex_use_global *g:ale_alex_use_global* + *b:ale_alex_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.2. Options for write-good *ale-write-good-options* + +The options for `write-good` are shared between all filetypes, so options can +be configured once. g:ale_writegood_executable *g:ale_writegood_executable* *b:ale_writegood_executable* @@ -2200,40 +2165,367 @@ g:ale_writegood_use_global *g:ale_writegood_use_global* See |ale-integrations-local-executables| -=============================================================================== -7. Integration Documentation *ale-integrations* +------------------------------------------------------------------------------- +7.3. Other Linter/Fixer Options *ale-other-integration-options* -Linter and fixer options are documented in individual help files. See the -table of contents at |ale-contents|. +ALE supports a very wide variety of tools. Other linter or fixer options are +documented in additional help files. -Every option for programs can be set globally, or individually for each -buffer. For example, `b:ale_python_flake8_executable` will override any -values set for `g:ale_python_flake8_executable`. - - *ale-integrations-local-executables* - -Some tools will prefer to search for locally-installed executables, unless -configured otherwise. For example, the `eslint` linter will search for -various executable paths in `node_modules`. The `flake8` linter will search -for virtualenv directories. - -If you prefer to use global executables for those tools, set the relevant -`_use_global` and `_executable` options for those linters. > - - " Use the global executable with a special name for eslint. - let g:ale_javascript_eslint_executable = 'special-eslint' - let g:ale_javascript_eslint_use_global = 1 - - " Use the global executable with a special name for flake8. - let g:ale_python_flake8_executable = '/foo/bar/flake8' - let g:ale_python_flake8_use_global = 1 -< - -|g:ale_use_global_executables| can be set to `1` in your vimrc file to make -ALE use global executables for all linters by default. - -The option |g:ale_virtualenv_dir_names| controls the local virtualenv paths -ALE will use to search for Python executables. + ada.....................................|ale-ada-options| + gcc...................................|ale-ada-gcc| + ansible.................................|ale-ansible-options| + ansible-lint..........................|ale-ansible-ansible-lint| + asciidoc................................|ale-asciidoc-options| + write-good............................|ale-asciidoc-write-good| + textlint..............................|ale-asciidoc-textlint| + asm.....................................|ale-asm-options| + gcc...................................|ale-asm-gcc| + awk.....................................|ale-awk-options| + gawk..................................|ale-awk-gawk| + bib.....................................|ale-bib-options| + bibclean..............................|ale-bib-bibclean| + c.......................................|ale-c-options| + clang.................................|ale-c-clang| + clangd................................|ale-c-clangd| + clang-format..........................|ale-c-clangformat| + clangtidy.............................|ale-c-clangtidy| + cppcheck..............................|ale-c-cppcheck| + cquery................................|ale-c-cquery| + flawfinder............................|ale-c-flawfinder| + gcc...................................|ale-c-gcc| + uncrustify............................|ale-c-uncrustify| + ccls..................................|ale-c-ccls| + chef....................................|ale-chef-options| + foodcritic............................|ale-chef-foodcritic| + clojure.................................|ale-clojure-options| + joker.................................|ale-clojure-joker| + cloudformation..........................|ale-cloudformation-options| + cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| + cmake...................................|ale-cmake-options| + cmakelint.............................|ale-cmake-cmakelint| + cmake-format..........................|ale-cmake-cmakeformat| + 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| + flawfinder............................|ale-cpp-flawfinder| + gcc...................................|ale-cpp-gcc| + uncrustify............................|ale-cpp-uncrustify| + ccls..................................|ale-cpp-ccls| + c#......................................|ale-cs-options| + mcs...................................|ale-cs-mcs| + mcsc..................................|ale-cs-mcsc| + uncrustify............................|ale-cs-uncrustify| + css.....................................|ale-css-options| + prettier..............................|ale-css-prettier| + stylelint.............................|ale-css-stylelint| + cuda....................................|ale-cuda-options| + nvcc..................................|ale-cuda-nvcc| + d.......................................|ale-d-options| + dls...................................|ale-d-dls| + uncrustify............................|ale-d-uncrustify| + dart....................................|ale-dart-options| + dartanalyzer..........................|ale-dart-dartanalyzer| + dartfmt...............................|ale-dart-dartfmt| + dockerfile..............................|ale-dockerfile-options| + dockerfile_lint.......................|ale-dockerfile-dockerfile_lint| + hadolint..............................|ale-dockerfile-hadolint| + elixir..................................|ale-elixir-options| + mix...................................|ale-elixir-mix| + mix_format............................|ale-elixir-mix-format| + dialyxir..............................|ale-elixir-dialyxir| + elixir-ls.............................|ale-elixir-elixir-ls| + elm.....................................|ale-elm-options| + elm-format............................|ale-elm-elm-format| + elm-make..............................|ale-elm-elm-make| + erlang..................................|ale-erlang-options| + erlc..................................|ale-erlang-erlc| + syntaxerl.............................|ale-erlang-syntaxerl| + eruby...................................|ale-eruby-options| + ruumba................................|ale-eruby-ruumba| + fish....................................|ale-fish-options| + fortran.................................|ale-fortran-options| + gcc...................................|ale-fortran-gcc| + language_server.......................|ale-fortran-language-server| + fountain................................|ale-fountain-options| + fusionscript............................|ale-fuse-options| + fusion-lint...........................|ale-fuse-fusionlint| + git commit..............................|ale-gitcommit-options| + gitlint...............................|ale-gitcommit-gitlint| + glsl....................................|ale-glsl-options| + glslang...............................|ale-glsl-glslang| + glslls................................|ale-glsl-glslls| + go......................................|ale-go-options| + gobuild...............................|ale-go-gobuild| + gofmt.................................|ale-go-gofmt| + golint................................|ale-go-golint| + govet.................................|ale-go-govet| + gometalinter..........................|ale-go-gometalinter| + staticcheck...........................|ale-go-staticcheck| + golangserver..........................|ale-go-golangserver| + golangci-lint.........................|ale-go-golangci-lint| + bingo.................................|ale-go-bingo| + 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| + brittany..............................|ale-haskell-brittany| + ghc...................................|ale-haskell-ghc| + ghc-mod...............................|ale-haskell-ghc-mod| + cabal-ghc.............................|ale-haskell-cabal-ghc| + hdevtools.............................|ale-haskell-hdevtools| + hfmt..................................|ale-haskell-hfmt| + hlint.................................|ale-haskell-hlint| + stack-build...........................|ale-haskell-stack-build| + stack-ghc.............................|ale-haskell-stack-ghc| + stylish-haskell.......................|ale-haskell-stylish-haskell| + hie...................................|ale-haskell-hie| + hcl.....................................|ale-hcl-options| + terraform-fmt.........................|ale-hcl-terraform-fmt| + html....................................|ale-html-options| + htmlhint..............................|ale-html-htmlhint| + tidy..................................|ale-html-tidy| + prettier..............................|ale-html-prettier| + stylelint.............................|ale-html-stylelint| + write-good............................|ale-html-write-good| + idris...................................|ale-idris-options| + idris.................................|ale-idris-idris| + ispc....................................|ale-ispc-options| + ispc..................................|ale-ispc-ispc| + java....................................|ale-java-options| + checkstyle............................|ale-java-checkstyle| + javac.................................|ale-java-javac| + google-java-format....................|ale-java-google-java-format| + pmd...................................|ale-java-pmd| + javalsp...............................|ale-java-javalsp| + uncrustify............................|ale-java-uncrustify| + javascript..............................|ale-javascript-options| + eslint................................|ale-javascript-eslint| + flow..................................|ale-javascript-flow| + importjs..............................|ale-javascript-importjs| + jscs..................................|ale-javascript-jscs| + jshint................................|ale-javascript-jshint| + prettier..............................|ale-javascript-prettier| + prettier-eslint.......................|ale-javascript-prettier-eslint| + prettier-standard.....................|ale-javascript-prettier-standard| + standard..............................|ale-javascript-standard| + xo....................................|ale-javascript-xo| + json....................................|ale-json-options| + fixjson...............................|ale-json-fixjson| + jsonlint..............................|ale-json-jsonlint| + jq....................................|ale-json-jq| + prettier..............................|ale-json-prettier| + julia...................................|ale-julia-options| + languageserver........................|ale-julia-languageserver| + kotlin..................................|ale-kotlin-options| + kotlinc...............................|ale-kotlin-kotlinc| + ktlint................................|ale-kotlin-ktlint| + languageserver........................|ale-kotlin-languageserver| + latex...................................|ale-latex-options| + write-good............................|ale-latex-write-good| + textlint..............................|ale-latex-textlint| + less....................................|ale-less-options| + lessc.................................|ale-less-lessc| + prettier..............................|ale-less-prettier| + stylelint.............................|ale-less-stylelint| + llvm....................................|ale-llvm-options| + llc...................................|ale-llvm-llc| + lua.....................................|ale-lua-options| + luac..................................|ale-lua-luac| + luacheck..............................|ale-lua-luacheck| + markdown................................|ale-markdown-options| + mdl...................................|ale-markdown-mdl| + prettier..............................|ale-markdown-prettier| + remark-lint...........................|ale-markdown-remark-lint| + textlint..............................|ale-markdown-textlint| + write-good............................|ale-markdown-write-good| + mercury.................................|ale-mercury-options| + mmc...................................|ale-mercury-mmc| + nasm....................................|ale-nasm-options| + nasm..................................|ale-nasm-nasm| + nroff...................................|ale-nroff-options| + write-good............................|ale-nroff-write-good| + objc....................................|ale-objc-options| + clang.................................|ale-objc-clang| + clangd................................|ale-objc-clangd| + uncrustify............................|ale-objc-uncrustify| + ccls..................................|ale-objc-ccls| + objcpp..................................|ale-objcpp-options| + clang.................................|ale-objcpp-clang| + clangd................................|ale-objcpp-clangd| + uncrustify............................|ale-objcpp-uncrustify| + ocaml...................................|ale-ocaml-options| + merlin................................|ale-ocaml-merlin| + ols...................................|ale-ocaml-ols| + ocamlformat...........................|ale-ocaml-ocamlformat| + pawn....................................|ale-pawn-options| + uncrustify............................|ale-pawn-uncrustify| + perl....................................|ale-perl-options| + perl..................................|ale-perl-perl| + perlcritic............................|ale-perl-perlcritic| + perltidy..............................|ale-perl-perltidy| + perl6...................................|ale-perl6-options| + perl6.................................|ale-perl6-perl6| + php.....................................|ale-php-options| + langserver............................|ale-php-langserver| + phan..................................|ale-php-phan| + phpcbf................................|ale-php-phpcbf| + phpcs.................................|ale-php-phpcs| + phpmd.................................|ale-php-phpmd| + phpstan...............................|ale-php-phpstan| + psalm.................................|ale-php-psalm| + php-cs-fixer..........................|ale-php-php-cs-fixer| + php...................................|ale-php-php| + po......................................|ale-po-options| + write-good............................|ale-po-write-good| + pod.....................................|ale-pod-options| + write-good............................|ale-pod-write-good| + pony....................................|ale-pony-options| + ponyc.................................|ale-pony-ponyc| + prolog..................................|ale-prolog-options| + swipl.................................|ale-prolog-swipl| + proto...................................|ale-proto-options| + protoc-gen-lint.......................|ale-proto-protoc-gen-lint| + pug.....................................|ale-pug-options| + puglint...............................|ale-pug-puglint| + puppet..................................|ale-puppet-options| + puppet................................|ale-puppet-puppet| + puppetlint............................|ale-puppet-puppetlint| + puppet-languageserver.................|ale-puppet-languageserver| + pyrex (cython)..........................|ale-pyrex-options| + cython................................|ale-pyrex-cython| + python..................................|ale-python-options| + autopep8..............................|ale-python-autopep8| + bandit................................|ale-python-bandit| + black.................................|ale-python-black| + flake8................................|ale-python-flake8| + isort.................................|ale-python-isort| + mypy..................................|ale-python-mypy| + prospector............................|ale-python-prospector| + pycodestyle...........................|ale-python-pycodestyle| + pydocstyle............................|ale-python-pydocstyle| + pyflakes..............................|ale-python-pyflakes| + pylama................................|ale-python-pylama| + pylint................................|ale-python-pylint| + pyls..................................|ale-python-pyls| + pyre..................................|ale-python-pyre| + vulture...............................|ale-python-vulture| + yapf..................................|ale-python-yapf| + qml.....................................|ale-qml-options| + qmlfmt................................|ale-qml-qmlfmt| + r.......................................|ale-r-options| + lintr.................................|ale-r-lintr| + reasonml................................|ale-reasonml-options| + merlin................................|ale-reasonml-merlin| + ols...................................|ale-reasonml-ols| + refmt.................................|ale-reasonml-refmt| + restructuredtext........................|ale-restructuredtext-options| + textlint..............................|ale-restructuredtext-textlint| + write-good............................|ale-restructuredtext-write-good| + ruby....................................|ale-ruby-options| + brakeman..............................|ale-ruby-brakeman| + rails_best_practices..................|ale-ruby-rails_best_practices| + reek..................................|ale-ruby-reek| + rubocop...............................|ale-ruby-rubocop| + ruby..................................|ale-ruby-ruby| + rufo..................................|ale-ruby-rufo| + solargraph............................|ale-ruby-solargraph| + standardrb............................|ale-ruby-standardrb| + rust....................................|ale-rust-options| + cargo.................................|ale-rust-cargo| + rls...................................|ale-rust-rls| + rustc.................................|ale-rust-rustc| + rustfmt...............................|ale-rust-rustfmt| + sass....................................|ale-sass-options| + sasslint..............................|ale-sass-sasslint| + stylelint.............................|ale-sass-stylelint| + scala...................................|ale-scala-options| + sbtserver.............................|ale-scala-sbtserver| + scalafmt..............................|ale-scala-scalafmt| + scalastyle............................|ale-scala-scalastyle| + scss....................................|ale-scss-options| + prettier..............................|ale-scss-prettier| + sasslint..............................|ale-scss-sasslint| + stylelint.............................|ale-scss-stylelint| + sh......................................|ale-sh-options| + sh-language-server....................|ale-sh-language-server| + shell.................................|ale-sh-shell| + shellcheck............................|ale-sh-shellcheck| + shfmt.................................|ale-sh-shfmt| + sml.....................................|ale-sml-options| + smlnj.................................|ale-sml-smlnj| + solidity................................|ale-solidity-options| + solhint...............................|ale-solidity-solhint| + solium................................|ale-solidity-solium| + spec....................................|ale-spec-options| + rpmlint...............................|ale-spec-rpmlint| + sql.....................................|ale-sql-options| + sqlfmt................................|ale-sql-sqlfmt| + stylus..................................|ale-stylus-options| + stylelint.............................|ale-stylus-stylelint| + sugarss.................................|ale-sugarss-options| + stylelint.............................|ale-sugarss-stylelint| + tcl.....................................|ale-tcl-options| + nagelfar..............................|ale-tcl-nagelfar| + terraform...............................|ale-terraform-options| + fmt...................................|ale-terraform-fmt| + tflint................................|ale-terraform-tflint| + tex.....................................|ale-tex-options| + chktex................................|ale-tex-chktex| + lacheck...............................|ale-tex-lacheck| + texinfo.................................|ale-texinfo-options| + write-good............................|ale-texinfo-write-good| + text....................................|ale-text-options| + textlint..............................|ale-text-textlint| + write-good............................|ale-text-write-good| + thrift..................................|ale-thrift-options| + thrift................................|ale-thrift-thrift| + typescript..............................|ale-typescript-options| + eslint................................|ale-typescript-eslint| + prettier..............................|ale-typescript-prettier| + tslint................................|ale-typescript-tslint| + tsserver..............................|ale-typescript-tsserver| + vala....................................|ale-vala-options| + uncrustify............................|ale-vala-uncrustify| + verilog/systemverilog...................|ale-verilog-options| + iverilog..............................|ale-verilog-iverilog| + verilator.............................|ale-verilog-verilator| + vlog..................................|ale-verilog-vlog| + xvlog.................................|ale-verilog-xvlog| + vhdl....................................|ale-vhdl-options| + ghdl..................................|ale-vhdl-ghdl| + vcom..................................|ale-vhdl-vcom| + xvhdl.................................|ale-vhdl-xvhdl| + vim.....................................|ale-vim-options| + vint..................................|ale-vim-vint| + vim help................................|ale-vim-help-options| + write-good............................|ale-vim-help-write-good| + vue.....................................|ale-vue-options| + prettier..............................|ale-vue-prettier| + vls...................................|ale-vue-vls| + xhtml...................................|ale-xhtml-options| + write-good............................|ale-xhtml-write-good| + 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| =============================================================================== @@ -2326,6 +2618,45 @@ ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit* command. +ALEGoToTypeDefinition *ALEGoToTypeDefinition* + + This works similar to |ALEGoToDefinition| but instead jumps to the + definition of a type of a symbol under the cursor. ALE will jump to a + definition if an LSP server provides a location to jump to. Otherwise, ALE + will do nothing. + + You can jump back to the position you were at before going to the definition + of something with jump motions like CTRL-O. See |jump-motions|. + + A plug mapping `(ale_go_to_type_definition)` is defined for this + command. + + +ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab* + + The same as |ALEGoToTypeDefinition|, but opens results in a new tab. + + A plug mapping `(ale_go_to_type_definition_in_tab)` is defined for + this command. + + +ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit* + + The same as |ALEGoToTypeDefinition|, but opens results in a new split. + + A plug mapping `(ale_go_to_type_definition_in_split)` is defined for + this command. + + +ALEGoToTypeDefinitionInVSplit *ALEGoToTypeDefinitionInVSplit* + + The same as |ALEGoToTypeDefinition|, but opens results in a new vertical + split. + + A plug mapping `(ale_go_to_type_definition_in_vsplit)` is defined for + this command. + + ALEHover *ALEHover* Print brief information about the symbol under the cursor, taken from any @@ -2374,14 +2705,36 @@ ALELast *ALELast* `ALEPreviousWrap` and `ALENextWrap` will wrap around the file to find the last or first warning or error in the file, respectively. + `ALEPrevious` and `ALENext` take optional flags arguments to custom their + behaviour : + `-wrap` enable wrapping around the file + `-error`, `-warning` and `-info` enable jumping to errors, warnings or infos + respectively, ignoring anything else. They are mutually exclusive and if + several are provided the priority is the following: error > warning > info. + `-style` and `-nostyle` allow you to jump respectively to style error or + warning and to not style error or warning. They also are mutually + exclusive and nostyle has priority over style. + + Flags can be combined to create create custom jumping. Thus you can use + ":ALENext -wrap -error -nosyle" to jump to the next error which is not a + style error while going back to the begining of the file if needed. + `ALEFirst` goes to the first error or warning in the buffer, while `ALELast` goes to the last one. The following || mappings are defined for the commands: > (ale_previous) - ALEPrevious (ale_previous_wrap) - ALEPreviousWrap + (ale_previous_error) - ALEPrevious -error + (ale_previous_wrap_error) - ALEPrevious -wrap -error + (ale_previous_warning) - ALEPrevious -warning + (ale_previous_wrap_warning) - ALEPrevious -wrap -warning (ale_next) - ALENext (ale_next_wrap) - ALENextWrap + (ale_next_error) - ALENext -error + (ale_next_wrap_error) - ALENext -wrap -error + (ale_next_warning) - ALENext -warning + (ale_next_wrap_warning) - ALENext -wrap -warning (ale_first) - ALEFirst (ale_last) - ALELast < @@ -2541,26 +2894,105 @@ ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* is broken, or when developing ALE itself. -ale#engine#CreateDirectory(buffer) *ale#engine#CreateDirectory()* +ale#command#CreateDirectory(buffer) *ale#command#CreateDirectory()* Create a new temporary directory with a unique name, and manage that - directory with |ale#engine#ManageDirectory()|, so it will be removed as soon + directory with |ale#command#ManageDirectory()|, so it will be removed as soon as possible. It is advised to only call this function from a callback function for returning a linter command to run. -ale#engine#CreateFile(buffer) *ale#engine#CreateFile()* +ale#command#CreateFile(buffer) *ale#command#CreateFile()* Create a new temporary file with a unique name, and manage that file with - |ale#engine#ManageFile()|, so it will be removed as soon as possible. + |ale#command#ManageFile()|, so it will be removed as soon as possible. It is advised to only call this function from a callback function for returning a linter command to run. -ale#engine#EscapeCommandPart(command_part) *ale#engine#EscapeCommandPart()* +ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* + + Start running a job in the background, and pass the results to the given + callback later. + + This function can be used for computing the results of ALE linter or fixer + functions asynchronously with jobs. `buffer` must match the buffer being + linted or fixed, `command` must be a |String| for a shell command to + execute, `callback` must be defined as a |Funcref| to call later with the + results, and an optional |Dictionary| of `options` can be provided. + + The `callback` will receive the arguments `(buffer, output, metadata)`, + where the `buffer` will match the buffer given to the function, the `output` + will be a `List` of lines of output from the job that was run, and the + `metadata` will be a |Dictionary| with additional information about the job + that was run, including: + + `exit_code` - A |Number| with the exit code for the program that was run. + + The result of this function is either a special |Dictionary| ALE will use + for waiting for the command to finish, or `0` if the job is not started. The + The return value of the `callback` will be used as the eventual result for + whatever value is being given to ALE. For example: > + + function! s:GetCommand(buffer, output, meta) abort + " Do something with a:output here, from the foo command. + + " This is used as the command to run for linting. + return 'final command' + endfunction + + " ... + + 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} +< + The result of a callback can also be the result of another call to this + function, so that several commands can be arbitrarily chained together. For + example: > + + function! s:GetAnotherCommand(buffer, output, meta) abort + " We can finally return this command. + return 'last command' + endfunction + + function! s:GetCommand(buffer, output, meta) abort + " We can return another deferred result. + return ale#command#Run( + \ a:buffer, + \ 'second command', + \ function('s:GetAnotherCommand') + \) + endfunction + + " ... + + 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} +< + + The following `options` can be provided. + + `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for + selecting which output streams to read lines from. + + The default is `'stdout'` + + `executable` - An executable for formatting into `%e` in the command. + If this option is not provided, formatting commands with + `%e` will not work. + + `read_buffer` - If set to `1`, the buffer will be piped into the + command. + + The default is `0`. + + `input` - When creating temporary files with `%t` or piping text + into a command `input` can be set to a |List| of text to + use instead of the buffer's text. + + +ale#command#EscapeCommandPart(command_part) *ale#command#EscapeCommandPart()* Given a |String|, return a |String| with all `%` characters replaced with `%%` instead. This function can be used to escape strings which are @@ -2569,6 +3001,35 @@ ale#engine#EscapeCommandPart(command_part) *ale#engine#EscapeCommandPart()* specially. +ale#command#ManageDirectory(buffer, directory) *ale#command#ManageDirectory()* + + Like |ale#command#ManageFile()|, but directories and all of their contents + will be deleted, akin to `rm -rf directory`, which could lead to loss of + data if mistakes are made. This command will also delete any temporary + filenames given to it. + + It is advised to use |ale#command#ManageFile()| instead for deleting single + files. + + +ale#command#ManageFile(buffer, filename) *ale#command#ManageFile()* + + Given a buffer number for a buffer currently running some linting or fixing + tasks and a filename, register a filename with ALE for automatic deletion + after linting or fixing is complete, or when Vim exits. + + If Vim exits suddenly, ALE will try its best to remove temporary files, but + ALE cannot guarantee with absolute certainty that the files will be removed. + It is advised to create temporary files in the operating system's managed + temporary file directory, such as with |tempname()|. + + Directory names should not be given to this function. ALE will only delete + files and symlinks given to this function. This is to prevent entire + directories from being accidentally deleted, say in cases of writing + `dir . '/' . filename` where `filename` is actually `''`, etc. ALE instead + manages directories separately with the |ale#command#ManageDirectory| function. + + ale#engine#GetLoclist(buffer) *ale#engine#GetLoclist()* Given a buffer number, this function will return the list of problems @@ -2585,35 +3046,6 @@ ale#engine#IsCheckingBuffer(buffer) *ale#engine#IsCheckingBuffer()* This function can be used for status lines, tab names, etc. -ale#engine#ManageFile(buffer, filename) *ale#engine#ManageFile()* - - Given a buffer number for a buffer currently running some linting tasks - and a filename, register a filename with ALE for automatic deletion after - linting is complete, or when Vim exits. - - If Vim exits suddenly, ALE will try its best to remove temporary files, but - ALE cannot guarantee with absolute certainty that the files will be removed. - It is advised to create temporary files in the operating system's managed - temporary file directory, such as with |tempname()|. - - Directory names should not be given to this function. ALE will only delete - files and symlinks given to this function. This is to prevent entire - directories from being accidentally deleted, say in cases of writing - `dir . '/' . filename` where `filename` is actually `''`, etc. ALE instead - manages directories separetly with the |ale#engine#ManageDirectory| function. - - -ale#engine#ManageDirectory(buffer, directory) *ale#engine#ManageDirectory()* - - Like |ale#engine#ManageFile()|, but directories and all of their contents - will be deleted, akin to `rm -rf directory`, which could lead to loss of - data if mistakes are made. This command will also delete any temporary - filenames given to it. - - It is advised to use |ale#engine#ManageFile()| instead for deleting single - files. - - ale#fix#registry#Add(name, func, filetypes, desc, [aliases]) *ale#fix#registry#Add()* @@ -2703,7 +3135,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* and have been checked at least once. Temporary files in directories used for Vim - temporary files with `tempname()` will be asssumed + temporary files with `tempname()` will be assumed to be the buffer being checked, unless the `bufnr` key is also set with a valid number for some other buffer. @@ -2726,74 +3158,30 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* 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. + will be run, or a |Funcref| for a function to call + for computing the executable, accepting a buffer + number. - Either this or the `executable_callback` argument - must be provided. + The result can be computed with |ale#command#Run()|. - `executable_callback ` A |String| or |Funcref| for a callback function - accepting a buffer number. A |String| should be - returned for the executable to check. This can be - used in place of `executable` when more complicated - processing is needed. + This value will be used to check if the program + requested is installed or not. + + If an `executable` is not defined, the command will + be run without checking if a program is executable + first. Defining an executable path is recommended to + avoid starting too many processes. + + `command` A |String| for a command to run asynchronously, or a + |Funcref| for a function to call for computing the + command, accepting a buffer number. + + The result can be computed with |ale#command#Run()|. - `command` A |String| for an executable to run asynchronously. This command will be fed the lines from the buffer to check, and will produce the lines of output given to the `callback`. - `command_callback` A |String| or |Funcref| for a callback function - accepting a buffer number. A |String| should be - returned for a command to run. This can be used in - place of `command` when more complicated processing - is needed. - - If an empty string is returned from the callback, - no jobs for linting will be run for that linter. - This can be used for skipping a linter call, - say if no configuration file was found. - - *ale-command-chain* - `command_chain` A |List| of |Dictionary| items defining a series - of commands to be run. At least one |Dictionary| - should be provided. Each Dictionary must contain the - key `callback`, defining a |String| or |Funcref| for - a function returning a |String| for a command to run. - - The callback functions for each command after the - first command in in the chain should accept two - arguments `(buffer, output)`, a buffer number and a - |List| of lines of output from the previous command - in the chain. - - The first callback function in a chain accepts only - a `(buffer)` argument, as there are no previous - commands to run which return `output`. - - If an empty string is returned for a command in a - chain, that command in the chain will be skipped, - and the next function in the chain will be called - immediately instead. If the last command in a chain - returns an empty string, then no linting will be - performed. - - Commands in the chain will all use the - `output_stream` value provided in the root - |Dictionary|. Each command in the chain can also - provide an `output_stream` key to override this value. - See the `output_stream` description for more - information. - - Commands in the chain all behave as if `read_buffer` - is set to `0` by default, except for the last command - in the chain, which uses the value set for - `read_buffer` in the root |Dictionary|. Each command - in the chain can also provide a `read_buffer` key - to override these values. - See the `read_buffer` description for more - information. - `output_stream` A |String| for the output stream the lines of output should be read from for the command which is run. The accepted values are `'stdout'`, `'stderr'`, and @@ -2839,21 +3227,20 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* linter will be defined as an LSP linter which keeps a process for a language server running, and communicates with it directly via a |channel|. - `executable` or `executable_callback` must be set, - and `command` or `command_callback` must be set. + `executable` and `command` must be set. When this argument is set to `'socket'`, then the linter will be defined as an LSP linter via a TCP - socket connection. `address_callback` must be set - with a callback returning an address to connect to. + socket connection. `address` must be set. + ALE will not start a server automatically. - When this argument is not empty - `project_root_callback` must be defined. + When this argument is not empty `project_root` must + be defined. - `language` or `language_callback` can be defined to - describe the language for a file. The filetype will - be used as the language by default. + `language` can be defined to describe the language + for a file. The filetype will be used as the language + by default. LSP linters handle diagnostics automatically, so the `callback` argument must not be defined. @@ -2861,45 +3248,41 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* An optional `completion_filter` callback may be defined for filtering completion results. - An optional `initialization_options` or - `initialization_options_callback` may be defined to - pass initialization options to the LSP. + `initialization_options` may be defined to pass + initialization options to the LSP. - An optional `lsp_config` or `lsp_config_callback` may - be defined to pass configuration settings to the LSP. + `lsp_config` may be defined to pass configuration + settings to the LSP. - `address_callback` A |String| or |Funcref| for a callback function - accepting a buffer number. A |String| should be - returned with an address to connect to. + `address` A |String| representing an address to connect to, + or a |Funcref| accepting a buffer number and + returning the |String|. + + The result can be computed with |ale#command#Run()|. This argument must only be set if the `lsp` argument is set to `'socket'`. - `project_root_callback` A |String| or |Funcref| for a callback function - accepting a buffer number. A |String| should be - returned representing the path to the project for the - file being checked with the language server. If an - empty string is returned, the file will not be + `project_root` A |String| representing a path to the project for + the file being checked with the language server, or + a |Funcref| accepting a buffer number and returning + the |String|. + + If an empty string is returned, the file will not be checked at all. This argument must only be set if the `lsp` argument is also set to a non-empty string. `language` A |String| representing the name of the language - being checked. This string will be sent to the LSP to - tell it what type of language is being checked. + being checked, or a |Funcref| accepting a buffer + number and returning the |String|. This string will + be sent to the LSP to tell it what type of language + is being checked. - If this or `language_callback` isn't set, the - language will default to the value of the filetype - given to |ale#linter#Define|. - - `language_callback` A |String| or |Funcref| for a callback function - accepting a buffer number. A |String| should be - returned representing the name of the language being - checked. - - This option can be used instead of `language` if a - linter can check multiple languages. + If a language isn't provided, the language will + default to the value of the filetype given to + |ale#linter#Define|. `completion_filter` A |String| or |Funcref| for a callback function accepting a buffer number and a completion item. @@ -2917,38 +3300,24 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* setting can make it easier to guess the linter name by offering a few alternatives. - `initialization_options` A |Dictionary| of initialization options for LSPs. + `initialization_options` A |Dictionary| of initialization options for LSPs, + or a |Funcref| for a callback function accepting + a buffer number and returning the |Dictionary|. + This will be fed (as JSON) to the LSP in the initialize command. - `initialization_options_callback` - A |String| or |Funcref| for a callback function - accepting a buffer number. A |Dictionary| should be - returned for initialization options to pass the LSP. - This can be used in place of `initialization_options` - when more complicated processing is needed. + `lsp_config` A |Dictionary| for configuring a language server, + or a |Funcref| for a callback function accepting + a buffer number and returning the |Dictionary|. - `lsp_config` A |Dictionary| of configuration settings for LSPs. This will be fed (as JSON) to the LSP in the workspace/didChangeConfiguration command. - `lsp_config_callback` A |String| or |Funcref| for a callback function - accepting a buffer number. A |Dictionary| should be - returned for configuration settings to pass the LSP. - This can be used in place of `lsp_config` when more - complicated processing is needed. - - Only one of `command`, `command_callback`, or `command_chain` should be - specified. `command_callback` is generally recommended when a command string - needs to be generated dynamically, or any global options are used. - `command_chain` is recommended where any system calls need to be made to - retrieve some kind of information before running the final command. - If temporary files or directories are created for commands run with - `command_callback` or `command_chain`, then these tempoary files or - directories can be managed by ALE, for automatic deletion. - See |ale#engine#ManageFile()| and |ale#engine#ManageDirectory| for more - information. + `command`, then these temporary files or directories can be managed by ALE, + for automatic deletion. See |ale#command#ManageFile()| and + |ale#command#ManageDirectory| for more information. *ale-command-format-strings* @@ -2966,16 +3335,16 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* strings will reference the one temporary file. The temporary file will be created inside a temporary directory, and the entire temporary directory will be automatically deleted, following the behaviour of - |ale#engine#ManageDirectory|. This option can be used for some linters which + |ale#command#ManageDirectory|. This option can be used for some linters which do not support reading from stdin. For example: > 'command': 'ghc -fno-code -v0 %t', < Any substring `%e` will be replaced with the escaped executable supplied - with `executable` or `executable_callback`. This provides a convenient way - to define a command string which needs to include a dynamic executable name, - but which is otherwise static. + with `executable`. This provides a convenient way to define a command string + which needs to include a dynamic executable name, but which is otherwise + static. For example: > 'command': '%e --some-argument', @@ -2986,7 +3355,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* If a callback for a command generates part of a command string which might possibly contain `%%`, `%s`, `%t`, or `%e`, where the special formatting - behavior is not desired, the |ale#engine#EscapeCommandPart()| function can + behavior is not desired, the |ale#command#EscapeCommandPart()| function can be used to replace those characters to avoid formatting issues. *ale-linter-loading-behavior* @@ -3072,6 +3441,21 @@ ale#statusline#Count(buffer) *ale#statusline#Count()* `total` -> The total number of problems. +ale#statusline#FirstProblem(buffer, type) *ale#statusline#FirstProblem()* + + Returns a copy of the first entry in the `loclist` that matches the supplied + buffer number and problem type. If there is no such enty, an empty dictionary + is returned. + Problem type should be one of the strings listed below: + + `error` -> Returns the first `loclist` item with type `E` and + `sub_type != 'style'` + `warning` -> First item with type `W` and `sub_type != 'style'` + `info` -> First item with type `I` + `style_error` -> First item with type `E` and `sub_type == 'style'` + `style_warning` -> First item with type `W` and `sub_type == 'style'` + + b:ale_linted *b:ale_linted* `b:ale_linted` is set to the number of times a buffer has been checked by diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 4af59a91..1df473c5 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -87,6 +87,9 @@ let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1) " This flag can be set to 1 to enable linting when the filetype is changed. let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1) +" This Dictionary configures the default LSP roots for various linters. +let g:ale_lsp_root = get(g:, 'ale_lsp_root', {}) + " This flag can be set to 1 to enable automatically fixing files on save. let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) @@ -148,9 +151,12 @@ if g:ale_completion_enabled endif " Define commands for moving through warnings and errors. -command! -bar ALEPrevious :call ale#loclist_jumping#Jump('before', 0) +command! -bar -nargs=* ALEPrevious +\ :call ale#loclist_jumping#WrapJump('before', ) +command! -bar -nargs=* ALENext +\ :call ale#loclist_jumping#WrapJump('after', ) + command! -bar ALEPreviousWrap :call ale#loclist_jumping#Jump('before', 1) -command! -bar ALENext :call ale#loclist_jumping#Jump('after', 0) command! -bar ALENextWrap :call ale#loclist_jumping#Jump('after', 1) command! -bar ALEFirst :call ale#loclist_jumping#JumpToIndex(0) command! -bar ALELast :call ale#loclist_jumping#JumpToIndex(-1) @@ -192,8 +198,14 @@ command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab' command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) +" Go to type definition for tsserver and LSP +command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({}) +command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'}) +command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'}) +command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'}) + " Find references for tsserver and LSP -command! -bar ALEFindReferences :call ale#references#Find() +command! -bar -nargs=* ALEFindReferences :call ale#references#Find() " Show summary information for the cursor. command! -bar ALEHover :call ale#hover#ShowAtCursor() @@ -204,13 +216,21 @@ command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor() " Search for appearances of a symbol, such as a type name or function name. command! -nargs=1 ALESymbolSearch :call ale#symbol#Search() -command! -bar ALEComplete :call ale#completion#AlwaysGetCompletions() +command! -bar ALEComplete :call ale#completion#AlwaysGetCompletions(0) " mappings for commands nnoremap (ale_previous) :ALEPrevious nnoremap (ale_previous_wrap) :ALEPreviousWrap +nnoremap (ale_previous_error) :ALEPrevious -error +nnoremap (ale_previous_wrap_error) :ALEPrevious -wrap -error +nnoremap (ale_previous_warning) :ALEPrevious -warning +nnoremap (ale_previous_wrap_warning) :ALEPrevious -wrap -warning nnoremap (ale_next) :ALENext nnoremap (ale_next_wrap) :ALENextWrap +nnoremap (ale_next_error) :ALENext -error +nnoremap (ale_next_wrap_error) :ALENext -wrap -error +nnoremap (ale_next_warning) :ALENext -warning +nnoremap (ale_next_wrap_warning) :ALENext -wrap -warning nnoremap (ale_first) :ALEFirst nnoremap (ale_last) :ALELast nnoremap (ale_toggle) :ALEToggle @@ -228,6 +248,10 @@ nnoremap (ale_go_to_definition) :ALEGoToDefinition nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit +nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition +nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab +nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation @@ -245,6 +269,6 @@ augroup ALECleanupGroup autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand(''))) if exists('##VimSuspend') - autocmd VimSuspend * if exists('*ale#engine#CleanupEveryBuffer') | call ale#engine#CleanupEveryBuffer() | endif + autocmd VimSuspend * if exists('*ale#engine#CleanupEveryBuffer') | call ale#engine#CleanupEveryBuffer() | endif endif augroup END diff --git a/sources_non_forked/auto-pairs/README.md b/sources_non_forked/auto-pairs/README.md index 7cdcbf92..8d079ba6 100644 --- a/sources_non_forked/auto-pairs/README.md +++ b/sources_non_forked/auto-pairs/README.md @@ -4,11 +4,13 @@ Insert or delete brackets, parens, quotes in pair. Installation ------------ -copy plugin/auto-pairs.vim to ~/.vim/plugin -or if you are using `pathogen`: - -```git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs``` +* Manual + * Copy `plugin/auto-pairs.vim` to `~/.vim/plugin` +* [Pathogen](https://github.com/tpope/vim-pathogen) + * `git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs` +* [Vundle](https://github.com/VundleVim/Vundle.vim) + * `Plugin 'jiangmiao/auto-pairs'` Features -------- @@ -27,7 +29,10 @@ Features input: {|} (press at |) output: { | - } + } (press } to close the pair) + output: { + }| (the inserted blank line will be deleted) + * Insert spaces before closing characters, only for [], (), {} @@ -57,13 +62,6 @@ Features * Fast Wrap - input: |'hello' (press ( at |) - output: ('hello') - - wrap string, only support c style string - input: |'h\\el\'lo' (press ( at |) - output ('h\\ello\'') - input: |[foo, bar()] (press ( at |) output: ([foo, bar()]) @@ -89,25 +87,6 @@ Features }| -* Support ``` ''' and """ - - input: - ''' - - output: - '''|''' - -* Delete Repeated Pairs in one time - - input: """|""" (press at |) - output: | - - input: {{|}} (press at |) - output: | - - input: [[[[[[|]]]]]] (press at |) - output: | - * Fly Mode input: if(a[3) @@ -137,6 +116,11 @@ Features See Fly Mode section for details +* Multibyte Pairs + + Support any multibyte pairs such as , <% %>, """ """ + See multibyte pairs section for details + Fly Mode -------- Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]" @@ -175,7 +159,7 @@ Options ------- * g:AutoPairs - Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''"} * b:AutoPairs @@ -273,6 +257,108 @@ eg: " When the filetype is FILETYPE then make AutoPairs only match for parenthesis au Filetype FILETYPE let b:AutoPairs = {"(": ")"} + au FileType php let b:AutoPairs = AutoPairsDefine({'', ''}) + +Multibyte Pairs +--------------- + + The default pairs is {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + You could also define multibyte pairs such as , <% %> and so on + +* Function AutoPairsDefine(addPairs:dict[, removeOpenPairList:list]) + + add or delete pairs base on g:AutoPairs + + eg: + au FileType html let b:AutoPairs = AutoPairsDefine({''}, ['{']) + add pair and remove '{' for html file + + the pair implict start with \V, so if want to match start of line ^ should be write in \^ vim comment {'\^"': ''} + +* General usage + + au FileType php let b:AutoPairs = AutoPairsDefine({'', ''}) + + the first key of closed pair ? will be mapped + + pairs: '', '' + input: + + input: + + input: he (press at|) + output: he| + + input: (press ? at|) + output: | + + pair: '[[':']]' + input: [[|]] (press ) + output: | ([[ and ]] will be deleted the [['s priority is higher than [ for it's longer) + +* Modifier + + The text after // in close pair is modifiers + + n - do not map the first charactor of closed pair to close key + m - close key jumps through multi line + s - close key jumps only in the same line + k[KEY] - map the close key to [KEY] + + by default if open key equals close key the multi line is turn off + + "" ? jumps only in the same line + "//m" force ? jumping through multi line + "" ? will jump through multi line + "//s" force ? only jumping in the same line + "//n" do not jump totally + "//k]" use key ] to jump through ?> + + for 'begin' 'end' pair, e is a charactor, if map e to jump will be annoy, so use modifier 'n' to skip key map + + au FileType ruby let b:AutoPairs = AutoPairsDefine({'begin': 'end//n]'}) + + + input: begin + output: begin|end + + input: begin|end (press on |) + output: | + + input: begin|end (press e on |) + output: begineend (will not jump for e is not mapped) + +* Advanced usage + + au FileType rust let b:AutoPairs = AutoPairsDefine({'\w\zs<': '>'}) + + if press < after a word will generate the pair + + when use regexp MUST use \zs to prevent catching + if use '\w<' without \zs, for text hello<|> press on | will output 'hell', the 'o' has been deleted + + pair: '\w\zs<': '>' + input: h < + output: h < + + input: h< + output: h<|> + + input: h<|> press + output: h| + + pair: '\w<': '>' (WRONG pair which missed \zs) + input: h<|> press + output: | (charactor 'h' is deleted) + + + the 'begin' 'end' pair write in + + au FileType ruby let b:AutoPairs = AutoPairsDefine({'\v(^|\W)\zsbegin': 'end//n'}) + + will be better, only auto pair when at start of line or follow non-word text TroubleShooting --------------- @@ -299,7 +385,7 @@ TroubleShooting To fix the issue, you need remap or disable the related shortcut. Known Issues ------------------------ +------------ Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3) Description: After entering insert mode and inputing `[hello` then leave insert diff --git a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim index b2a9af7d..af5eb32a 100644 --- a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim +++ b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim @@ -1,8 +1,8 @@ " Insert or delete brackets, parens, quotes in pairs. " Maintainer: JiangMiao " Contributor: camthompson -" Last Change: 2017-06-17 -" Version: 1.3.3 +" Last Change: 2019-02-02 +" Version: 2.0.0 " Homepage: http://www.vim.org/scripts/script.php?script_id=3599 " Repository: https://github.com/jiangmiao/auto-pairs " License: MIT @@ -13,12 +13,30 @@ end let g:AutoPairsLoaded = 1 if !exists('g:AutoPairs') - let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"} end -if !exists('g:AutoPairsParens') - let g:AutoPairsParens = {'(':')', '[':']', '{':'}'} -end +" default pairs base on filetype +func! AutoPairsDefaultPairs() + if exists('b:autopairs_defaultpairs') + return b:autopairs_defaultpairs + end + let r = copy(g:AutoPairs) + let allPairs = { + \ 'vim': {'\v^\s*\zs"': ''}, + \ 'rust': {'\w\zs<': '>', '&\zs''': ''}, + \ 'php': {'//k]', '//k]'} + \ } + for [filetype, pairs] in items(allPairs) + if &filetype == filetype + for [open, close] in items(pairs) + let r[open] = close + endfor + end + endfor + let b:autopairs_defaultpairs = r + return r +endf if !exists('g:AutoPairsMapBS') let g:AutoPairsMapBS = 1 @@ -33,6 +51,10 @@ if !exists('g:AutoPairsMapCR') let g:AutoPairsMapCR = 1 end +if !exists('g:AutoPairsWildClosedPair') + let g:AutoPairsWildClosedPair = '' +end + if !exists('g:AutoPairsMapSpace') let g:AutoPairsMapSpace = 1 end @@ -91,267 +113,336 @@ let s:Left = s:Go."\" let s:Right = s:Go."\" -" Will auto generated {']' => '[', ..., '}' => '{'}in initialize. -let g:AutoPairsClosedPairs = {} -function! AutoPairsInsert(key) - if !b:autopairs_enabled - return a:key - end +" unicode len +func! s:ulen(s) + return len(split(a:s, '\zs')) +endf +func! s:left(s) + return repeat(s:Left, s:ulen(a:s)) +endf + +func! s:right(s) + return repeat(s:Right, s:ulen(a:s)) +endf + +func! s:delete(s) + return repeat("\", s:ulen(a:s)) +endf + +func! s:backspace(s) + return repeat("\", s:ulen(a:s)) +endf + +func! s:getline() let line = getline('.') let pos = col('.') - 1 let before = strpart(line, 0, pos) let after = strpart(line, pos) - let next_chars = split(after, '\zs') - let current_char = get(next_chars, 0, '') - let next_char = get(next_chars, 1, '') - let prev_chars = split(before, '\zs') - let prev_char = get(prev_chars, -1, '') - - let eol = 0 - if col('$') - col('.') <= 1 - let eol = 1 - end - - " Ignore auto close if prev character is \ - if prev_char == '\' - return a:key - end - - " The key is difference open-pair, then it means only for ) ] } by default - if !has_key(b:AutoPairs, a:key) - let b:autopairs_saved_pair = [a:key, getpos('.')] - - " Skip the character if current character is the same as input - if current_char == a:key - return s:Right - end - - if !g:AutoPairsFlyMode - " Skip the character if next character is space - if current_char == ' ' && next_char == a:key - return s:Right.s:Right - end - - " Skip the character if closed pair is next character - if current_char == '' - if g:AutoPairsMultilineClose - let next_lineno = line('.')+1 - let next_line = getline(nextnonblank(next_lineno)) - let next_char = matchstr(next_line, '\s*\zs.') - else - let next_char = matchstr(line, '\s*\zs.') - end - if next_char == a:key - return "\e^a" - endif - endif - endif - - " Fly Mode, and the key is closed-pairs, search closed-pair and jump - if g:AutoPairsFlyMode && has_key(b:AutoPairsClosedPairs, a:key) - let n = stridx(after, a:key) - if n != -1 - return repeat(s:Right, n+1) - end - if search(a:key, 'W') - " force break the '.' when jump to different line - return "\" - endif - endif - - " Insert directly if the key is not an open key - return a:key - end - - let open = a:key - let close = b:AutoPairs[open] - - if current_char == close && open == close - return s:Right - end - - " Ignore auto close ' if follows a word - " MUST after closed check. 'hello|' - if a:key == "'" && prev_char =~ '\v\w' - return a:key - end - - " support for ''' ``` and """ - if open == close - " The key must be ' " ` - let pprev_char = line[col('.')-3] - if pprev_char == open && prev_char == open - " Double pair found - return repeat(a:key, 4) . repeat(s:Left, 3) - end - end - - let quotes_num = 0 - " Ignore comment line for vim file - if &filetype == 'vim' && a:key == '"' - if before =~ '^\s*$' - return a:key - end - if before =~ '^\s*"' - let quotes_num = -1 - end - end - - " Keep quote number is odd. - " Because quotes should be matched in the same line in most of situation - if g:AutoPairsSmartQuotes && open == close - " Remove \\ \" \' - let cleaned_line = substitute(line, '\v(\\.)', '', 'g') - let n = quotes_num - let pos = 0 - while 1 - let pos = stridx(cleaned_line, open, pos) - if pos == -1 + let afterline = after + if g:AutoPairsMultilineClose + let n = line('$') + let i = line('.')+1 + while i <= n + let line = getline(i) + let after = after.' '.line + if !(line =~ '\v^\s*$') break end - let n = n + 1 - let pos = pos + 1 + let i = i+1 endwhile - if n % 2 == 1 - return a:key + end + return [before, after, afterline] +endf + +" split text to two part +" returns [orig, text_before_open, open] +func! s:matchend(text, open) + let m = matchstr(a:text, '\V'.a:open.'\v$') + if m == "" + return [] + end + return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m] +endf + +" returns [orig, close, text_after_close] +func! s:matchbegin(text, close) + let m = matchstr(a:text, '^\V'.a:close) + if m == "" + return [] + end + return [a:text, m, strpart(a:text, len(m), len(a:text)-len(m))] +endf + +" add or delete pairs base on g:AutoPairs +" AutoPairsDefine(addPairs:dict[, removeOpenPairList:list]) +" +" eg: +" au FileType html let b:AutoPairs = AutoPairsDefine({''}, ['{']) +" add pair and remove '{' for html file +func! AutoPairsDefine(pairs, ...) + let r = AutoPairsDefaultPairs() + if a:0 > 0 + for open in a:1 + unlet r[open] + endfor + end + for [open, close] in items(a:pairs) + let r[open] = close + endfor + return r +endf + +func! AutoPairsInsert(key) + if !b:autopairs_enabled + return a:key + end + + let b:autopairs_saved_pair = [a:key, getpos('.')] + + let [before, after, afterline] = s:getline() + + " Ignore auto close if prev character is \ + if before[-1:-1] == '\' + return a:key + end + + " check open pairs + for [open, close, opt] in b:AutoPairsList + let ms = s:matchend(before.a:key, open) + let m = matchstr(afterline, '^\v\s*\zs\V'.close) + if len(ms) > 0 + " process the open pair + + " remove inserted pair + " eg: if the pairs include < > and + " when " contains=pugCommentTodo,@Spell syn region pugAngular2 start="(" end=")" contains=htmlEvent syn region pugJavascriptString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contained syn region pugJavascriptString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contained -syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent +syn region pugJavascriptString start=+`+ skip=+\\\(`\|$\)+ end=+`\|$+ contains=javascriptInterpolation contained +syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end="\(.\zs)\)\|)" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent syn match pugClassChar "\." containedin=htmlTagName nextgroup=pugClass syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId @@ -68,10 +69,11 @@ syn region pugPlainFilter matchgroup=pugFilter start="^\z(\s*\):\%(sass\|less\| syn match pugScriptConditional "^\s*\<\%(if\|else\|else if\|elif\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!" syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!" -syn region pugScriptLoopRegion start="^\s*\(for \)" end="$" contains=pugScriptLoopKeywords -syn keyword pugScriptLoopKeywords for in contained +syn region pugScriptLoopRegion start="^\s*\(for\|each\)" end="$" contains=pugScriptLoopKeywords +syn keyword pugScriptLoopKeywords contained for each in -syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend +syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend +syn region javascriptInterpolation start=/${/ end=/}/ contained syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag @@ -102,6 +104,7 @@ hi def link pugComment Comment hi def link pugCommentBlock Comment hi def link pugHtmlConditionalComment pugComment hi def link pugJavascriptString String +hi def link javascriptInterpolation Delimiter let b:current_syntax = "pug" diff --git a/sources_non_forked/vim-snipmate/README.md b/sources_non_forked/vim-snipmate/README.md index f025dce5..2072d7c5 100644 --- a/sources_non_forked/vim-snipmate/README.md +++ b/sources_non_forked/vim-snipmate/README.md @@ -46,6 +46,10 @@ looking at the [vim-snippets][vim-snippets] repository. " Optional: Plugin 'honza/vim-snippets' +## Using SnipMate ## +Press and try :SnipMateOpenSnippetFiles for starting. +Also see doc/SnipMate.txt to learn all SnipMate + ## FAQ ## > SnipMate doesn't work / My snippets aren't triggering diff --git a/sources_non_forked/vim-snipmate/autoload/snipMate.vim b/sources_non_forked/vim-snipmate/autoload/snipMate.vim index 9d1786ab..49528795 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipMate.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipMate.vim @@ -504,7 +504,7 @@ fun! s:ChooseSnippet(snippets) abort let snippet += [i.'. '.snip] let i += 1 endfor - if len(snippet) == 1 + if len(snippet) == 1 || get(g:snipMate, 'always_choose_first', 0) == 1 " there's only a single snippet, choose it let idx = 0 else diff --git a/sources_non_forked/vim-snipmate/doc/snipMate.txt b/sources_non_forked/vim-snipmate/doc/snipMate.txt index d00e6b20..cb5f9ff2 100644 --- a/sources_non_forked/vim-snipmate/doc/snipMate.txt +++ b/sources_non_forked/vim-snipmate/doc/snipMate.txt @@ -161,6 +161,13 @@ g:snipMate.override maps and other settings work. Note: Load order is determined by 'runtimepath'. + Duplicates are only dropped after reading one + snippet file. If multiple files contain a + snippet see always_choose_first +g:snipMate.always_choose_first + Always choose first snippet if there are + multiple left + g:snipMate.description_in_completion If set to 1 (default is 0), snippet descriptions will be included in the popup diff --git a/sources_non_forked/vim-snippets/.gitignore b/sources_non_forked/vim-snippets/.gitignore index f3d74a9a..9989bee9 100644 --- a/sources_non_forked/vim-snippets/.gitignore +++ b/sources_non_forked/vim-snippets/.gitignore @@ -1,2 +1,4 @@ *.pyc *~ +*.swo +*.swp diff --git a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets index 4f58aef9..ffd76613 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets @@ -1,12 +1,12 @@ priority -50 snippet anaf "accepts_nested_attributes_for" -accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}} +accepts_nested_attributes_for :${1:association_name}${2:${3:, allow_destroy: true}${4:, reject_if: proc \{ |obj| ${5:obj.blank?} \}}} endsnippet snippet tcbi "Create binary column" -t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +t.binary :${1:title}${2:, limit: ${3:2}.megabytes} $0 endsnippet @@ -17,7 +17,7 @@ endsnippet snippet clac "Create controller class" class ${1:Model}Controller < ApplicationController - before_filter :find_${2:model} + before_action :find_${2:model} $0 @@ -39,7 +39,7 @@ $0 endsnippet snippet tcd "Create decimal column" -t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +t.decimal :${1:title}${2:${3:, precision: ${4:10}}${5:, scale: ${6:2}}} $0 endsnippet @@ -63,48 +63,48 @@ $0 endsnippet snippet tcl "Create lock_version column" -t.integer :lock_version, :null => false, :default => 0 +t.integer :lock_version, null: false, default: 0 $0 endsnippet # FIXME: handling literal bracket pair inside of nested tab groups? snippet tcr "Create references column" -t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +t.references :${1:taggable}${2:, polymorphic ${3:{ :default: '${4:Photo}' \}}} $0 endsnippet snippet resources "Create resources controller class" class ${1:Model}sController < ApplicationController - before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy] + before_action :find_${1/./\l$0/}, only: [:show, :edit, :update, :destroy] # GET /${1/./\l$0/}s - # GET /${1/./\l$0/}s.xml + # GET /${1/./\l$0/}s.json def index @${1/./\l$0/}s = ${1:Model}.all respond_to do |wants| wants.html # index.html.erb - wants.xml { render :xml => @${1/./\l$0/}s } + wants.json { render json: @${1/./\l$0/}s } end end # GET /${1/./\l$0/}s/1 - # GET /${1/./\l$0/}s/1.xml + # GET /${1/./\l$0/}s/1.json def show respond_to do |wants| wants.html # show.html.erb - wants.xml { render :xml => @${1/./\l$0/} } + wants.json { render json: @${1/./\l$0/} } end end # GET /${1/./\l$0/}s/new - # GET /${1/./\l$0/}s/new.xml + # GET /${1/./\l$0/}s/new.json def new @${1/./\l$0/} = ${1:Model}.new respond_to do |wants| wants.html # new.html.erb - wants.xml { render :xml => @${1/./\l$0/} } + wants.json { render json: @${1/./\l$0/} } end end @@ -113,7 +113,7 @@ class ${1:Model}sController < ApplicationController end # POST /${1/./\l$0/}s - # POST /${1/./\l$0/}s.xml + # POST /${1/./\l$0/}s.json def create @${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}]) @@ -121,37 +121,37 @@ class ${1:Model}sController < ApplicationController if @${1/./\l$0/}.save flash[:notice] = '${1:Model} was successfully created.' wants.html { redirect_to(@${1/./\l$0/}) } - wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} } + wants.json { render json: @${1/./\l$0/}, status: :created, location: @${1/./\l$0/} } else - wants.html { render :action => "new" } - wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + wants.html { render action: "new" } + wants.json { render json: @${1/./\l$0/}.errors, status: :unprocessable_entity } end end end # PUT /${1/./\l$0/}s/1 - # PUT /${1/./\l$0/}s/1.xml + # PUT /${1/./\l$0/}s/1.json def update respond_to do |wants| if @${1/./\l$0/}.update(params[:${1/./\l$0/}]) flash[:notice] = '${1:Model} was successfully updated.' wants.html { redirect_to(@${1/./\l$0/}) } - wants.xml { head :ok } + wants.json { head :ok } else - wants.html { render :action => "edit" } - wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + wants.html { render action: "edit" } + wants.json { render json: @${1/./\l$0/}.errors, status: :unprocessable_entity } end end end # DELETE /${1/./\l$0/}s/1 - # DELETE /${1/./\l$0/}s/1.xml + # DELETE /${1/./\l$0/}s/1.json def destroy @${1/./\l$0/}.destroy respond_to do |wants| wants.html { redirect_to(${1/./\l$0/}s_url) } - wants.xml { head :ok } + wants.json { head :ok } end end @@ -217,7 +217,7 @@ $0 endsnippet snippet art "Test Assert Redirected To (art)" -assert_redirected_to ${2::action => "${1:index}"} +assert_redirected_to ${2:action: "${1:index}"} endsnippet snippet asre "Test Assert Response (are)" @@ -290,7 +290,7 @@ assert_rjs :${1:replace}, ${2:"${3:dom id}"} endsnippet snippet ass "assert_select" -assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do +assert_select '${1:path}'${2:, ${3:text}: ${4:'${5:inner_html}'}}${6: do $0 end} endsnippet @@ -324,7 +324,7 @@ before_validation_on_update endsnippet snippet bt "belongs_to (bt)" -belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"} +belongs_to :${1:object}${2:, class_name: "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", foreign_key: "${4:$1_id}"} endsnippet snippet crw "cattr_accessor" @@ -339,10 +339,10 @@ def create if @$1.save flash[:notice] = '$2 was successfully created.' wants.html { redirect_to(@$1) } - wants.xml { render :xml => @$1, :status => :created, :location => @$1 } + wants.json { render json: @$1, status: :created, location: @$1 } else - wants.html { render :action => "new" } - wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } + wants.html { render action: "new" } + wants.json { render json: @$1.errors, status: :unprocessable_entity } end end end @@ -358,7 +358,7 @@ endsnippet snippet deftg "def get request" def test_should_get_${1:action} ${2:@${3:model} = ${4:$3s}(:${5:fixture_name}) - }get :$1${6:, :id => @$3.to_param} + }get :$1${6:, id: @$3.to_param} assert_response :success $0 end @@ -367,18 +367,18 @@ endsnippet snippet deftp "def post request" def test_should_post_${1:action} ${3:@$2 = ${4:$2s}(:${5:fixture_name}) - }post :$1${6:, :id => @$2.to_param}, :${2:model} => { $0 } + }post :$1${6:, id: @$2.to_param}, ${2:model}: { $0 } assert_response :redirect end endsnippet snippet fina "find(:all)" -find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +find(:all${1:, conditions: ['${2:${3:field} = ?}', ${5:true}]}) endsnippet snippet finf "find(:first)" -find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +find(:first${1:, conditions: ['${2:${3:field} = ?}', ${5:true}]}) endsnippet snippet fini "find(id)" @@ -386,13 +386,13 @@ find(${1:id}) endsnippet snippet fine "find_each" -find_each(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}| +find_each(${1conditions: {:${2:field}: ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}| $0 end endsnippet snippet finb "find_in_batches" -find_in_batches(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s| +find_in_batches(${1conditions: {:${2:field}: ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s| $4s.each do |$4| $0 end @@ -400,23 +400,23 @@ end endsnippet snippet habtm "has_and_belongs_to_many (habtm)" -has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:$1_id}"} +has_and_belongs_to_many :${1:object}${2:, join_table: "${3:table_name}", foreign_key: "${4:$1_id}"} endsnippet snippet hm "has_many (hm)" -has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"} +has_many :${1:object}s${2:, class_name: "$1", foreign_key: "${4:reference}_id"} endsnippet snippet hmt "has_many (through)" -has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:$2_table_foreign_key_to_$1_table}} +has_many :${1:objects}, through: :${2:join_association}${3:, source: :${4:$2_table_foreign_key_to_$1_table}} endsnippet -snippet hmd "has_many :dependent => :destroy" -has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0 +snippet hmd "has_many dependent: :destroy" +has_many :${1:object}s${2:, class_name: "$1", foreign_key: "${4:reference}_id"}, dependent: :destroy$0 endsnippet snippet ho "has_one (ho)" -has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"} +has_one :${1:object}${2:, class_name: "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", foreign_key: "${4:$1_id}"} endsnippet snippet logd "logger.debug" @@ -444,7 +444,7 @@ map(&:${1:id}) endsnippet snippet mapca "map.catch_all" -${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}" +${1:map}.catch_all "*${2:anything}", controller: "${3:default}", action: "${4:error}" endsnippet @@ -465,7 +465,7 @@ end} endsnippet snippet mapwo "map.with_options" -${1:map}.with_options :${2:controller} => '${3:thing}' do |${4:$3}| +${1map}.with_options :${2:controller}: '${3:thing}' do |${4:$3}| $0 end @@ -476,12 +476,12 @@ mattr_accessor :${0:attr_names} endsnippet snippet ncl "named_scope lambda" -named_scope :name, lambda { |${1:param}| { :conditions => ${3:['${4:${5:field} = ?}', ${6:$1}]} } } +named_scope :name, lambda { |${1param}| { :conditions: ${3:['${4:${5:field} = ?}', ${6:$1}]} } } endsnippet snippet nc "named_scope" -named_scope :name${1:, :joins => :${2:table}}, :conditions => ${3:['${4:${5:field} = ?}', ${6:true}]} +named_scope :name${1:, joins: :${2:table}}, conditions: ${3:['${4:${5:field} = ?}', ${6:true}]} endsnippet @@ -494,23 +494,23 @@ flash[:${1:notice}] = "${2:Successfully created...}"$0 endsnippet snippet rea "redirect_to (action)" -redirect_to :action => "${1:index}" +redirect_to action: "${1:index}" endsnippet snippet reai "redirect_to (action, id)" -redirect_to :action => "${1:show}", :id => ${0:@item} +redirect_to action: "${1:show}", id: ${0:@item} endsnippet snippet rec "redirect_to (controller)" -redirect_to :controller => "${1:items}" +redirect_to controller: "${1:items}" endsnippet snippet reca "redirect_to (controller, action)" -redirect_to :controller => "${1:items}", :action => "${2:list}" +redirect_to controller: "${1:items}", action: "${2:list}" endsnippet snippet recai "redirect_to (controller, action, id)" -redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@item} +redirect_to controller: "${1:items}", action: "${2:show}", id: ${0:@item} endsnippet snippet renpp "redirect_to (nested path plural)" @@ -534,59 +534,59 @@ redirect_to :back endsnippet snippet ra "render (action)... (ra)" -render :action => "${1:action}" +render action: "${1:action}" endsnippet snippet ral "render (action,layout) (ral)" -render :action => "${1:action}", :layout => "${2:layoutname}" +render action: "${1:action}", layout: "${2:layoutname}" endsnippet snippet rf "render (file) (rf)" -render :file => "${1:filepath}" +render file: "${1:filepath}" endsnippet snippet rfu "render (file,use_full_path) (rfu)" -render :file => "${1:filepath}", :use_full_path => ${2:false} +render file: "${1:filepath}", use_full_path: ${2:false} endsnippet snippet ri "render (inline) (ri)" -render :inline => "${1:<%= 'hello' %>}" +render inline: "${1:<%= 'hello' %>}" endsnippet snippet ril "render (inline,locals) (ril)" -render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"$4 } +render inline: "${1:<%= 'hello' %>}", locals { ${2::name}: "${3:value}"$4 } endsnippet snippet rit "render (inline,type) (rit)" -render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml} +render inline: "${1:<%= 'hello' %>}", type: ${2::rjson} endsnippet snippet rl "render (layout) (rl)" -render :layout => "${1:layoutname}" +render layout: "${1:layoutname}" endsnippet snippet rn "render (nothing) (rn)" -render :nothing => ${1:true} +render nothing: ${1:true} endsnippet snippet rns "render (nothing,status) (rns)" -render :nothing => ${1:true}, :status => ${2:401} +render nothing: ${1:true}, status: ${2:401} endsnippet snippet rt "render (text) (rt)" -render :text => "${1:text to render...}" +render text: "${1:text to render...}" endsnippet snippet rtl "render (text,layout) (rtl)" -render :text => "${1:text to render...}", :layout => "${2:layoutname}" +render text: "${1:text to render...}", layout: "${2:layoutname}" endsnippet snippet rtlt "render (text,layout => true) (rtlt)" -render :text => "${1:text to render...}", :layout => ${2:true} +render text: "${1:text to render...}", layout: ${2:true} endsnippet snippet rts "render (text,status) (rts)" -render :text => "${1:text to render...}", :status => ${2:401} +render text: "${1:text to render...}", status: ${2:401} endsnippet snippet ru "render (update)" @@ -615,7 +615,7 @@ end endsnippet snippet t. "t.binary (tcbi)" -t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +t.binary :${1:title}${2:, limit: ${3:2}.megabytes} t.$0 endsnippet @@ -635,7 +635,7 @@ t.$0 endsnippet snippet t. "t.decimal (tcd)" -t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +t.decimal :${1:title}${2:${3:, precision: ${4:10}}${5:, scale: ${6:2}}} t.$0 endsnippet @@ -650,12 +650,12 @@ t.$0 endsnippet snippet t. "t.lock_version (tcl)" -t.integer :lock_version, :null => false, :default => 0 +t.integer :lock_version, null: false, default: 0 t.$0 endsnippet snippet t. "t.references (tcr)" -t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +t.references :${1:taggable}${2:, polymorphic ${3:{ :default: '${4:Photo}' \}}} t.$0 endsnippet @@ -690,113 +690,113 @@ t.$0 endsnippet snippet vaoif "validates_acceptance_of if" -validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}, :if => proc { |obj| ${7:obj.condition?} }} +validates_acceptance_of :${1:terms}${2:${3:, accept: "${4:1}"}${5:, message: "${6:You must accept the terms of service}"}}, if: proc { |obj| ${7:obj.condition?} }} endsnippet snippet vao "validates_acceptance_of" -validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}} +validates :${1:terms}${2:, acceptance: ${3:{ accept: "${4:1}"${5:, message: "${6:You must accept the terms of service}"}}} } endsnippet snippet va "validates_associated (va)" -validates_associated :${1:attribute}${2:, :on => :${3:create}} +validates_associated :${1:attribute}${2:, on: :${3:create}} endsnippet snippet vaif "validates_associated if (vaif)" -validates_associated :${1:attribute}${2:, :on => :${3:create}, :if => proc { |obj| ${5:obj.condition?} }} +validates_associated :${1:attribute}${2:, on: :${3:create}, if: proc { |obj| ${5:obj.condition?} }} endsnippet snippet vc "validates_confirmation_of (vc)" -validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}"} +validates_confirmation_of :${1:attribute}${2:, on: :${3:create}, message: "${4:should match confirmation}"} endsnippet snippet vcif "validates_confirmation_of if (vcif)" -validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}", :if => proc { |obj| ${5:obj.condition?} }} +validates_confirmation_of :${1:attribute}${2:, on: :${3:create}, message: "${4:should match confirmation}", if: proc { |obj| ${5:obj.condition?} }} endsnippet snippet ve "validates_exclusion_of (ve)" -validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"} +validates_exclusion_of :${1:attribute}${2:, in: ${3:%w( ${4:mov avi} )}, on: :${5:create}, message: "${6:extension %s is not allowed}"} endsnippet snippet veif "validates_exclusion_of if (veif)" -validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}, :if => proc { |obj| ${7:obj.condition?} }} +validates_exclusion_of :${1:attribute}${2:, in: ${3:%w( ${4:mov avi} )}, on: :${5:create}, message: "${6:extension %s is not allowed}"}, if: proc { |obj| ${7:obj.condition?} }} endsnippet snippet vfif "validates_format_of if" -validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}, :if => proc { |obj| ${7:obj.condition?} }} +validates_format_of :${1:attribute}, with: /${2:^[${3:\w\d}]+\$}/${4:, on: :${5:create}, message: "${6:is invalid}"}, if: proc { |obj| ${7:obj.condition?} }} endsnippet snippet vf "validates_format_of" -validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"} +validates_format_of :${1:attribute}, with: /${2:^[${3:\w\d}]+\$}/${4:, on: :${5:create}, message: "${6:is invalid}"} endsnippet snippet viif "validates_inclusion_of if" -validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}, :if => proc { |obj| ${7:obj.condition?} }} +validates_inclusion_of :${1:attribute}${2:, in: ${3:%w( ${4:mov avi} )}, on: :${5:create}, message: "${6:extension %s is not included in the list}"}, if: proc { |obj| ${7:obj.condition?} }} endsnippet snippet vi "validates_inclusion_of" -validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"} +validates_inclusion_of :${1:attribute}${2:, in: ${3:%w( ${4:mov avi} )}, on: :${5:create}, message: "${6:extension %s is not included in the list}"} endsnippet snippet vl "validates_length_of (vl)" -validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"} +validates_length_of :${1:attribute}, within: ${2:3..20}${3:, on: :${4:create}, message: "${5:must be present}"} endsnippet snippet vlif "validates_length_of if" -validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}, :if => proc { |obj| ${6:obj.condition?} }} +validates_length_of :${1:attribute}, within: ${2:3..20}${3:, on: :${4:create}, message: "${5:must be present}"}, if: proc { |obj| ${6:obj.condition?} }} endsnippet snippet vnif "validates_numericality_of if" -validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}, :if => proc { |obj| ${5:obj.condition?} }} +validates_numericality_of :${1:attribute}${2:, on: :${3:create}, message: "${4:is not a number}"}, if: proc { |obj| ${5:obj.condition?} }} endsnippet snippet vn "validates_numericality_of" -validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"} +validates_numericality_of :${1:attribute}${2:, on: :${3:create}, message: "${4:is not a number}"} endsnippet snippet vp "validates_presence_of (vp)" -validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"} +validates_presence_of :${1:attribute}${2:, on: :${3:create}, message: "${4:can't be blank}"} endsnippet snippet vpif "validates_presence_of if (vpif) 2" -validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}, :if => proc { |obj| ${5:obj.condition?} }} +validates_presence_of :${1:attribute}${2:, on: :${3:create}, message: "${4:can't be blank}"}, if: proc { |obj| ${5:obj.condition?} }} endsnippet snippet vu "validates_uniqueness_of (vu)" -validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}"} +validates_uniqueness_of :${1:attribute}${2:, on: :${3:create}, message: "${4:must be unique}"} endsnippet snippet vuif "validates_uniqueness_of if (vuif)" -validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}", :if => proc { |obj| ${6:obj.condition?} }} +validates_uniqueness_of :${1:attribute}${2:, on: :${3:create}, message: "${4:must be unique}", if: proc { |obj| ${6:obj.condition?} }} endsnippet snippet verify "verify -- render" -verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"} +verify only: [:$1], method: :post, render {:status: 500, text: "use HTTP-POST"} endsnippet snippet verify "verify -- redirect" -verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'} +verify only: [:$1], session: :user, params: :id, redirect_to {:action: '${2:index}'} endsnippet snippet wants "wants_format" -wants.${1:js|xml|html}${2: { $0 \}} +wants.${1:js|json|html}${2: { $0 \}} endsnippet snippet xdelete "xhr delete" -xhr :delete, :${1:destroy}, :id => ${2:1}$0 +xhr :delete, :${1:destroy}, id: ${2:1}$0 endsnippet snippet xget "xhr get" -xhr :get, :${1:show}${2:, :id => ${3:1}}$0 +xhr :get, :${1:show}${2:, id: ${3:1}}$0 endsnippet snippet xpost "xhr post" -xhr :post, :${1:create}, :${2:object} => { $3 } +xhr :post, :${1:create}, ${2:object}: { $3 } endsnippet snippet xput "xhr put" -xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0 +xhr :put, :${1:update}, id: ${2:1}, ${3:object}: { $4 }$0 endsnippet snippet sweeper "Create sweeper class" @@ -835,15 +835,15 @@ format.${1:html|xml|json|js|any} { $0 } endsnippet snippet gem "gem" -gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, :require => ${7:"${8:$1}"}}${9:, :group => :${10:test}}}} +gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, require: ${7:"${8:$1}"}}${9:, group: :${10:test}}}} endsnippet snippet gemg "gem :git" -gem '${1:paperclip}', :git => "${2:git://github.com/thoughtbot/paperclip.git}"${3:, :branch => "${4:rails3}"} +gem '${1:paperclip}', git: "${2:git://github.com/thoughtbot/paperclip.git}"${3:, branch: "${4:rails3}"} endsnippet snippet match "match" -match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: => '${9:$2}#${10:$4}'${11:, :as => :${12:$10}}} +match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: '${9:$2}#${10:$4}'${11:, as: :${12:$10}}} endsnippet snippet member "member routes" @@ -862,15 +862,15 @@ end} endsnippet snippet scope "scope" -scope :${1:name}, ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}}) +scope :${1:name}, { ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}}) } endsnippet snippet scopel "scope lambda" -scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field} => ${6:"${7:value}"}})} } +scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field}: ${6:"${7:value}"}})} } endsnippet snippet scopee "scope with extension" -scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do +scope :${1:name}, { ${2:where(${3::${4:field}: ${5:'${6:value}'}})} } do def ${7:method_name} $0 end @@ -888,7 +888,7 @@ end endsnippet snippet trans "Translation snippet" -I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}$3', :default => "${1:some_text}"$4)${5:$0} +I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}$3', default: "${1:some_text}"$4)${5:$0} endsnippet snippet route_spec diff --git a/sources_non_forked/vim-snippets/snippets/css.snippets b/sources_non_forked/vim-snippets/snippets/css.snippets index 08b6cdf3..dd688cbe 100644 --- a/sources_non_forked/vim-snippets/snippets/css.snippets +++ b/sources_non_forked/vim-snippets/snippets/css.snippets @@ -1,50 +1,90 @@ snippet . "selector { }" ${1} { - ${0:${VISUAL}} - } + ${2:${VISUAL}} + }${0} snippet ! "!important" !important snippet bdi:m+ - -moz-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; + -moz-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};${0} snippet bdi:m - -moz-border-image: ${0}; + -moz-border-image: ${1};${0} snippet bdrz:m - -moz-border-radius: ${0}; + -moz-border-radius: ${1};${0} snippet bxsh:m+ - -moz-box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; + -moz-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};${0} snippet bxsh:m - -moz-box-shadow: ${0}; + -moz-box-shadow: ${1};${0} snippet bdi:w+ - -webkit-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; + -webkit-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};${0} snippet bdi:w - -webkit-border-image: ${0}; + -webkit-border-image: ${1};${0} snippet bdrz:w - -webkit-border-radius: ${0}; + -webkit-border-radius: ${1};${0} snippet bxsh:w+ - -webkit-box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; + -webkit-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};${0} snippet bxsh:w - -webkit-box-shadow: ${0}; + -webkit-box-shadow: ${1};${0} snippet @f @font-face { font-family: ${1}; - src: url(${0}); - } + src: url(${2}); + }${0} snippet @i - @import url(${0}); + @import url(${1});${0} snippet @m "@media mediatype { }" @media ${1:print} { - ${0:${VISUAL}} - } + ${2:${VISUAL}} + }${0} +snippet ac + align-content: ${0:stretch}; +snippet ac:c + align-content: center; +snippet ac:fe + align-content: flex-end; +snippet ac:fs + align-content: flex-start; +snippet ac:sa + align-content: space-around; +snippet ac:sb + align-content: space-between; +snippet ac:s + align-content: stretch; +snippet ai + align-items: ${0:stretch}; +snippet ai:b + align-items: baseline; +snippet ai:c + align-items: center; +snippet ai:fe + align-items: flex-end; +snippet ai:fs + align-items: flex-start; +snippet ai:s + align-items: stretch; +snippet as + align-self: ${0}; +snippet as:a + align-self: auto; +snippet as:b + align-self: baseline; +snippet as:c + align-self: center; +snippet as:fe + align-self: flex-end; +snippet as:fs + align-self: flex-start; +snippet as:s + align-self: stretch; snippet bg+ - background: #${1:FFF} url(${2}) ${3:0} ${4:0} ${0:no-repeat}; + background: #${1:fff} url(${2}) ${3:0} ${4:0} ${5:no-repeat};${0} snippet bga - background-attachment: ${0}; + background-attachment: ${1};${0} snippet bga:f background-attachment: fixed; snippet bga:s background-attachment: scroll; snippet bgbk - background-break: ${0}; + background-break: ${1};${0} snippet bgbk:bb background-break: bounding-box; snippet bgbk:c @@ -52,7 +92,7 @@ snippet bgbk:c snippet bgbk:eb background-break: each-box; snippet bgcp - background-clip: ${0}; + background-clip: ${1};${0} snippet bgcp:bb background-clip: border-box; snippet bgcp:cb @@ -62,15 +102,15 @@ snippet bgcp:nc snippet bgcp:pb background-clip: padding-box; snippet bgc - background-color: #${0:FFF}; + background-color: #${1:fff};${0} snippet bgc:t background-color: transparent; snippet bgi - background-image: url(${0}); + background-image: url(${1});${0} snippet bgi:n background-image: none; snippet bgo - background-origin: ${0}; + background-origin: ${1};${0} snippet bgo:bb background-origin: border-box; snippet bgo:cb @@ -78,13 +118,13 @@ snippet bgo:cb snippet bgo:pb background-origin: padding-box; snippet bgpx - background-position-x: ${0}; + background-position-x: ${1};${0} snippet bgpy - background-position-y: ${0}; + background-position-y: ${1};${0} snippet bgp - background-position: ${1:0} ${0:0}; + background-position: ${1:0} ${2:0};${0} snippet bgr - background-repeat: ${0}; + background-repeat: ${1};${0} snippet bgr:n background-repeat: no-repeat; snippet bgr:x @@ -94,7 +134,7 @@ snippet bgr:y snippet bgr:r background-repeat: repeat; snippet bgz - background-size: ${0}; + background-size: ${1};${0} snippet bgz:a background-size: auto; snippet bgz:ct @@ -102,67 +142,67 @@ snippet bgz:ct snippet bgz:cv background-size: cover; snippet bg - background: ${0}; + background: ${1};${0} snippet bg:ie filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${0:crop}'); snippet bg:n background: none; snippet bd+ - border: ${1:1px} ${2:solid} #${0:000}; + border: ${1:1px} ${2:solid} #${3:000};${0} snippet bdb+ - border-bottom: ${1:1px} ${2:solid} #${0:000}; + border-bottom: ${1:1px} ${2:solid} #${3:000};${0} snippet bdbc - border-bottom-color: #${0:000}; + border-bottom-color: #${1:000};${0} snippet bdbi - border-bottom-image: url(${0}); + border-bottom-image: url(${1});${0} snippet bdbi:n border-bottom-image: none; snippet bdbli - border-bottom-left-image: url(${0}); + border-bottom-left-image: url(${1});${0} snippet bdbli:c border-bottom-left-image: continue; snippet bdbli:n border-bottom-left-image: none; snippet bdblrz - border-bottom-left-radius: ${0}; + border-bottom-left-radius: ${1};${0} snippet bdbri - border-bottom-right-image: url(${0}); + border-bottom-right-image: url(${1});${0} snippet bdbri:c border-bottom-right-image: continue; snippet bdbri:n border-bottom-right-image: none; snippet bdbrrz - border-bottom-right-radius: ${0}; + border-bottom-right-radius: ${1};${0} snippet bdbs - border-bottom-style: ${0}; + border-bottom-style: ${1};${0} snippet bdbs:n border-bottom-style: none; snippet bdbw - border-bottom-width: ${0}; + border-bottom-width: ${1};${0} snippet bdb - border-bottom: ${0}; + border-bottom: ${1};${0} snippet bdb:n border-bottom: none; snippet bdbk - border-break: ${0}; + border-break: ${1};${0} snippet bdbk:c border-break: close; snippet bdcl - border-collapse: ${0}; + border-collapse: ${1};${0} snippet bdcl:c border-collapse: collapse; snippet bdcl:s border-collapse: separate; snippet bdc - border-color: #${0:000}; + border-color: #${1:000};${0} snippet bdci - border-corner-image: url(${0}); + border-corner-image: url(${1});${0} snippet bdci:c border-corner-image: continue; snippet bdci:n border-corner-image: none; snippet bdf - border-fit: ${0}; + border-fit: ${1};${0} snippet bdf:c border-fit: clip; snippet bdf:of @@ -178,55 +218,55 @@ snippet bdf:sp snippet bdf:st border-fit: stretch; snippet bdi - border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; + border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};${0} snippet bdi:n border-image: none; snippet bdl+ - border-left: ${1:1px} ${2:solid} #${0:000}; + border-left: ${1:1px} ${2:solid} #${3:000};${0} snippet bdlc - border-left-color: #${0:000}; + border-left-color: #${1:000};${0} snippet bdli - border-left-image: url(${0}); + border-left-image: url(${1});${0} snippet bdli:n border-left-image: none; snippet bdls - border-left-style: ${0}; + border-left-style: ${1};${0} snippet bdls:n border-left-style: none; snippet bdlw - border-left-width: ${0}; + border-left-width: ${1};${0} snippet bdl - border-left: ${0}; + border-left: ${1};${0} snippet bdl:n border-left: none; snippet bdlt - border-length: ${0}; + border-length: ${1};${0} snippet bdlt:a border-length: auto; snippet bdrz - border-radius: ${0}; + border-radius: ${1};${0} snippet bdr+ - border-right: ${1:1px} ${2:solid} #${0:000}; + border-right: ${1:1px} ${2:solid} #${3:000};${0} snippet bdrc - border-right-color: #${0:000}; + border-right-color: #${1:000};${0} snippet bdri - border-right-image: url(${0}); + border-right-image: url(${1});${0} snippet bdri:n border-right-image: none; snippet bdrs - border-right-style: ${0}; + border-right-style: ${1};${0} snippet bdrs:n border-right-style: none; snippet bdrw - border-right-width: ${0}; + border-right-width: ${1};${0} snippet bdr - border-right: ${0}; + border-right: ${1};${0} snippet bdr:n border-right: none; snippet bdsp - border-spacing: ${0}; + border-spacing: ${1};${0} snippet bds - border-style: ${0}; + border-style: ${1};${0} snippet bds:ds border-style: dashed; snippet bds:dtds @@ -254,69 +294,69 @@ snippet bds:s snippet bds:w border-style: wave; snippet bdt+ - border-top: ${1:1px} ${2:solid} #${0:000}; + border-top: ${1:1px} ${2:solid} #${3:000};${0} snippet bdtc - border-top-color: #${0:000}; + border-top-color: #${1:000};${0} snippet bdti - border-top-image: url(${0}); + border-top-image: url(${1});${0} snippet bdti:n border-top-image: none; snippet bdtli - border-top-left-image: url(${0}); + border-top-left-image: url(${1});${0} snippet bdtli:c border-corner-image: continue; snippet bdtli:n border-corner-image: none; snippet bdtlrz - border-top-left-radius: ${0}; + border-top-left-radius: ${1};${0} snippet bdtri - border-top-right-image: url(${0}); + border-top-right-image: url(${1});${0} snippet bdtri:c border-top-right-image: continue; snippet bdtri:n border-top-right-image: none; snippet bdtrrz - border-top-right-radius: ${0}; + border-top-right-radius: ${1};${0} snippet bdts - border-top-style: ${0}; + border-top-style: ${1};${0} snippet bdts:n border-top-style: none; snippet bdtw - border-top-width: ${0}; + border-top-width: ${1};${0} snippet bdt - border-top: ${0}; + border-top: ${1};${0} snippet bdt:n border-top: none; snippet bdw - border-width: ${0}; + border-width: ${1};${0} snippet bd - border: ${0}; + border: ${1};${0} snippet bd:n border: none; snippet b - bottom: ${0}; + bottom: ${1};${0} snippet b:a bottom: auto; snippet bxsh+ - box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; + box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};${0} snippet bxsh - box-shadow: ${0}; + box-shadow: ${1};${0} snippet bxsh:n box-shadow: none; snippet bxz - box-sizing: ${0}; + box-sizing: ${1};${0} snippet bxz:bb box-sizing: border-box; snippet bxz:cb box-sizing: content-box; snippet cps - caption-side: ${0}; + caption-side: ${1};${0} snippet cps:b caption-side: bottom; snippet cps:t caption-side: top; snippet cl - clear: ${0}; + clear: ${1};${0} snippet cl:b clear: both; snippet cl:l @@ -326,23 +366,23 @@ snippet cl:n snippet cl:r clear: right; snippet cp - clip: ${0}; + clip: ${1};${0} snippet cp:a clip: auto; snippet cp:r - clip: rect(${1:0} ${2:0} ${3:0} ${0:0}); + clip: rect(${1:0} ${2:0} ${3:0} ${4:0});${0} snippet c - color: #${0:000}; + color: #${1:000};${0} snippet ct - content: ${0}; + content: ${1};${0} snippet ct:a - content: attr(${0}); + content: attr(${1});${0} snippet ct:cq content: close-quote; snippet ct:c - content: counter(${0}); + content: counter(${1});${0} snippet ct:cs - content: counters(${0}); + content: counters(${1});${0} snippet ct:ncq content: no-close-quote; snippet ct:noq @@ -352,11 +392,11 @@ snippet ct:n snippet ct:oq content: open-quote; snippet coi - counter-increment: ${0}; + counter-increment: ${1};${0} snippet cor - counter-reset: ${0}; + counter-reset: ${1};${0} snippet cur - cursor: ${0}; + cursor: ${1};${0} snippet cur:a cursor: auto; snippet cur:c @@ -374,7 +414,7 @@ snippet cur:p snippet cur:t cursor: text; snippet d - display: ${0}; + display: ${1};${0} snippet d:mib display: -moz-inline-box; snippet d:mis @@ -383,6 +423,8 @@ snippet d:b display: block; snippet d:cp display: compact; +snippet d:f + display: flex; snippet d:ib display: inline-block; snippet d:itb @@ -414,15 +456,45 @@ snippet d:tbr snippet d:tb display: table; snippet ec - empty-cells: ${0}; + empty-cells: ${1};${0} snippet ec:h empty-cells: hide; snippet ec:s empty-cells: show; snippet exp expression() +snippet fx + flex: ${1:0} ${2:1} ${0:auto}; +snippet fxb + flex-basis: ${0:auto}; +snippet fxb:a + flex-basis: auto; +snippet fxd + flex-direction: ${0:row}; +snippet fxd:c + flex-direction: column; +snippet fxd:cr + flex-direction: column-reverse; +snippet fxd:r + flex-direction: row; +snippet fxd:rr + flex-direction: row-reverse; +snippet fxf + flex-flow: ${1:row} ${0:nowrap}; +snippet fxg + flex-grow: ${0:0}; +snippet fxs + flex-shrink: ${0:1}; +snippet fxw + flex-wrap: ${0:nowrap}; +snippet fxw:n + flex-wrap: nowrap; +snippet fxw:w + flex-wrap: wrap; +snippet fxw:wr + flex-wrap: wrap-reverse; snippet fl - float: ${0}; + float: ${1};${0} snippet fl:l float: left; snippet fl:n @@ -430,9 +502,9 @@ snippet fl:n snippet fl:r float: right; snippet f+ - font: ${1:1em} ${2:Arial},${0:sans-serif}; + font: ${1:1em} ${2:Arial},${3:sans-serif};${0} snippet fef - font-effect: ${0}; + font-effect: ${1};${0} snippet fef:eb font-effect: emboss; snippet fef:eg @@ -442,13 +514,13 @@ snippet fef:n snippet fef:o font-effect: outline; snippet femp - font-emphasize-position: ${0}; + font-emphasize-position: ${1};${0} snippet femp:a font-emphasize-position: after; snippet femp:b font-emphasize-position: before; snippet fems - font-emphasize-style: ${0}; + font-emphasize-style: ${1};${0} snippet fems:ac font-emphasize-style: accent; snippet fems:c @@ -460,9 +532,9 @@ snippet fems:dt snippet fems:n font-emphasize-style: none; snippet fem - font-emphasize: ${0}; + font-emphasize: ${1};${0} snippet ff - font-family: ${0}; + font-family: ${1};${0} snippet ff:c font-family: ${0:'Monotype Corsiva','Comic Sans MS'},cursive; snippet ff:f @@ -474,13 +546,13 @@ snippet ff:ss snippet ff:s font-family: ${0:Georgia,'Times New Roman'},serif; snippet fza - font-size-adjust: ${0}; + font-size-adjust: ${1};${0} snippet fza:n font-size-adjust: none; snippet fz - font-size: ${0}; + font-size: ${1};${0} snippet fsm - font-smooth: ${0}; + font-smooth: ${1};${0} snippet fsm:aw font-smooth: always; snippet fsm:a @@ -488,7 +560,7 @@ snippet fsm:a snippet fsm:n font-smooth: never; snippet fst - font-stretch: ${0}; + font-stretch: ${1};${0} snippet fst:c font-stretch: condensed; snippet fst:e @@ -508,7 +580,7 @@ snippet fst:uc snippet fst:ue font-stretch: ultra-expanded; snippet fs - font-style: ${0}; + font-style: ${1};${0} snippet fs:i font-style: italic; snippet fs:n @@ -516,13 +588,13 @@ snippet fs:n snippet fs:o font-style: oblique; snippet fv - font-variant: ${0}; + font-variant: ${1};${0} snippet fv:n font-variant: normal; snippet fv:sc font-variant: small-caps; snippet fw - font-weight: ${0}; + font-weight: ${1};${0} snippet fw:b font-weight: bold; snippet fw:br @@ -532,31 +604,45 @@ snippet fw:lr snippet fw:n font-weight: normal; snippet f - font: ${0}; + font: ${1};${0} snippet h - height: ${0}; + height: ${1};${0} snippet h:a height: auto; +snippet jc + justify-content: ${0:flex-start}; +snippet jc:c + justify-content: center; +snippet jc:fe + justify-content: flex-end; +snippet jc:fs + justify-content: flex-start; +snippet jc:sa + justify-content: space-around; +snippet jc:sb + justify-content: space-between; +snippet jc:se + justify-content: space-evenly; snippet l - left: ${0}; + left: ${1};${0} snippet l:a left: auto; snippet lts - letter-spacing: ${0}; + letter-spacing: ${1};${0} snippet lh - line-height: ${0}; + line-height: ${1};${0} snippet lisi - list-style-image: url(${0}); + list-style-image: url(${1});${0} snippet lisi:n list-style-image: none; snippet lisp - list-style-position: ${0}; + list-style-position: ${1};${0} snippet lisp:i list-style-position: inside; snippet lisp:o list-style-position: outside; snippet list - list-style-type: ${0}; + list-style-type: ${1};${0} snippet list:c list-style-type: circle; snippet list:dclz @@ -574,75 +660,77 @@ snippet list:s snippet list:ur list-style-type: upper-roman; snippet lis - list-style: ${0}; + list-style: ${1};${0} snippet lis:n list-style: none; snippet mb - margin-bottom: ${0}; + margin-bottom: ${1};${0} snippet mb:a margin-bottom: auto; snippet ml - margin-left: ${0}; + margin-left: ${1};${0} snippet ml:a margin-left: auto; snippet mr - margin-right: ${0}; + margin-right: ${1};${0} snippet mr:a margin-right: auto; snippet mt - margin-top: ${0}; + margin-top: ${1};${0} snippet mt:a margin-top: auto; snippet m - margin: ${0}; + margin: ${1};${0} snippet m:4 - margin: ${1:0} ${2:0} ${3:0} ${0:0}; + margin: ${1:0} ${2:0} ${3:0} ${4:0};${0} snippet m:3 - margin: ${1:0} ${2:0} ${0:0}; + margin: ${1:0} ${2:0} ${3:0};${0} snippet m:2 - margin: ${1:0} ${0:0}; + margin: ${1:0} ${2:0};${0} snippet m:0 margin: 0; snippet m:a margin: auto; snippet mah - max-height: ${0}; + max-height: ${1};${0} snippet mah:n max-height: none; snippet maw - max-width: ${0}; + max-width: ${1};${0} snippet maw:n max-width: none; snippet mih - min-height: ${0}; + min-height: ${1};${0} snippet miw - min-width: ${0}; + min-width: ${1};${0} snippet op - opacity: ${0}; + opacity: ${1};${0} snippet op:ie - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100}); + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=${1:100});${0} snippet op:ms -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100})'; snippet orp - orphans: ${0}; + orphans: ${1};${0} +snippet or + order: ${0:0}; snippet o+ - outline: ${1:1px} ${2:solid} #${0:000}; + outline: ${1:1px} ${2:solid} #${3:000};${0} snippet oc - outline-color: ${0:#000}; + outline-color: ${1:#000};${0} snippet oc:i outline-color: invert; snippet oo - outline-offset: ${0}; + outline-offset: ${1};${0} snippet os - outline-style: ${0}; + outline-style: ${1};${0} snippet ow - outline-width: ${0}; + outline-width: ${1};${0} snippet o - outline: ${0}; + outline: ${1};${0} snippet o:n outline: none; snippet ovs - overflow-style: ${0}; + overflow-style: ${1};${0} snippet ovs:a overflow-style: auto; snippet ovs:mq @@ -654,7 +742,7 @@ snippet ovs:p snippet ovs:s overflow-style: scrollbar; snippet ovx - overflow-x: ${0}; + overflow-x: ${1};${0} snippet ovx:a overflow-x: auto; snippet ovx:h @@ -664,7 +752,7 @@ snippet ovx:s snippet ovx:v overflow-x: visible; snippet ovy - overflow-y: ${0}; + overflow-y: ${1};${0} snippet ovy:a overflow-y: auto; snippet ovy:h @@ -674,7 +762,7 @@ snippet ovy:s snippet ovy:v overflow-y: visible; snippet ov - overflow: ${0}; + overflow: ${1};${0} snippet ov:a overflow: auto; snippet ov:h @@ -684,25 +772,25 @@ snippet ov:s snippet ov:v overflow: visible; snippet pb - padding-bottom: ${0}; + padding-bottom: ${1};${0} snippet pl - padding-left: ${0}; + padding-left: ${1};${0} snippet pr - padding-right: ${0}; + padding-right: ${1};${0} snippet pt - padding-top: ${0}; + padding-top: ${1};${0} snippet p - padding: ${0}; + padding: ${1};${0} snippet p:4 - padding: ${1:0} ${2:0} ${3:0} ${0:0}; + padding: ${1:0} ${2:0} ${3:0} ${4:0};${0} snippet p:3 - padding: ${1:0} ${2:0} ${0:0}; + padding: ${1:0} ${2:0} ${3:0};${0} snippet p:2 - padding: ${1:0} ${0:0}; + padding: ${1:0} ${2:0};${0} snippet p:0 padding: 0; snippet pgba - page-break-after: ${0}; + page-break-after: ${1};${0} snippet pgba:aw page-break-after: always; snippet pgba:a @@ -712,7 +800,7 @@ snippet pgba:l snippet pgba:r page-break-after: right; snippet pgbb - page-break-before: ${0}; + page-break-before: ${1};${0} snippet pgbb:aw page-break-before: always; snippet pgbb:a @@ -722,13 +810,13 @@ snippet pgbb:l snippet pgbb:r page-break-before: right; snippet pgbi - page-break-inside: ${0}; + page-break-inside: ${1};${0} snippet pgbi:a page-break-inside: auto; snippet pgbi:av page-break-inside: avoid; snippet pos - position: ${0}; + position: ${1};${0} snippet pos:a position: absolute; snippet pos:f @@ -738,7 +826,7 @@ snippet pos:r snippet pos:s position: static; snippet q - quotes: ${0}; + quotes: ${1};${0} snippet q:en quotes: '\201C' '\201D' '\2018' '\2019'; snippet q:n @@ -746,7 +834,7 @@ snippet q:n snippet q:ru quotes: '\00AB' '\00BB' '\201E' '\201C'; snippet rz - resize: ${0}; + resize: ${1};${0} snippet rz:b resize: both; snippet rz:h @@ -756,17 +844,17 @@ snippet rz:n snippet rz:v resize: vertical; snippet r - right: ${0}; + right: ${1};${0} snippet r:a right: auto; snippet tbl - table-layout: ${0}; + table-layout: ${1};${0} snippet tbl:a table-layout: auto; snippet tbl:f table-layout: fixed; snippet tal - text-align-last: ${0}; + text-align-last: ${1};${0} snippet tal:a text-align-last: auto; snippet tal:c @@ -776,7 +864,7 @@ snippet tal:l snippet tal:r text-align-last: right; snippet ta - text-align: ${0}; + text-align: ${1};${0} snippet ta:c text-align: center; snippet ta:l @@ -784,7 +872,7 @@ snippet ta:l snippet ta:r text-align: right; snippet td - text-decoration: ${0}; + text-decoration: ${1};${0} snippet td:l text-decoration: line-through; snippet td:n @@ -794,7 +882,7 @@ snippet td:o snippet td:u text-decoration: underline; snippet te - text-emphasis: ${0}; + text-emphasis: ${1};${0} snippet te:ac text-emphasis: accent; snippet te:a @@ -810,7 +898,7 @@ snippet te:dt snippet te:n text-emphasis: none; snippet th - text-height: ${0}; + text-height: ${1};${0} snippet th:a text-height: auto; snippet th:f @@ -820,11 +908,11 @@ snippet th:m snippet th:t text-height: text-size; snippet ti - text-indent: ${0}; + text-indent: ${1};${0} snippet ti:- text-indent: -9999px; snippet tj - text-justify: ${0}; + text-justify: ${1};${0} snippet tj:a text-justify: auto; snippet tj:d @@ -840,23 +928,23 @@ snippet tj:k snippet tj:t text-justify: tibetan; snippet to+ - text-outline: ${1:0} ${2:0} #${0:000}; + text-outline: ${1:0} ${2:0} #${3:000};${0} snippet to - text-outline: ${0}; + text-outline: ${1};${0} snippet to:n text-outline: none; snippet tr - text-replace: ${0}; + text-replace: ${1};${0} snippet tr:n text-replace: none; snippet tsh+ - text-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; + text-shadow: ${1:0} ${2:0} ${3:0} #${4:000};${0} snippet tsh - text-shadow: ${0}; + text-shadow: ${1};${0} snippet tsh:n text-shadow: none; snippet tt - text-transform: ${0}; + text-transform: ${1};${0} snippet tt:c text-transform: capitalize; snippet tt:l @@ -866,7 +954,7 @@ snippet tt:n snippet tt:u text-transform: uppercase; snippet tw - text-wrap: ${0}; + text-wrap: ${1};${0} snippet tw:no text-wrap: none; snippet tw:n @@ -876,11 +964,11 @@ snippet tw:s snippet tw:u text-wrap: unrestricted; snippet t - top: ${0}; + top: ${1};${0} snippet t:a top: auto; snippet va - vertical-align: ${0}; + vertical-align: ${1};${0} snippet va:bl vertical-align: baseline; snippet va:b @@ -898,7 +986,7 @@ snippet va:tt snippet va:t vertical-align: top; snippet v - visibility: ${0}; + visibility: ${1};${0} snippet v:c visibility: collapse; snippet v:h @@ -906,7 +994,7 @@ snippet v:h snippet v:v visibility: visible; snippet whsc - white-space-collapse: ${0}; + white-space-collapse: ${1};${0} snippet whsc:ba white-space-collapse: break-all; snippet whsc:bs @@ -918,7 +1006,7 @@ snippet whsc:l snippet whsc:n white-space-collapse: normal; snippet whs - white-space: ${0}; + white-space: ${1};${0} snippet whs:n white-space: normal; snippet whs:nw @@ -930,13 +1018,13 @@ snippet whs:pw snippet whs:p white-space: pre; snippet wid - widows: ${0}; + widows: ${1};${0} snippet w - width: ${0}; + width: ${1};${0} snippet w:a width: auto; snippet wob - word-break: ${0}; + word-break: ${1};${0} snippet wob:ba word-break: break-all; snippet wob:bs @@ -948,9 +1036,9 @@ snippet wob:l snippet wob:n word-break: normal; snippet wos - word-spacing: ${0}; + word-spacing: ${1};${0} snippet wow - word-wrap: ${0}; + word-wrap: ${1};${0} snippet wow:no word-wrap: none; snippet wow:n @@ -960,7 +1048,7 @@ snippet wow:s snippet wow:u word-wrap: unrestricted; snippet z - z-index: ${0}; + z-index: ${1};${0} snippet z:a z-index: auto; snippet zoo diff --git a/sources_non_forked/vim-snippets/snippets/elixir.snippets b/sources_non_forked/vim-snippets/snippets/elixir.snippets index 9f331b24..64b63f6e 100644 --- a/sources_non_forked/vim-snippets/snippets/elixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/elixir.snippets @@ -126,16 +126,24 @@ snippet doc @doc """ ${0} """ -snippet im - @impl true +snippet docs + @doc ~S""" + ${0} + """ snippet docf @doc false +snippet im + @impl true snippet fn fn ${1:args} -> ${0} end snippet mdoc @moduledoc """ ${0} """ +snippet mdocs + @moduledoc ~S""" + ${0} + """ snippet mdocf @moduledoc false snippet rec @@ -237,3 +245,7 @@ snippet impl def ${1:name} do ${0} end +snippet wl word list + ~w(${0}) +snippet al atom list + ~w(${0})a diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets index 8c4a3e32..2828f2fb 100644 --- a/sources_non_forked/vim-snippets/snippets/php.snippets +++ b/sources_non_forked/vim-snippets/snippets/php.snippets @@ -148,6 +148,12 @@ snippet doc_v * @var ${4:string} */ ${1:var} $${2}; + +# Class attribute with short comment +snippet att + /** @var ${3:string} */ + ${1:public} $${2}; + # Class snippet doc_c /** diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index 0e513cb8..42832815 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -24,8 +24,7 @@ snippet docs # Unittest skip snippet sk "skip unittests" b -@unittest.skip(${1:skip_reason}) -endsnippet + @unittest.skip(${1:skip_reason}) snippet wh while ${1:condition}: @@ -241,7 +240,7 @@ snippet addaarg parser.add_argument("${0:arg}", "${1:long_arg}", action="${2:store_true}", default=${3:False}, help="${4:Help text}") snippet pargs "${VISUAL:return }"parser.parse_args() - + # logging # glog = get log snippet glog @@ -314,14 +313,14 @@ snippet contain "methods for emulating a container type" b def __contains__(self, item): ${7:pass} - + snippet context "context manager methods" b def __enter__(self): ${1:pass} def __exit__(self, exc_type, exc_value, traceback): ${2:pass} - + snippet attr "methods for customizing attribute access" b def __getattr__(self, name): ${1:pass} @@ -331,7 +330,7 @@ snippet attr "methods for customizing attribute access" b def __delattr__(self, name): ${3:pass} - + snippet desc "methods implementing descriptors" b def __get__(self, instance, owner): ${1:pass} @@ -341,7 +340,7 @@ snippet desc "methods implementing descriptors" b def __delete__(self, instance): ${3:pass} - + snippet cmp "methods implementing rich comparison" def __eq__(self, other): ${1:pass} @@ -363,7 +362,7 @@ snippet cmp "methods implementing rich comparison" def __cmp__(self, other): ${7:pass} - + snippet repr "methods implementing string representation" def __repr__(self): ${1:pass} @@ -373,7 +372,7 @@ snippet repr "methods implementing string representation" def __unicode__(self): ${3:pass} - + # note: reflected operands and augmented arithmeitc assignements have been # intentionally ommited to reduce verbosity. snippet numeric "methods for emulating a numeric type" b @@ -454,4 +453,4 @@ snippet numeric "methods for emulating a numeric type" b def __coerce__(self, other): ${25:pass} - + diff --git a/sources_non_forked/vim-snippets/snippets/rust.snippets b/sources_non_forked/vim-snippets/snippets/rust.snippets index 0d7885c7..7a97fdc2 100644 --- a/sources_non_forked/vim-snippets/snippets/rust.snippets +++ b/sources_non_forked/vim-snippets/snippets/rust.snippets @@ -44,7 +44,11 @@ snippet pln, "println! with format param" println!("${1}{${2}}", ${3}); snippet fmt "format!" format!("${1}{${2}}", ${3}); - +snippet d "dbg! debugging macro" + dbg!(${0:${VISUAL}}) +snippet d; "dbg! debugging macro statement" + dbg!(&${1}); + ${0} # Modules snippet ec "extern crate" extern crate ${1:sync}; @@ -72,9 +76,11 @@ snippet testmod "Test module" b test${0} } +snippet ig "#[ignore]" + #[ignore] # Attributes snippet allow "allow lint attribute" b - #[allow(${1:unused_variable})] + #[allow(${1:unused_variables})] snippet cfg "cfg attribute" b #[cfg(${1:target_os = "linux"})] snippet feat "feature attribute" b diff --git a/sources_non_forked/vim-snippets/tests.sh b/sources_non_forked/vim-snippets/tests.sh index 07f0ff31..cacc16ab 100644 --- a/sources_non_forked/vim-snippets/tests.sh +++ b/sources_non_forked/vim-snippets/tests.sh @@ -1,15 +1,37 @@ #!/usr/bin/env bash -SPACED=$(grep -REn '^ .+' --include '*.snippets' snippets) +check=0 -if [[ $? -ne 1 ]]; then - echo These snippet lines are indented with spaces: - echo - echo "$SPACED" - echo - echo Tests failed! +function test_space_indented { + local spaced + spaced=$(grep -REn '^ ' --include '*.snippets' snippets) + + if [[ $? -ne 1 ]]; then + echo "These snippet lines are indented with spaces:" + echo "$spaced" + echo + (( check++ )) + fi +} + +function test_snipmate_format { + local ultisnips_in_snipmate + ultisnips_in_snipmate=$(grep -REn 'endsnippet' --include '*.snippets' snippets) + if [[ $? -ne 1 ]]; then + echo "These snippet definitions are probably in UltiSnips format but stored in the snipmate directory" + echo "$ultisnips_in_snipmate" + echo + (( check++ )) + fi +} + +test_space_indented +test_snipmate_format + +if [ $check -eq 0 ]; then + echo "Tests passed!" + exit 0 +else + echo "$check test(s) failed out of 2!" exit 1 fi - -echo Tests passed! -exit 0