diff --git a/sources_non_forked/ale/after/plugin/ale.vim b/sources_non_forked/ale/after/plugin/ale.vim deleted file mode 100644 index d738dbdd..00000000 --- a/sources_non_forked/ale/after/plugin/ale.vim +++ /dev/null @@ -1,37 +0,0 @@ -" Author: w0rp -" Description: Follow-up checks for the plugin: warn about conflicting plugins. - -" A flag for ensuring that this is not run more than one time. -if exists('g:loaded_ale_after') - finish -endif - -" Set the flag so this file is not run more than one time. -let g:loaded_ale_after = 1 - -" Check if the flag is available and set to 0 to disable checking for and -" emitting conflicting plugin warnings. -if exists('g:ale_emit_conflict_warnings') && !g:ale_emit_conflict_warnings - finish -endif - -" Conflicting Plugins Checks - -function! s:GetConflictingPluginWarning(plugin_name) abort - return 'ALE conflicts with ' . a:plugin_name - \ . '. Uninstall it, or disable this warning with ' - \ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, ' - \ . '*before* plugins are loaded.' -endfunction - -if exists('g:loaded_syntastic_plugin') - throw s:GetConflictingPluginWarning('Syntastic') -endif - -if exists('g:loaded_neomake') - throw s:GetConflictingPluginWarning('Neomake') -endif - -if exists('g:loaded_validator_plugin') - throw s:GetConflictingPluginWarning('Validator') -endif diff --git a/sources_non_forked/ale/ale_linters/cpp/cquery.vim b/sources_non_forked/ale/ale_linters/cpp/cquery.vim new file mode 100644 index 00000000..2fd77d46 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cquery.vim @@ -0,0 +1,34 @@ +" Author: Ben Falconer +" Description: A language server for C++ + +call ale#Set('cpp_cquery_executable', 'cquery') +call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery')) + +function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +function! ale_linters#cpp#cquery#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'cpp_cquery_executable') +endfunction + +function! ale_linters#cpp#cquery#GetCommand(buffer) abort + let l:executable = ale_linters#cpp#cquery#GetExecutable(a:buffer) + return ale#Escape(l:executable) +endfunction + +function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort + return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')} +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cquery', +\ 'lsp': 'stdio', +\ 'executable_callback': 'ale_linters#cpp#cquery#GetExecutable', +\ 'command_callback': 'ale_linters#cpp#cquery#GetCommand', +\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot', +\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions', +\ 'language': 'cpp', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim index c63ecb38..5a7092cf 100644 --- a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim +++ b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim @@ -4,6 +4,7 @@ call ale#Set('cpp_flawfinder_executable', 'flawfinder') call ale#Set('cpp_flawfinder_options', '') call ale#Set('cpp_flawfinder_minlevel', 1) +call ale#Set('c_flawfinder_error_severity', 6) function! ale_linters#cpp#flawfinder#GetExecutable(buffer) abort return ale#Var(a:buffer, 'cpp_flawfinder_executable') diff --git a/sources_non_forked/ale/ale_linters/cpp/gcc.vim b/sources_non_forked/ale/ale_linters/cpp/gcc.vim index 577c9f79..a663eaa3 100644 --- a/sources_non_forked/ale/ale_linters/cpp/gcc.vim +++ b/sources_non_forked/ale/ale_linters/cpp/gcc.vim @@ -21,7 +21,8 @@ function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort endfunction call ale#linter#Define('cpp', { -\ 'name': 'g++', +\ 'name': 'gcc', +\ 'aliases': ['g++'], \ 'output_stream': 'stderr', \ 'executable_callback': 'ale_linters#cpp#gcc#GetExecutable', \ 'command_chain': [ diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index 9f683190..a16dfde2 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -2,7 +2,7 @@ call ale#Set('css_stylelint_executable', 'stylelint') call ale#Set('css_stylelint_options', '') -call ale#Set('css_stylelint_use_global', 0) +call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#css#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'css_stylelint', [ diff --git a/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim new file mode 100644 index 00000000..6708d32f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim @@ -0,0 +1,45 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Cucumber, a BDD test tool + +function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort + let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features') + + if !empty(l:features_dir) + let l:features_arg = '-r ' . ale#Escape(l:features_dir) + else + let l:features_arg = '' + endif + + return 'cucumber --dry-run --quiet --strict --format=json ' + \ . l:features_arg . ' %t' +endfunction + +function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort + try + let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0] + catch + return [] + endtry + + let l:output = [] + for l:element in get(l:json, 'elements', []) + for l:step in l:element['steps'] + if l:step['result']['status'] is# 'undefined' + call add(l:output, { + \ 'lnum': l:step['line'], + \ 'code': 'E', + \ 'text': 'Undefined step' + \}) + endif + endfor + endfor + + return l:output +endfunction + +call ale#linter#Define('cucumber', { +\ 'name': 'cucumber', +\ 'executable': 'cucumber', +\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand', +\ 'callback': 'ale_linters#cucumber#cucumber#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/d/dmd.vim b/sources_non_forked/ale/ale_linters/d/dmd.vim index b91238ae..d64b6c3d 100644 --- a/sources_non_forked/ale/ale_linters/d/dmd.vim +++ b/sources_non_forked/ale/ale_linters/d/dmd.vim @@ -46,7 +46,7 @@ function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort endif endfor - return 'dmd '. join(l:import_list) . ' -o- -vcolumns -c %t' + return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t' endfunction function! ale_linters#d#dmd#Handle(buffer, lines) abort 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 15c77017..bed77c52 100644 --- a/sources_non_forked/ale/ale_linters/dart/language_server.vim +++ b/sources_non_forked/ale/ale_linters/dart/language_server.vim @@ -7,10 +7,6 @@ function! ale_linters#dart#language_server#GetExecutable(buffer) abort return ale#Var(a:buffer, 'dart_language_server_executable') endfunction -function! ale_linters#dart#language_server#GetLanguage(buffer) abort - return 'dart' -endfunction - function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort " Note: pub only looks for pubspec.yaml, there's no point in adding " support for pubspec.yml @@ -24,7 +20,6 @@ call ale#linter#Define('dart', { \ 'lsp': 'stdio', \ 'executable_callback': 'ale_linters#dart#language_server#GetExecutable', \ 'command_callback': 'ale_linters#dart#language_server#GetExecutable', -\ 'language_callback': 'ale_linters#dart#language_server#GetLanguage', +\ 'language': 'dart', \ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot', \}) - diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index 3783b5e3..cc14fe4e 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -1,45 +1,26 @@ -" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod +" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod, hecrj - https://github.com/hecrj " Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim. -call ale#Set('elm_make_executable', 'elm-make') -call ale#Set('elm_make_use_global', 0) +call ale#Set('elm_make_executable', 'elm') +call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#elm#make#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'elm_make', [ - \ 'node_modules/.bin/elm-make', + \ 'node_modules/.bin/elm', \]) endfunction function! ale_linters#elm#make#Handle(buffer, lines) abort let l:output = [] - let l:is_windows = has('win32') - let l:temp_dir = l:is_windows ? $TMP : $TMPDIR let l:unparsed_lines = [] + for l:line in a:lines - if l:line[0] is# '[' - let l:errors = json_decode(l:line) - - for l:error in l:errors - " Check if file is from the temp directory. - " Filters out any errors not related to the buffer. - if l:is_windows - let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is? l:temp_dir - else - let l:file_is_buffer = l:error.file[0:len(l:temp_dir) - 1] is# l:temp_dir - endif - - if l:file_is_buffer - call add(l:output, { - \ 'lnum': l:error.region.start.line, - \ 'col': l:error.region.start.column, - \ 'end_lnum': l:error.region.end.line, - \ 'end_col': l:error.region.end.column, - \ 'type': (l:error.type is? 'error') ? 'E' : 'W', - \ 'text': l:error.overview, - \ 'detail': l:error.overview . "\n\n" . l:error.details - \}) - endif - endfor + if l:line[0] is# '{' + " Elm 0.19 + call ale_linters#elm#make#HandleElm019Line(l:line, l:output) + elseif l:line[0] is# '[' + " Elm 0.18 + call ale_linters#elm#make#HandleElm018Line(l:line, l:output) elseif l:line isnot# 'Successfully generated /dev/null' call add(l:unparsed_lines, l:line) endif @@ -57,23 +38,142 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#elm#make#HandleElm019Line(line, output) abort + let l:report = json_decode(a:line) + + if l:report.type is? 'error' + " General problem + let l:details = ale_linters#elm#make#ParseMessage(l:report.message) + + if empty(l:report.path) + let l:report.path = 'Elm' + endif + + if ale_linters#elm#make#FileIsBuffer(l:report.path) + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:details, + \}) + else + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:report.path .' - '. l:details, + \ 'detail': l:report.path ." ----------\n\n". l:details, + \}) + endif + else + " Compilation errors + for l:error in l:report.errors + let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path) + + for l:problem in l:error.problems + let l:details = ale_linters#elm#make#ParseMessage(l:problem.message) + + if l:file_is_buffer + " Buffer module has problems + call add(a:output, { + \ 'lnum': l:problem.region.start.line, + \ 'col': l:problem.region.start.column, + \ 'end_lnum': l:problem.region.end.line, + \ 'end_col': l:problem.region.end.column, + \ 'type': 'E', + \ 'text': l:details, + \}) + else + " Imported module has problems + let l:location = l:error.path .':'. l:problem.region.start.line + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:location .' - '. l:details, + \ 'detail': l:location ." ----------\n\n". l:details, + \}) + endif + endfor + endfor + endif +endfunction + +function! ale_linters#elm#make#HandleElm018Line(line, output) abort + let l:errors = json_decode(a:line) + + for l:error in l:errors + let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.file) + + if l:file_is_buffer + " Current buffer has problems + call add(a:output, { + \ 'lnum': l:error.region.start.line, + \ 'col': l:error.region.start.column, + \ 'end_lnum': l:error.region.end.line, + \ 'end_col': l:error.region.end.column, + \ 'type': (l:error.type is? 'error') ? 'E' : 'W', + \ 'text': l:error.overview, + \ 'detail': l:error.overview . "\n\n" . l:error.details + \}) + elseif l:error.type is? 'error' + " Imported module has errors + let l:location = l:error.file .':'. l:error.region.start.line + + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:location .' - '. l:error.overview, + \ 'detail': l:location ." ----------\n\n". l:error.overview . "\n\n" . l:error.details + \}) + endif + endfor +endfunction + +function! ale_linters#elm#make#FileIsBuffer(path) abort + let l:is_windows = has('win32') + let l:temp_dir = l:is_windows ? $TMP : $TMPDIR + + if has('win32') + return a:path[0:len(l:temp_dir) - 1] is? l:temp_dir + else + return a:path[0:len(l:temp_dir) - 1] is# l:temp_dir + endif +endfunction + +function! ale_linters#elm#make#ParseMessage(message) abort + return join(map(copy(a:message), 'ale_linters#elm#make#ParseMessageItem(v:val)'), '') +endfunction + +function! ale_linters#elm#make#ParseMessageItem(item) abort + if type(a:item) == type('') + return a:item + else + return a:item.string + endif +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:elm_package = ale#path#FindNearestFile(a:buffer, 'elm-package.json') + let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') let l:elm_exe = ale_linters#elm#make#GetExecutable(a:buffer) - if empty(l:elm_package) + + if empty(l:elm_json) + " Fallback to Elm 0.18 + let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json') + endif + + if empty(l:elm_json) let l:dir_set_cmd = '' else - let l:root_dir = fnamemodify(l:elm_package, ':p:h') + let l:root_dir = fnamemodify(l:elm_json, ':p:h') let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' endif - " The elm-make compiler, at the time of this writing, uses '/dev/null' as + " 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. It does not use NUL on Windows. - " Source: https://github.com/elm-lang/elm-make/blob/master/src/Flags.hs + " which is why this is hard coded here. + " Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 let l:elm_cmd = ale#Escape(l:elm_exe) + \ . ' make' \ . ' --report=json' \ . ' --output=/dev/null' diff --git a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim index 49aeda7c..64731055 100644 --- a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim +++ b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim @@ -4,7 +4,7 @@ let g:ale_gitcommit_gitlint_executable = \ get(g:, 'ale_gitcommit_gitlint_executable', 'gitlint') let g:ale_gitcommit_gitlint_options = get(g:, 'ale_gitcommit_gitlint_options', '') -let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', 0) +let g:ale_gitcommit_gitlint_use_global = get(g:, 'ale_gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort @@ -28,6 +28,10 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:code = l:match[2] + if l:code is# 'T2' && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + continue + endif + let l:item = { \ 'lnum': l:match[1] + 0, \ 'text': l:match[3], diff --git a/sources_non_forked/ale/ale_linters/glsl/glslls.vim b/sources_non_forked/ale/ale_linters/glsl/glslls.vim index 67ea379c..c19f28c2 100644 --- a/sources_non_forked/ale/ale_linters/glsl/glslls.vim +++ b/sources_non_forked/ale/ale_linters/glsl/glslls.vim @@ -18,10 +18,6 @@ function! ale_linters#glsl#glslls#GetCommand(buffer) abort return ale#Escape(l:executable) . l:logfile_args . ' --stdin' endfunction -function! ale_linters#glsl#glslls#GetLanguage(buffer) abort - return 'glsl' -endfunction - function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort let l:project_root = ale#c#FindProjectRoot(a:buffer) @@ -33,6 +29,6 @@ call ale#linter#Define('glsl', { \ 'lsp': 'stdio', \ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable', \ 'command_callback': 'ale_linters#glsl#glslls#GetCommand', -\ 'language_callback': 'ale_linters#glsl#glslls#GetLanguage', +\ 'language': 'glsl', \ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 68ea7155..162a033c 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -2,7 +2,7 @@ " Description: Ember-template-lint for checking Handlebars files call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') -call ale#Set('handlebars_embertemplatelint_use_global', 0) +call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ diff --git a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim index 93c7ddd6..dc902152 100644 --- a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim +++ b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim @@ -2,7 +2,7 @@ " Description: hdevtools for Haskell files call ale#Set('haskell_hdevtools_executable', 'hdevtools') -call ale#Set('haskell_hdevtools_options', '-g -Wall') +call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall')) function! ale_linters#haskell#hdevtools#GetExecutable(buffer) abort return ale#Var(a:buffer, 'haskell_hdevtools_executable') diff --git a/sources_non_forked/ale/ale_linters/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim index 88a83f1d..caa15bbb 100644 --- a/sources_non_forked/ale/ale_linters/html/htmlhint.vim +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -3,7 +3,7 @@ call ale#Set('html_htmlhint_options', '') call ale#Set('html_htmlhint_executable', 'htmlhint') -call ale#Set('html_htmlhint_use_global', 0) +call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#html#htmlhint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'html_htmlhint', [ diff --git a/sources_non_forked/ale/ale_linters/html/tidy.vim b/sources_non_forked/ale/ale_linters/html/tidy.vim index 34152c6b..3af64d74 100644 --- a/sources_non_forked/ale/ale_linters/html/tidy.vim +++ b/sources_non_forked/ale/ale_linters/html/tidy.vim @@ -3,11 +3,19 @@ " CLI options let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy') +" remove in 2.0 " Look for the old _args variable first. +let s:deprecation_warning_echoed = 0 let s:default_options = get(g:, 'ale_html_tidy_args', '-q -e -language en') let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', s:default_options) function! ale_linters#html#tidy#GetCommand(buffer) abort + " remove in 2.0 + if exists('g:ale_html_tidy_args') && !s:deprecation_warning_echoed + execute 'echom ''Rename your g:ale_html_tidy_args setting to g:ale_html_tidy_options instead. Support for this will removed in ALE 2.0.''' + let s:deprecation_warning_echoed = 1 + endif + " Specify file encoding in options " (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim) let l:file_encoding = get({ diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index 73e84147..b1f74a6d 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -3,8 +3,9 @@ let s:classpath_sep = has('unix') ? ':' : ';' -let g:ale_java_javac_options = get(g:, 'ale_java_javac_options', '') -let g:ale_java_javac_classpath = get(g:, 'ale_java_javac_classpath', '') +call ale#Set('java_javac_executable', 'javac') +call ale#Set('java_javac_options', '') +call ale#Set('java_javac_classpath', '') function! ale_linters#java#javac#GetImportPaths(buffer) abort let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') @@ -35,6 +36,10 @@ function! s:BuildClassPathOption(buffer, import_paths) abort \ : '' endfunction +function! ale_linters#java#javac#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'java_javac_executable') +endfunction + function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths) let l:sp_option = '' @@ -72,11 +77,13 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort " Create .class files in a temporary directory, which we will delete later. let l:class_file_directory = ale#engine#CreateDirectory(a:buffer) + let l:executable = ale_linters#java#javac#GetExecutable(a:buffer) " Always run javac from the directory the file is in, so we can resolve " relative paths correctly. return ale#path#BufferCdString(a:buffer) - \ . 'javac -Xlint' + \ . ale#Escape(l:executable) + \ . ' -Xlint' \ . ' ' . l:cp_option \ . ' ' . l:sp_option \ . ' -d ' . ale#Escape(l:class_file_directory) @@ -119,7 +126,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javac', -\ 'executable': 'javac', +\ 'executable_callback': 'ale_linters#java#javac#GetExecutable', \ '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/pmd.vim b/sources_non_forked/ale/ale_linters/java/pmd.vim new file mode 100644 index 00000000..d461e094 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/pmd.vim @@ -0,0 +1,36 @@ +" Author: Johannes Wienke +" Description: PMD for Java files + +function! ale_linters#java#pmd#Handle(buffer, lines) abort + let l:pattern = '"\(\d\+\)",".\+","\(.\+\)","\(\d\+\)","\(\d\+\)","\(.\+\)","\(.\+\)","\(.\+\)"$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': 'W', + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[5], + \ 'code': l:match[6] . ' - ' . l:match[7], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#java#pmd#GetCommand(buffer) abort + return 'pmd ' + \ . ale#Var(a:buffer, 'java_pmd_options') + \ . ' -f csv' + \ . ' -d %t' +endfunction + +if !exists('g:ale_java_pmd_options') + let g:ale_java_pmd_options = '-R category/java/bestpractices.xml' +endif + +call ale#linter#Define('java', { +\ 'name': 'pmd', +\ 'executable': 'pmd', +\ 'command_callback': 'ale_linters#java#pmd#GetCommand', +\ 'callback': 'ale_linters#java#pmd#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/flow.vim b/sources_non_forked/ale/ale_linters/javascript/flow.vim index 643ea190..d555184e 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow.vim @@ -4,7 +4,8 @@ call ale#Set('javascript_flow_executable', 'flow') call ale#Set('javascript_flow_use_home_config', 0) -call ale#Set('javascript_flow_use_global', 0) +call ale#Set('javascript_flow_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_flow_use_respect_pragma', 1) function! ale_linters#javascript#flow#GetExecutable(buffer) abort let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') @@ -47,8 +48,8 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort " If we can parse the version number, then only use --respect-pragma " if the version is >= 0.36.0, which added the argument. - let l:use_respect_pragma = empty(l:version) - \ || ale#semver#GTE(l:version, [0, 36]) + let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma') + \ && (empty(l:version) || ale#semver#GTE(l:version, [0, 36])) return ale#Escape(l:executable) \ . ' check-contents' diff --git a/sources_non_forked/ale/ale_linters/javascript/jscs.vim b/sources_non_forked/ale/ale_linters/javascript/jscs.vim index bcf3ee3a..60044037 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jscs.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -2,7 +2,7 @@ " Description: jscs for JavaScript files call ale#Set('javascript_jscs_executable', 'jscs') -call ale#Set('javascript_jscs_use_global', 0) +call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#javascript#jscs#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_jscs', [ diff --git a/sources_non_forked/ale/ale_linters/javascript/jshint.vim b/sources_non_forked/ale/ale_linters/javascript/jshint.vim index 93b16a8f..2e9bb9fd 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jshint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -2,7 +2,7 @@ " Description: JSHint for Javascript files call ale#Set('javascript_jshint_executable', 'jshint') -call ale#Set('javascript_jshint_use_global', 0) +call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#javascript#jshint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [ diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim index aa6a3a72..f16b837a 100644 --- a/sources_non_forked/ale/ale_linters/javascript/standard.vim +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -2,7 +2,7 @@ " Description: standardjs for JavaScript files call ale#Set('javascript_standard_executable', 'standard') -call ale#Set('javascript_standard_use_global', 0) +call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/javascript/xo.vim b/sources_non_forked/ale/ale_linters/javascript/xo.vim index cf305eb4..bc8657ed 100644 --- a/sources_non_forked/ale/ale_linters/javascript/xo.vim +++ b/sources_non_forked/ale/ale_linters/javascript/xo.vim @@ -2,7 +2,7 @@ " Description: xo for JavaScript files call ale#Set('javascript_xo_executable', 'xo') -call ale#Set('javascript_xo_use_global', 0) +call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_xo_options', '') function! ale_linters#javascript#xo#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/less/lessc.vim b/sources_non_forked/ale/ale_linters/less/lessc.vim index 108679de..5fd9a383 100644 --- a/sources_non_forked/ale/ale_linters/less/lessc.vim +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -3,7 +3,7 @@ call ale#Set('less_lessc_executable', 'lessc') call ale#Set('less_lessc_options', '') -call ale#Set('less_lessc_use_global', 0) +call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#less#lessc#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'less_lessc', [ diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim index 690c8c93..8e16a098 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -2,7 +2,7 @@ call ale#Set('less_stylelint_executable', 'stylelint') call ale#Set('less_stylelint_options', '') -call ale#Set('less_stylelint_use_global', 0) +call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#less#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'less_stylelint', [ diff --git a/sources_non_forked/ale/ale_linters/markdown/mdl.vim b/sources_non_forked/ale/ale_linters/markdown/mdl.vim index 16b08cc5..0953144b 100644 --- a/sources_non_forked/ale/ale_linters/markdown/mdl.vim +++ b/sources_non_forked/ale/ale_linters/markdown/mdl.vim @@ -10,9 +10,13 @@ endfunction function! ale_linters#markdown#mdl#GetCommand(buffer) abort let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'bundle$' + \ ? ' exec mdl' + \ : '' + let l:options = ale#Var(a:buffer, 'markdown_mdl_options') - return ale#Escape(l:executable) + return ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') endfunction diff --git a/sources_non_forked/ale/ale_linters/mercury/mmc.vim b/sources_non_forked/ale/ale_linters/mercury/mmc.vim new file mode 100644 index 00000000..c7bfc59d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -0,0 +1,45 @@ +" Author: stewy33 +" Description: Lints mercury files using mmc + +call ale#Set('mercury_mmc_executable', 'mmc') +call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') + +function! ale_linters#mercury#mmc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'mercury_mmc_executable') +endfunction + +function! ale_linters#mercury#mmc#GetCommand(buffer) abort + let l:module_name = expand('#' . a:buffer . ':t:r') + + return ale#path#BufferCdString(a:buffer) + \ . ale_linters#mercury#mmc#GetExecutable(a:buffer) + \ . ' --errorcheck-only ' + \ . ale#Var(a:buffer, 'mercury_mmc_options') + \ . ' ' . l:module_name +endfunction + +function! ale_linters#mercury#mmc#Handle(buffer, lines) abort + " output format + " :: : + let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': substitute(l:match[1], '\v^0*', '', '') + 0, + \ 'type': l:match[2][0] =~? 'W' ? 'W' : 'E', + \ 'text': l:match[2] . ': ' . l:match[3] + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('mercury', { +\ 'name': 'mmc', +\ 'output_stream': 'stderr', +\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable', +\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand', +\ 'callback': 'ale_linters#mercury#mmc#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/nasm/nasm.vim b/sources_non_forked/ale/ale_linters/nasm/nasm.vim new file mode 100644 index 00000000..f4b2ca4b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -0,0 +1,50 @@ +" Author: Oyvind Ingvaldsen +" Description: NASM linter for asmsyntax nasm. + +call ale#Set('nasm_nasm_executable', 'nasm') +call ale#Set('nasm_nasm_options', '') + +function! ale_linters#nasm#nasm#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'nasm_nasm_executable') +endfunction + +function! ale_linters#nasm#nasm#GetOptions(buffer) abort + return ale#Var(a:buffer, 'nasm_nasm_options') +endfunction + +function! ale_linters#nasm#nasm#GetCommand(buffer) abort + " Note that NASM require a trailing slash to the -I option. + let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer)) + let l:separator = has('win32') ? '\' : '/' + let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator) + let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer) + + return l:executable + \ . ' -X gnu' + \ . ' -I ' . l:path + \ . ' ' . l:options + \ . ' %s' +endfunction + +function! ale_linters#nasm#nasm#Handle(buffer, lines) abort + " Note that we treat 'fatal' as errors. + let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] =~? 'error\|fatal' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + return l:output +endfunction + +call ale#linter#Define('nasm', { +\ 'name': 'nasm', +\ 'executable': 'nasm', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand', +\ 'callback': 'ale_linters#nasm#nasm#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ols.vim b/sources_non_forked/ale/ale_linters/ocaml/ols.vim index c0255a6c..077862fc 100644 --- a/sources_non_forked/ale/ale_linters/ocaml/ols.vim +++ b/sources_non_forked/ale/ale_linters/ocaml/ols.vim @@ -2,7 +2,7 @@ " Description: A language server for OCaml call ale#Set('ocaml_ols_executable', 'ocaml-language-server') -call ale#Set('ocaml_ols_use_global', 0) +call ale#Set('ocaml_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('ocaml', { \ 'name': 'ols', diff --git a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim index 24f7eb86..e91c8a03 100644 --- a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim +++ b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim @@ -18,9 +18,9 @@ function! ale_linters#perl#perlcritic#GetExecutable(buffer) abort endfunction function! ale_linters#perl#perlcritic#GetProfile(buffer) abort - " first see if we've been overridden let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile') + if l:profile is? '' return '' endif @@ -31,6 +31,7 @@ endfunction function! ale_linters#perl#perlcritic#GetCommand(buffer) abort let l:critic_verbosity = '%l:%c %m\n' + if ale#Var(a:buffer, 'perl_perlcritic_showrules') let l:critic_verbosity = '%l:%c %m [%p]\n' endif @@ -38,17 +39,11 @@ function! ale_linters#perl#perlcritic#GetCommand(buffer) abort let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer) let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') - let l:command = ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) - \ . " --verbose '". l:critic_verbosity . "' --nocolor" - - if l:profile isnot? '' - let l:command .= ' --profile ' . ale#Escape(l:profile) - endif - if l:options isnot? '' - let l:command .= ' ' . l:options - endif - - return l:command + return ale#Escape(ale_linters#perl#perlcritic#GetExecutable(a:buffer)) + \ . ' --verbose ' . ale#Escape(l:critic_verbosity) + \ . ' --nocolor' + \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') endfunction diff --git a/sources_non_forked/ale/ale_linters/php/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim index be2d6ef1..0f3ead66 100644 --- a/sources_non_forked/ale/ale_linters/php/langserver.vim +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -2,7 +2,7 @@ " Description: PHP Language server integration for ALE call ale#Set('php_langserver_executable', 'php-language-server.php') -call ale#Set('php_langserver_use_global', 0) +call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#langserver#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'php_langserver', [ @@ -14,10 +14,6 @@ function! ale_linters#php#langserver#GetCommand(buffer) abort return 'php ' . ale#Escape(ale_linters#php#langserver#GetExecutable(a:buffer)) endfunction -function! ale_linters#php#langserver#GetLanguage(buffer) abort - return 'php' -endfunction - function! ale_linters#php#langserver#GetProjectRoot(buffer) abort let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') @@ -29,6 +25,6 @@ call ale#linter#Define('php', { \ 'lsp': 'stdio', \ 'executable_callback': 'ale_linters#php#langserver#GetExecutable', \ 'command_callback': 'ale_linters#php#langserver#GetCommand', -\ 'language_callback': 'ale_linters#php#langserver#GetLanguage', +\ 'language': 'php', \ 'project_root_callback': '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 f3b3d48f..c6f16356 100644 --- a/sources_non_forked/ale/ale_linters/php/phan.vim +++ b/sources_non_forked/ale/ale_linters/php/phan.vim @@ -1,28 +1,65 @@ -" Author: diegoholiveira +" Author: diegoholiveira , haginaga " Description: static analyzer for PHP " Define the minimum severity let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0) +let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan') +let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0) + +function! ale_linters#php#phan#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'php_phan_executable') + + if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan' + let l:executable = 'phan_client' + endif + + return l:executable +endfunction + function! ale_linters#php#phan#GetCommand(buffer) abort - return 'phan -y ' - \ . ale#Var(a:buffer, 'php_phan_minimum_severity') - \ . ' %s' + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + let l:args = '-l ' + \ . ' %s' + else + let l:args = '-y ' + \ . ale#Var(a:buffer, 'php_phan_minimum_severity') + \ . ' %s' + endif + + let l:executable = ale_linters#php#phan#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:args endfunction function! ale_linters#php#phan#Handle(buffer, lines) abort " Matches against lines like the following: - " - " /path/to/some-filename.php:18 ERRORTYPE message - let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + " Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn + let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$' + else + " /path/to/some-filename.php:18 ERRORTYPE message + let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + endif + let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[3], - \ 'type': 'W', - \}) + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + let l:dict = { + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[2], + \ 'type': 'W', + \} + else + let l:dict = { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \} + endif + + call add(l:output, l:dict) endfor return l:output @@ -30,7 +67,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phan', -\ 'executable': 'phan', +\ 'executable_callback': 'ale_linters#php#phan#GetExecutable', \ 'command_callback': 'ale_linters#php#phan#GetCommand', \ 'callback': 'ale_linters#php#phan#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index 399fbd23..faf8ad55 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -4,7 +4,7 @@ let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '') call ale#Set('php_phpcs_executable', 'phpcs') -call ale#Set('php_phpcs_use_global', 0) +call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#phpcs#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'php_phpcs', [ diff --git a/sources_non_forked/ale/ale_linters/po/msgfmt.vim b/sources_non_forked/ale/ale_linters/po/msgfmt.vim index 578792bf..8279ccdc 100644 --- a/sources_non_forked/ale/ale_linters/po/msgfmt.vim +++ b/sources_non_forked/ale/ale_linters/po/msgfmt.vim @@ -1,10 +1,30 @@ " Author: Cian Butler https://github.com/butlerx " Description: msgfmt for PO files +function! ale_linters#po#msgfmt#Handle(buffer, lines) abort + let l:results = ale#handlers#unix#HandleAsWarning(a:buffer, a:lines) + let l:index = 0 + + for l:item in l:results + if l:index > 0 && l:item.text =~? 'this is the location of the first definition' + let l:last_item = l:results[l:index - 1] + + if l:last_item.text =~? 'duplicate message definition' + let l:last_item.text = 'duplicate of message at line ' . l:item.lnum + let l:item.text = 'first location of duplicate of message at line ' . l:last_item.lnum + endif + endif + + let l:index += 1 + endfor + + return l:results +endfunction + call ale#linter#Define('po', { \ 'name': 'msgfmt', \ 'executable': 'msgfmt', \ 'output_stream': 'stderr', \ 'command': 'msgfmt --statistics --output-file=- %t', -\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\ 'callback': 'ale_linters#po#msgfmt#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim index 6c29efe9..165e68b7 100644 --- a/sources_non_forked/ale/ale_linters/pug/puglint.vim +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -3,7 +3,7 @@ call ale#Set('pug_puglint_options', '') call ale#Set('pug_puglint_executable', 'pug-lint') -call ale#Set('pug_puglint_use_global', 0) +call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#pug#puglint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'pug_puglint', [ diff --git a/sources_non_forked/ale/ale_linters/puppet/puppet.vim b/sources_non_forked/ale/ale_linters/puppet/puppet.vim index 8beeb61e..4ca0dd55 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppet.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppet.vim @@ -4,14 +4,15 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Matches patterns like the following: " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5" + " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5) - let l:pattern = '^Error: .*: \(.\+\) at .\+\.pp:\(\d\+\):\=\(\d*\)' + let l:pattern = '^Error: .*: \(.\+\) \((file:\|at\) .\+\.pp\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, + \ 'lnum': l:match[4] + 0, + \ 'col': l:match[6] + 0, \ 'text': l:match[1], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index e7bbcfb1..fdc4ac94 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -1,14 +1,15 @@ " Author: w0rp " Description: flake8 for python files -let g:ale_python_flake8_executable = -\ get(g:, 'ale_python_flake8_executable', 'flake8') - +" remove in 2.0 " Support an old setting as a fallback. +let s:deprecation_warning_echoed = 0 let s:default_options = get(g:, 'ale_python_flake8_args', '') -let g:ale_python_flake8_options = -\ get(g:, 'ale_python_flake8_options', s:default_options) -let g:ale_python_flake8_use_global = get(g:, 'ale_python_flake8_use_global', 0) + +call ale#Set('python_flake8_executable', 'flake8') +call ale#Set('python_flake8_options', s:default_options) +call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_flake8_change_directory', 1) function! s:UsingModule(buffer) abort return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8' @@ -39,9 +40,22 @@ function! ale_linters#python#flake8#VersionCheck(buffer) abort endfunction function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort + " remove in 2.0 + if exists('g:ale_python_flake8_args') && !s:deprecation_warning_echoed + execute 'echom ''Rename your g:ale_python_flake8_args setting to g:ale_python_flake8_options instead. Support for this will removed in ALE 2.0.''' + let s:deprecation_warning_echoed = 1 + endif + + let l:cd_string = ale#Var(a:buffer, 'python_flake8_change_directory') + \ ? ale#path#BufferCdString(a:buffer) + \ : '' let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) let l:version = ale#semver#GetVersion(l:executable, a:version_output) + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run flake8' + \ : '' + " Only include the --stdin-display-name argument if we can parse the " flake8 version, and it is recent enough to support it. let l:display_name_args = ale#semver#GTE(l:version, [3, 0, 0]) @@ -50,7 +64,8 @@ function! ale_linters#python#flake8#GetCommand(buffer, version_output) abort let l:options = ale#Var(a:buffer, 'python_flake8_options') - return ale#Escape(l:executable) + return l:cd_string + \ . ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --format=default' \ . l:display_name_args . ' -' diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim index c1c91742..b38ccdeb 100644 --- a/sources_non_forked/ale/ale_linters/python/mypy.vim +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -4,7 +4,7 @@ call ale#Set('python_mypy_executable', 'mypy') call ale#Set('python_mypy_ignore_invalid_syntax', 0) call ale#Set('python_mypy_options', '') -call ale#Set('python_mypy_use_global', 0) +call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#python#mypy#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy']) @@ -23,10 +23,14 @@ function! ale_linters#python#mypy#GetCommand(buffer) abort let l:dir = s:GetDir(a:buffer) let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run mypy' + \ : '' + " We have to always switch to an explicit directory for a command so " we can know with certainty the base path for the 'filename' keys below. return ale#path#CdString(l:dir) - \ . ale#Escape(l:executable) + \ . ale#Escape(l:executable) . l:exec_args \ . ' --show-column-numbers ' \ . ale#Var(a:buffer, 'python_mypy_options') \ . ' --shadow-file %s %t %s' diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim index 66af598a..eadfee47 100644 --- a/sources_non_forked/ale/ale_linters/python/prospector.vim +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -7,14 +7,21 @@ let g:ale_python_prospector_executable = let g:ale_python_prospector_options = \ get(g:, 'ale_python_prospector_options', '') -let g:ale_python_prospector_use_global = get(g:, 'ale_python_prospector_use_global', 0) +let g:ale_python_prospector_use_global = get(g:, 'ale_python_prospector_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#python#prospector#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector']) endfunction function! ale_linters#python#prospector#GetCommand(buffer) abort - return ale#Escape(ale_linters#python#prospector#GetExecutable(a:buffer)) + let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run prospector' + \ : '' + + return ale#Escape(l:executable) + \ . l:exec_args \ . ' ' . ale#Var(a:buffer, 'python_prospector_options') \ . ' --messages-only --absolute-paths --zero-exit --output-format json' \ . ' %s' diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim index 19f05a53..de96363f 100644 --- a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -3,14 +3,20 @@ call ale#Set('python_pycodestyle_executable', 'pycodestyle') call ale#Set('python_pycodestyle_options', '') -call ale#Set('python_pycodestyle_use_global', 0) +call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle']) endfunction function! ale_linters#python#pycodestyle#GetCommand(buffer) abort - return ale#Escape(ale_linters#python#pycodestyle#GetExecutable(a:buffer)) + let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run pycodestyle' + \ : '' + + return ale#Escape(l:executable) . l:exec_args \ . ' ' \ . ale#Var(a:buffer, 'python_pycodestyle_options') \ . ' -' diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim index b4a0b5f9..86ff8773 100644 --- a/sources_non_forked/ale/ale_linters/python/pyflakes.vim +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -2,7 +2,7 @@ " Description: pyflakes for python files call ale#Set('python_pyflakes_executable', 'pyflakes') -call ale#Set('python_pyflakes_use_global', 0) +call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#python#pyflakes#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes']) @@ -11,7 +11,13 @@ endfunction function! ale_linters#python#pyflakes#GetCommand(buffer) abort let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer) - return ale#Escape(l:executable) . ' %t' + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run pyflakes' + \ : '' + + return ale#Escape(l:executable) + \ . l:exec_args + \ . ' %t' endfunction function! ale_linters#python#pyflakes#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index e3e6624d..9239f835 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -1,20 +1,28 @@ " Author: keith " Description: pylint for python files -let g:ale_python_pylint_executable = -\ get(g:, 'ale_python_pylint_executable', 'pylint') - -let g:ale_python_pylint_options = -\ get(g:, 'ale_python_pylint_options', '') - -let g:ale_python_pylint_use_global = get(g:, 'ale_python_pylint_use_global', 0) +call ale#Set('python_pylint_executable', 'pylint') +call ale#Set('python_pylint_options', '') +call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylint_change_directory', 1) function! ale_linters#python#pylint#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint']) endfunction function! ale_linters#python#pylint#GetCommand(buffer) abort - return ale#Escape(ale_linters#python#pylint#GetExecutable(a:buffer)) + let l:cd_string = ale#Var(a:buffer, 'python_pylint_change_directory') + \ ? ale#path#BufferCdString(a:buffer) + \ : '' + + let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run pylint' + \ : '' + + return l:cd_string + \ . ale#Escape(l:executable) . l:exec_args \ . ' ' . ale#Var(a:buffer, 'python_pylint_options') \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n' \ . ' %s' @@ -24,7 +32,7 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort " Matches patterns like the following: " " test.py:4:4: W0101 (unreachable) Unreachable code - let l:pattern = '\v^[^:]+:(\d+):(\d+): ([[:alnum:]]+) \(([^(]*)\) (.*)$' + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ([[:alnum:]]+) \(([^(]*)\) (.*)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/sources_non_forked/ale/ale_linters/python/pyls.vim b/sources_non_forked/ale/ale_linters/python/pyls.vim index 9888853f..010cb31f 100644 --- a/sources_non_forked/ale/ale_linters/python/pyls.vim +++ b/sources_non_forked/ale/ale_linters/python/pyls.vim @@ -2,7 +2,7 @@ " Description: A language server for Python call ale#Set('python_pyls_executable', 'pyls') -call ale#Set('python_pyls_use_global', 0) +call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#python#pyls#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls']) @@ -11,11 +11,11 @@ endfunction function! ale_linters#python#pyls#GetCommand(buffer) abort let l:executable = ale_linters#python#pyls#GetExecutable(a:buffer) - return ale#Escape(l:executable) -endfunction + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run pyls' + \ : '' -function! ale_linters#python#pyls#GetLanguage(buffer) abort - return 'python' + return ale#Escape(l:executable) . l:exec_args endfunction call ale#linter#Define('python', { @@ -23,6 +23,7 @@ call ale#linter#Define('python', { \ 'lsp': 'stdio', \ 'executable_callback': 'ale_linters#python#pyls#GetExecutable', \ 'command_callback': 'ale_linters#python#pyls#GetCommand', -\ 'language_callback': 'ale_linters#python#pyls#GetLanguage', +\ 'language': 'python', \ 'project_root_callback': 'ale#python#FindProjectRoot', +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', \}) diff --git a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim new file mode 100644 index 00000000..85b131fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim @@ -0,0 +1,40 @@ +" Author: pylipp (www.github.com/pylipp) +" Description: qmlfmt for QML files + +let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt') + +function! ale_linters#qml#qmlfmt#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'qml_qmlfmt_executable') +endfunction + +function! ale_linters#qml#qmlfmt#GetCommand(buffer) abort + return ale#Escape(ale_linters#qml#qmlfmt#GetExecutable(a:buffer)) + \ . ' -e' +endfunction + +" Find lines like +" Error:11:1: Expected token `}' +function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort + let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': l:match[1] is# 'Warning' ? 'W' : 'E', + \} + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('qml', { +\ 'name': 'qmlfmt', +\ 'output_stream': 'stderr', +\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable', +\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand', +\ '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 51e5c562..8f74c9b8 100644 --- a/sources_non_forked/ale/ale_linters/r/lintr.vim +++ b/sources_non_forked/ale/ale_linters/r/lintr.vim @@ -22,7 +22,7 @@ function! ale_linters#r#lintr#GetCommand(buffer) abort \ . l:lint_cmd return ale#path#BufferCdString(a:buffer) - \ . 'Rscript -e ' + \ . 'Rscript --vanilla -e ' \ . ale#Escape(l:cmd_string) . ' %t' endfunction diff --git a/sources_non_forked/ale/ale_linters/reason/ols.vim b/sources_non_forked/ale/ale_linters/reason/ols.vim index b2cd5f79..4e5bd395 100644 --- a/sources_non_forked/ale/ale_linters/reason/ols.vim +++ b/sources_non_forked/ale/ale_linters/reason/ols.vim @@ -2,7 +2,7 @@ " Description: A language server for Reason call ale#Set('reason_ols_executable', 'ocaml-language-server') -call ale#Set('reason_ols_use_global', 0) +call ale#Set('reason_ols_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#linter#Define('reason', { \ 'name': 'ols', diff --git a/sources_non_forked/ale/ale_linters/rust/cargo.vim b/sources_non_forked/ale/ale_linters/rust/cargo.vim index 09f41bbb..ef0c3bd1 100644 --- a/sources_non_forked/ale/ale_linters/rust/cargo.vim +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -4,6 +4,8 @@ call ale#Set('rust_cargo_use_check', 1) call ale#Set('rust_cargo_check_all_targets', 0) +call ale#Set('rust_cargo_check_examples', 0) +call ale#Set('rust_cargo_check_tests', 0) call ale#Set('rust_cargo_default_feature_behavior', 'default') call ale#Set('rust_cargo_include_features', '') @@ -31,6 +33,12 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort let l:use_all_targets = l:use_check \ && ale#Var(a:buffer, 'rust_cargo_check_all_targets') \ && ale#semver#GTE(l:version, [0, 22, 0]) + let l:use_examples = l:use_check + \ && ale#Var(a:buffer, 'rust_cargo_check_examples') + \ && ale#semver#GTE(l:version, [0, 22, 0]) + let l:use_tests = l:use_check + \ && ale#Var(a:buffer, 'rust_cargo_check_tests') + \ && ale#semver#GTE(l:version, [0, 22, 0]) let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features') if !empty(l:include_features) @@ -50,6 +58,8 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version_output) abort return 'cargo ' \ . (l:use_check ? 'check' : 'build') \ . (l:use_all_targets ? ' --all-targets' : '') + \ . (l:use_examples ? ' --examples' : '') + \ . (l:use_tests ? ' --tests' : '') \ . ' --frozen --message-format=json -q' \ . l:default_feature \ . l:include_features diff --git a/sources_non_forked/ale/ale_linters/rust/rls.vim b/sources_non_forked/ale/ale_linters/rust/rls.vim index 832fe3e2..d5160b14 100644 --- a/sources_non_forked/ale/ale_linters/rust/rls.vim +++ b/sources_non_forked/ale/ale_linters/rust/rls.vim @@ -12,12 +12,11 @@ function! ale_linters#rust#rls#GetCommand(buffer) abort let l:executable = ale_linters#rust#rls#GetExecutable(a:buffer) let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain') - return ale#Escape(l:executable) - \ . ' +' . ale#Escape(l:toolchain) -endfunction - -function! ale_linters#rust#rls#GetLanguage(buffer) abort - return 'rust' + if empty(l:toolchain) + return ale#Escape(l:executable) + else + return ale#Escape(l:executable) . ' +' . ale#Escape(l:toolchain) + endif endfunction function! ale_linters#rust#rls#GetProjectRoot(buffer) abort @@ -31,6 +30,6 @@ call ale#linter#Define('rust', { \ 'lsp': 'stdio', \ 'executable_callback': 'ale_linters#rust#rls#GetExecutable', \ 'command_callback': 'ale_linters#rust#rls#GetCommand', -\ 'language_callback': 'ale_linters#rust#rls#GetLanguage', +\ 'language': 'rust', \ 'project_root_callback': 'ale_linters#rust#rls#GetProjectRoot', \}) diff --git a/sources_non_forked/ale/ale_linters/sass/sasslint.vim b/sources_non_forked/ale/ale_linters/sass/sasslint.vim index bbe71255..4df56dfd 100644 --- a/sources_non_forked/ale/ale_linters/sass/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/sass/sasslint.vim @@ -1,8 +1,9 @@ -" Author: KabbAmine - https://github.com/KabbAmine +" Author: KabbAmine - https://github.com/KabbAmine, +" Ben Falconer call ale#linter#Define('sass', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': 'sass-lint -v -q -f compact %t', +\ 'command_callback': 'ale#handlers#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 98c37257..fe941d6a 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -1,7 +1,7 @@ " Author: diartyz call ale#Set('sass_stylelint_executable', 'stylelint') -call ale#Set('sass_stylelint_use_global', 0) +call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#sass#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'sass_stylelint', [ diff --git a/sources_non_forked/ale/ale_linters/scala/fsc.vim b/sources_non_forked/ale/ale_linters/scala/fsc.vim new file mode 100644 index 00000000..17b26f0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/fsc.vim @@ -0,0 +1,29 @@ +" Author: Nils Leuzinger - https://github.com/PawkyPenguin +" Description: Basic scala support using fsc +" +function! ale_linters#scala#fsc#GetExecutable(buffer) abort + if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 + " Don't check sbt files + return '' + endif + + return 'fsc' +endfunction + +function! ale_linters#scala#fsc#GetCommand(buffer) abort + let l:executable = ale_linters#scala#fsc#GetExecutable(a:buffer) + + if empty(l:executable) + return '' + endif + + return ale#Escape(l:executable) . ' -Ystop-after:parser %t' +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'fsc', +\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable', +\ 'command_callback': 'ale_linters#scala#fsc#GetCommand', +\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/scalac.vim b/sources_non_forked/ale/ale_linters/scala/scalac.vim index 584aee74..551284af 100644 --- a/sources_non_forked/ale/ale_linters/scala/scalac.vim +++ b/sources_non_forked/ale/ale_linters/scala/scalac.vim @@ -4,7 +4,7 @@ function! ale_linters#scala#scalac#GetExecutable(buffer) abort if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 - " Don't check sbt files with scalac. + " Don't check sbt files return '' endif @@ -21,45 +21,10 @@ function! ale_linters#scala#scalac#GetCommand(buffer) abort return ale#Escape(l:executable) . ' -Ystop-after:parser %t' endfunction -function! ale_linters#scala#scalac#Handle(buffer, lines) abort - " Matches patterns line the following: - " - " /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition - let l:pattern = '^.\+:\(\d\+\): \(\w\+\): \(.\+\)' - let l:output = [] - let l:ln = 0 - - for l:line in a:lines - let l:ln = l:ln + 1 - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:text = l:match[3] - let l:type = l:match[2] is# 'error' ? 'E' : 'W' - let l:col = 0 - - if l:ln + 1 < len(a:lines) - let l:col = stridx(a:lines[l:ln + 1], '^') - endif - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:col + 1, - \ 'text': l:text, - \ 'type': l:type, - \}) - endfor - - return l:output -endfunction - call ale#linter#Define('scala', { \ 'name': 'scalac', \ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable', \ 'command_callback': 'ale_linters#scala#scalac#GetCommand', -\ 'callback': 'ale_linters#scala#scalac#Handle', +\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) diff --git a/sources_non_forked/ale/ale_linters/scss/sasslint.vim b/sources_non_forked/ale/ale_linters/scss/sasslint.vim index bd016465..f6075001 100644 --- a/sources_non_forked/ale/ale_linters/scss/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/scss/sasslint.vim @@ -1,8 +1,18 @@ -" Author: KabbAmine - https://github.com/KabbAmine +" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer +" + +function! ale_linters#scss#sasslint#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . ale#Escape('sass-lint') + \ . ' -v' + \ . ' -q' + \ . ' -f compact' + \ . ' %t' +endfunction call ale#linter#Define('scss', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', -\ 'command': 'sass-lint -v -q -f compact %t', +\ 'command_callback': '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 00189a8b..6bfdd09a 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -1,7 +1,7 @@ " Author: diartyz call ale#Set('scss_stylelint_executable', 'stylelint') -call ale#Set('scss_stylelint_use_global', 0) +call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#scss#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'scss_stylelint', [ diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim index 2721529b..1562692a 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -2,7 +2,7 @@ call ale#Set('stylus_stylelint_executable', 'stylelint') call ale#Set('stylus_stylelint_options', '') -call ale#Set('stylus_stylelint_use_global', 0) +call ale#Set('stylus_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#stylus#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'stylus_stylelint', [ diff --git a/sources_non_forked/ale/ale_linters/typescript/tslint.vim b/sources_non_forked/ale/ale_linters/typescript/tslint.vim index 6f94fbae..b28f7cee 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tslint.vim @@ -4,7 +4,7 @@ call ale#Set('typescript_tslint_executable', 'tslint') call ale#Set('typescript_tslint_config_path', '') call ale#Set('typescript_tslint_rules_dir', '') -call ale#Set('typescript_tslint_use_global', 0) +call ale#Set('typescript_tslint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('typescript_tslint_ignore_empty_files', 0) function! ale_linters#typescript#tslint#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index 7a155bd9..08bd0f41 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -3,17 +3,13 @@ call ale#Set('typescript_tsserver_executable', 'tsserver') call ale#Set('typescript_tsserver_config_path', '') -call ale#Set('typescript_tsserver_use_global', 0) +call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) " These functions need to be defined just to comply with the API for LSP. function! ale_linters#typescript#tsserver#GetProjectRoot(buffer) abort return '' endfunction -function! ale_linters#typescript#tsserver#GetLanguage(buffer) abort - return '' -endfunction - function! ale_linters#typescript#tsserver#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'typescript_tsserver', [ \ 'node_modules/.bin/tsserver', @@ -26,5 +22,5 @@ call ale#linter#Define('typescript', { \ 'executable_callback': 'ale_linters#typescript#tsserver#GetExecutable', \ 'command_callback': 'ale_linters#typescript#tsserver#GetExecutable', \ 'project_root_callback': 'ale_linters#typescript#tsserver#GetProjectRoot', -\ 'language_callback': 'ale_linters#typescript#tsserver#GetLanguage', +\ 'language': '', \}) diff --git a/sources_non_forked/ale/ale_linters/vim/vint.vim b/sources_non_forked/ale/ale_linters/vim/vint.vim index dfa00dc0..cf2d4afd 100644 --- a/sources_non_forked/ale/ale_linters/vim/vint.vim +++ b/sources_non_forked/ale/ale_linters/vim/vint.vim @@ -2,31 +2,38 @@ " Description: This file adds support for checking Vim code with Vint. " This flag can be used to change enable/disable style issues. -let g:ale_vim_vint_show_style_issues = -\ get(g:, 'ale_vim_vint_show_style_issues', 1) -let s:enable_neovim = has('nvim') ? ' --enable-neovim ' : '' +call ale#Set('vim_vint_show_style_issues', 1) +call ale#Set('vim_vint_executable', 'vint') +let s:enable_neovim = has('nvim') ? ' --enable-neovim' : '' let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})"' +function! ale_linters#vim#vint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'vim_vint_executable') +endfunction + function! ale_linters#vim#vint#VersionCommand(buffer) abort + let l:executable = ale_linters#vim#vint#GetExecutable(a:buffer) + " Check the Vint version if we haven't checked it already. - return !ale#semver#HasVersion('vint') - \ ? 'vint --version' + return !ale#semver#HasVersion(l:executable) + \ ? ale#Escape(l:executable) . ' --version' \ : '' endfunction function! ale_linters#vim#vint#GetCommand(buffer, version_output) abort - let l:version = ale#semver#GetVersion('vint', a:version_output) + let l:executable = ale_linters#vim#vint#GetExecutable(a:buffer) + let l:version = ale#semver#GetVersion(l:executable, a:version_output) let l:can_use_no_color_flag = empty(l:version) \ || ale#semver#GTE(l:version, [0, 3, 7]) let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w' - return 'vint ' - \ . l:warning_flag . ' ' - \ . (l:can_use_no_color_flag ? '--no-color ' : '') + return ale#Escape(l:executable) + \ . ' ' . l:warning_flag + \ . (l:can_use_no_color_flag ? ' --no-color' : '') \ . s:enable_neovim - \ . s:format + \ . ' ' . s:format \ . ' %t' endfunction @@ -58,7 +65,7 @@ endfunction call ale#linter#Define('vim', { \ 'name': 'vint', -\ 'executable': 'vint', +\ 'executable_callback': '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/yaml/swaglint.vim b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim index 75a496c5..4a22c70f 100644 --- a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -2,7 +2,7 @@ " Description: This file adds support for linting Swagger / OpenAPI documents using swaglint call ale#Set('yaml_swaglint_executable', 'swaglint') -call ale#Set('yaml_swaglint_use_global', 0) +call ale#Set('yaml_swaglint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#yaml#swaglint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'yaml_swaglint', [ diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index f6c06cf1..f31446cb 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -2,6 +2,11 @@ " Description: Primary code path for the plugin " Manages execution of linters when requested by autocommands +" Strings used for severity in the echoed message +let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') +let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info') +let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') + let s:lint_timer = -1 let s:queued_buffer_number = -1 let s:should_lint_file_for_buffer = {} @@ -32,8 +37,8 @@ function! ale#CallWithCooldown(timestamp_key, func, arglist) abort endfunction " Return 1 if a file is too large for ALE to handle. -function! ale#FileTooLarge() abort - let l:max = ale#Var(bufnr(''), 'maximum_file_size') +function! ale#FileTooLarge(buffer) abort + let l:max = getbufvar(a:buffer, 'ale_maximum_file_size', get(g:, 'ale_maximum_file_size', 0)) return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0 endfunction @@ -46,39 +51,47 @@ function! ale#ShouldDoNothing(buffer) abort " The checks are split into separate if statements to make it possible to " profile each check individually with Vim's profiling tools. + " Do nothing if ALE is disabled. + if !getbufvar(a:buffer, 'ale_enabled', get(g:, 'ale_enabled', 0)) + return 1 + endif + " Don't perform any checks when newer NeoVim versions are exiting. if get(v:, 'exiting', v:null) isnot v:null return 1 endif - " Do nothing for blacklisted files - if index(g:ale_filetype_blacklist, getbufvar(a:buffer, '&filetype')) >= 0 + let l:filetype = getbufvar(a:buffer, '&filetype') + + " Do nothing when there's no filetype. + if l:filetype is# '' return 1 endif - " Do nothing if running from command mode + " Do nothing for blacklisted files. + if index(get(g:, 'ale_filetype_blacklist', []), l:filetype) >= 0 + return 1 + endif + + " Do nothing if running from command mode. if s:getcmdwintype_exists && !empty(getcmdwintype()) return 1 endif let l:filename = fnamemodify(bufname(a:buffer), ':t') + " Do nothing for directories. if l:filename is# '.' return 1 endif - " Do nothing if running in the sandbox + " Do nothing if running in the sandbox. if ale#util#InSandbox() return 1 endif - " Do nothing if ALE is disabled. - if !ale#Var(a:buffer, 'enabled') - return 1 - endif - " Do nothing if the file is too large. - if ale#FileTooLarge() + if ale#FileTooLarge(a:buffer) return 1 endif diff --git a/sources_non_forked/ale/autoload/ale/autocmd.vim b/sources_non_forked/ale/autoload/ale/autocmd.vim new file mode 100644 index 00000000..8570adaa --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/autocmd.vim @@ -0,0 +1,77 @@ +function! ale#autocmd#InitAuGroups() abort + " This value used to be a Boolean as a Number, and is now a String. + let l:text_changed = '' . g:ale_lint_on_text_changed + + augroup ALEPatternOptionsGroup + autocmd! + autocmd BufEnter,BufRead * call ale#pattern_options#SetOptions(str2nr(expand(''))) + augroup END + + augroup ALERunOnTextChangedGroup + autocmd! + if g:ale_enabled + if l:text_changed is? 'always' || l:text_changed is# '1' + autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) + elseif l:text_changed is? 'normal' + autocmd TextChanged * call ale#Queue(g:ale_lint_delay) + elseif l:text_changed is? 'insert' + autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) + endif + endif + augroup END + + augroup ALERunOnEnterGroup + autocmd! + if g:ale_enabled + " Handle everything that needs to happen when buffers are entered. + autocmd BufEnter * call ale#events#EnterEvent(str2nr(expand(''))) + endif + if g:ale_enabled && g:ale_lint_on_enter + autocmd BufWinEnter,BufRead * call ale#Queue(0, 'lint_file', str2nr(expand(''))) + " Track when the file is changed outside of Vim. + autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''))) + endif + augroup END + + augroup ALERunOnFiletypeChangeGroup + autocmd! + if g:ale_enabled && g:ale_lint_on_filetype_changed + " Only start linting if the FileType actually changes after + " opening a buffer. The FileType will fire when buffers are opened. + autocmd FileType * call ale#events#FileTypeEvent( + \ str2nr(expand('')), + \ expand('') + \) + endif + augroup END + + augroup ALERunOnSaveGroup + autocmd! + autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand(''))) + augroup END + + augroup ALERunOnInsertLeave + autocmd! + if g:ale_enabled && g:ale_lint_on_insert_leave + autocmd InsertLeave * call ale#Queue(0) + endif + augroup END + + augroup ALECursorGroup + autocmd! + if g:ale_enabled && g:ale_echo_cursor + autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() + " Look for a warning to echo as soon as we leave Insert mode. + " The script's position variable used when moving the cursor will + " not be changed here. + autocmd InsertLeave * call ale#cursor#EchoCursorWarning() + endif + augroup END + + if !g:ale_enabled + augroup! ALERunOnTextChangedGroup + augroup! ALERunOnEnterGroup + augroup! ALERunOnInsertLeave + augroup! ALECursorGroup + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/balloon.vim b/sources_non_forked/ale/autoload/ale/balloon.vim index 552ced82..d49dcbf9 100644 --- a/sources_non_forked/ale/autoload/ale/balloon.vim +++ b/sources_non_forked/ale/autoload/ale/balloon.vim @@ -12,7 +12,21 @@ function! ale#balloon#MessageForPos(bufnr, lnum, col) abort let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) - return l:index >= 0 ? l:loclist[l:index].text : '' + " Show the diagnostics message if found, 'Hover' output otherwise + if l:index >= 0 + return l:loclist[l:index].text + elseif exists('*balloon_show') || getbufvar( + \ a:bufnr, + \ 'ale_set_balloons_legacy_echo', + \ get(g:, 'ale_set_balloons_legacy_echo', 0) + \) + " Request LSP/tsserver hover information, but only if this version of + " Vim supports the balloon_show function, or if we turned a legacy + " setting on. + call ale#hover#Show(a:bufnr, a:lnum, a:col, {'called_from_balloonexpr': 1}) + endif + + return '' endfunction function! ale#balloon#Expr() abort @@ -20,9 +34,22 @@ function! ale#balloon#Expr() abort endfunction function! ale#balloon#Disable() abort - set noballooneval balloonexpr= + set noballooneval noballoonevalterm + set balloonexpr= endfunction function! ale#balloon#Enable() abort - set ballooneval balloonexpr=ale#balloon#Expr() + if !has('balloon_eval') && !has('balloon_eval_term') + return + endif + + if has('balloon_eval') + set ballooneval + endif + + if has('balloon_eval_term') + set balloonevalterm + endif + + set balloonexpr=ale#balloon#Expr() endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 7ad7f9da..d8c2b4e2 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -1,6 +1,10 @@ " Author: w0rp " Description: Completion support for LSP linters +let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100) +let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', []) +let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50) + let s:timer_id = -1 let s:last_done_pos = [] @@ -28,6 +32,8 @@ let s:LSP_COMPLETION_REFERENCE_KIND = 18 " the insert cursor is. If one of these matches, we'll check for completions. let s:should_complete_map = { \ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$', +\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$', +\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$', \} " Regular expressions for finding the start column to replace with completion. @@ -38,6 +44,8 @@ let s:omni_start_map = { " A map of exact characters for triggering LSP completions. let s:trigger_character_map = { \ '': ['.'], +\ 'typescript': ['.', '''', '"'], +\ 'rust': ['.', '::'], \} function! s:GetFiletypeValue(map, filetype) abort @@ -74,33 +82,49 @@ function! ale#completion#GetTriggerCharacter(filetype, prefix) abort return '' endfunction -function! ale#completion#Filter(suggestions, prefix) abort +function! ale#completion#Filter(buffer, suggestions, prefix) abort + let l:excluded_words = ale#Var(a:buffer, 'completion_excluded_words') + " For completing... " foo. " ^ " We need to include all of the given suggestions. if a:prefix is# '.' - return a:suggestions + let l:filtered_suggestions = a:suggestions + else + let l:filtered_suggestions = [] + + " 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) == type('') ? 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 - let l:filtered_suggestions = [] - - " 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) == type('') ? 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) + if !empty(l:excluded_words) + " Copy the List if needed. We don't want to modify the argument. + " We shouldn't make a copy if we don't need to. + if l:filtered_suggestions is a:suggestions + let l:filtered_suggestions = copy(a:suggestions) endif - endfor + + " Remove suggestions with words in the exclusion List. + call filter( + \ l:filtered_suggestions, + \ 'index(l:excluded_words, type(v:val) is type('''') ? v:val : v:val.word) < 0', + \) + endif return l:filtered_suggestions endfunction @@ -178,7 +202,9 @@ function! ale#completion#ParseTSServerCompletions(response) abort endfunction function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort + let l:buffer = bufnr('') let l:results = [] + let l:names_with_details = [] for l:suggestion in a:response.body let l:displayParts = [] @@ -212,10 +238,44 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort \}) endfor + let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', []) + + if !empty(l:names) && len(l:names) != len(l:results) + let l:names_with_details = map(copy(l:results), 'v:val.word') + let l:missing_names = filter( + \ copy(l:names), + \ 'index(l:names_with_details, v:val) < 0', + \) + + for l:name in l:missing_names + call add(l:results, { + \ 'word': l:name, + \ 'kind': 'v', + \ 'icase': 1, + \ 'menu': '', + \ 'info': '', + \}) + endfor + endif + return l:results endfunction +function! ale#completion#NullFilter(buffer, item) abort + return 1 +endfunction + function! ale#completion#ParseLSPCompletions(response) abort + let l:buffer = bufnr('') + let l:info = get(b:, 'ale_completion_info', {}) + let l:Filter = get(l:info, 'completion_filter', v:null) + + if l:Filter is v:null + let l:Filter = function('ale#completion#NullFilter') + else + let l:Filter = ale#util#GetFunction(l:Filter) + endif + let l:item_list = [] if type(get(a:response, 'result')) is type([]) @@ -228,6 +288,16 @@ function! ale#completion#ParseLSPCompletions(response) abort let l:results = [] for l:item in l:item_list + if !call(l:Filter, [l:buffer, l:item]) + continue + endif + + let l:word = matchstr(l:item.label, '\v^[^(]+') + + if empty(l:word) + continue + endif + " See :help complete-items for Vim completion kinds if l:item.kind is s:LSP_COMPLETION_METHOD_KIND let l:kind = 'm' @@ -244,14 +314,18 @@ function! ale#completion#ParseLSPCompletions(response) abort endif call add(l:results, { - \ 'word': l:item.label, + \ 'word': l:word, \ 'kind': l:kind, \ 'icase': 1, - \ 'menu': l:item.detail, - \ 'info': l:item.documentation, + \ 'menu': get(l:item, 'detail', ''), + \ 'info': get(l:item, 'documentation', ''), \}) endfor + if has_key(l:info, 'prefix') + return ale#completion#Filter(l:buffer, l:results, l:info.prefix) + endif + return l:results endfunction @@ -264,19 +338,25 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort return endif + let l:buffer = bufnr('') let l:command = get(a:response, 'command', '') if l:command is# 'completions' let l:names = ale#completion#Filter( + \ l:buffer, \ ale#completion#ParseTSServerCompletions(a:response), \ b:ale_completion_info.prefix, \)[: g:ale_completion_max_suggestions - 1] + " We need to remember some names for tsserver, as it doesn't send + " details back for everything we send. + call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names) + if !empty(l:names) let b:ale_completion_info.request_id = ale#lsp#Send( \ b:ale_completion_info.conn_id, \ ale#lsp#tsserver_message#CompletionEntryDetails( - \ bufnr(''), + \ l:buffer, \ b:ale_completion_info.line, \ b:ale_completion_info.column, \ l:names, @@ -349,6 +429,10 @@ function! s:GetLSPCompletions(linter) abort if l:request_id let b:ale_completion_info.conn_id = l:id let b:ale_completion_info.request_id = l:request_id + + if has_key(a:linter, 'completion_filter') + let b:ale_completion_info.completion_filter = a:linter.completion_filter + endif endif endfunction @@ -378,10 +462,7 @@ function! ale#completion#GetCompletions() abort for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) - if l:linter.lsp is# 'tsserver' - \|| get(g:, 'ale_completion_experimental_lsp_support', 0) - call s:GetLSPCompletions(l:linter) - endif + call s:GetLSPCompletions(l:linter) endif endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion/python.vim b/sources_non_forked/ale/autoload/ale/completion/python.vim new file mode 100644 index 00000000..6b65c5b5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/completion/python.vim @@ -0,0 +1,3 @@ +function! ale#completion#python#CompletionItemFilter(buffer, item) abort + return a:item.label !~# '\v^__[a-z_]+__' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim index 50b1fb50..e3dd4208 100644 --- a/sources_non_forked/ale/autoload/ale/cursor.vim +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -1,6 +1,11 @@ " Author: w0rp " Description: Echoes lint message for the current line, if any +" Controls the milliseconds delay before echoing a message. +let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10) +" A string format for the echoed message. +let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s') + let s:cursor_timer = -1 let s:last_pos = [0, 0, 0] diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index cb93ec16..f32e4308 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -51,6 +51,7 @@ let s:global_variable_list = [ \ 'ale_sign_warning', \ 'ale_statusline_format', \ 'ale_type_map', +\ 'ale_use_global_executables', \ 'ale_warn_about_trailing_blank_lines', \ 'ale_warn_about_trailing_whitespace', \] @@ -167,6 +168,30 @@ function! s:EchoLinterAliases(all_linters) abort endfor endfunction +function! s:EchoLSPErrorMessages(all_linter_names) abort + let l:lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) + let l:header_echoed = 0 + + for l:linter_name in a:all_linter_names + let l:error_list = get(l:lsp_error_messages, l:linter_name, []) + + if !empty(l:error_list) + if !l:header_echoed + call s:Echo(' LSP Error Messages:') + call s:Echo('') + endif + + call s:Echo('(Errors for ' . l:linter_name . ')') + + for l:message in l:error_list + for l:line in split(l:message, "\n") + call s:Echo(l:line) + endfor + endfor + endif + endfor +endfunction + function! ale#debugging#Info() abort let l:filetype = &filetype @@ -199,6 +224,7 @@ function! ale#debugging#Info() abort call s:Echo(' Global Variables:') call s:Echo('') call s:EchoGlobalVariables() + call s:EchoLSPErrorMessages(l:all_names) call s:Echo(' Command History:') call s:Echo('') call s:EchoCommandHistory() @@ -211,3 +237,14 @@ function! ale#debugging#InfoToClipboard() abort call s:Echo('ALEInfo copied to your clipboard') endfunction + +function! ale#debugging#InfoToFile(filename) abort + let l:expanded_filename = expand(a:filename) + + redir => l:output + silent call ale#debugging#Info() + redir END + + call writefile(split(l:output, "\n"), l:expanded_filename) + call s:Echo('ALEInfo written to ' . l:expanded_filename) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 521cd0b1..a17eb2e7 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -13,37 +13,21 @@ function! ale#definition#SetMap(map) abort let s:go_to_definition_map = a:map endfunction -" This function is used so we can check the execution of commands without -" running them. -function! ale#definition#Execute(expr) abort - execute a:expr -endfunction - function! ale#definition#ClearLSPData() abort let s:go_to_definition_map = {} endfunction -function! ale#definition#Open(options, filename, line, column) abort - if a:options.open_in_tab - call ale#definition#Execute('tabedit ' . fnameescape(a:filename)) - else - call ale#definition#Execute('edit ' . fnameescape(a:filename)) - endif - - call cursor(a:line, a:column) -endfunction - function! ale#definition#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'command', '') is# 'definition' \&& has_key(s:go_to_definition_map, a:response.request_seq) let l:options = remove(s:go_to_definition_map, a:response.request_seq) - if get(a:response, 'success', v:false) is v:true + if get(a:response, 'success', v:false) is v:true && !empty(a:response.body) let l:filename = a:response.body[0].file let l:line = a:response.body[0].start.line let l:column = a:response.body[0].start.offset - call ale#definition#Open(l:options, l:filename, l:line, l:column) + call ale#util#Open(l:filename, l:line, l:column, l:options) endif endif endfunction @@ -67,7 +51,7 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort let l:line = l:item.range.start.line + 1 let l:column = l:item.range.start.character - call ale#definition#Open(l:options, l:filename, l:line, l:column) + call ale#util#Open(l:filename, l:line, l:column, l:options) break endfor endif diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index dd871c36..10589869 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -2,6 +2,9 @@ " Description: Backend execution and job management " Executes linters in the background, using NeoVim or Vim 8 jobs +" 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. @@ -44,7 +47,7 @@ function! ale#engine#IsExecutable(buffer, executable) abort " Cache the executable check if we found it, or if the option to cache " failing checks is on. - if l:result || g:ale_cache_executable_check_failures + if l:result || get(g:, 'ale_cache_executable_check_failures', 0) let s:executable_cache_map[a:executable] = l:result endif @@ -81,6 +84,11 @@ function! ale#engine#ClearLSPData() abort let s:lsp_linter_map = {} endfunction +" Just for tests. +function! ale#engine#SetLSPLinterMap(replacement_map) abort + let s:lsp_linter_map = a:replacement_map +endfunction + " This function is documented and part of the public API. " " Return 1 if ALE is busy checking a given buffer @@ -93,11 +101,13 @@ 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) 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) endfunction @@ -270,20 +280,38 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort call ale#engine#HandleLoclist('tsserver', l:buffer, l:loclist) endfunction -function! s:HandleLSPErrorMessage(error_message) abort - execute 'echoerr ''Error from LSP:''' +function! s:HandleLSPErrorMessage(linter_name, response) abort + if !g:ale_history_enabled || !g:ale_history_log_output + return + endif - for l:line in split(a:error_message, "\n") - execute 'echoerr l:line' - endfor + if empty(a:linter_name) + return + endif + + let l:message = ale#lsp#response#GetErrorMessage(a:response) + + if empty(l:message) + return + endif + + " This global variable is set here so we don't load the debugging.vim file + " until someone uses :ALEInfo. + let g:ale_lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) + + if !has_key(g:ale_lsp_error_messages, a:linter_name) + let g:ale_lsp_error_messages[a:linter_name] = [] + endif + + call add(g:ale_lsp_error_messages[a:linter_name], l:message) endfunction function! ale#engine#HandleLSPResponse(conn_id, response) abort let l:method = get(a:response, 'method', '') + let l:linter_name = get(s:lsp_linter_map, a:conn_id, '') if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error') - " Uncomment this line to print LSP error messages. - " call s:HandleLSPErrorMessage(a:response.error.message) + call s:HandleLSPErrorMessage(l:linter_name, a:response) elseif l:method is# 'textDocument/publishDiagnostics' call s:HandleLSPDiagnostics(a:conn_id, a:response) elseif get(a:response, 'type', '') is# 'event' @@ -339,6 +367,7 @@ function! ale#engine#SetResults(buffer, loclist) abort " Call user autocommands. This allows users to hook into ALE's lint cycle. silent doautocmd User ALELintPost + " remove in 2.0 " Old DEPRECATED name; call it for backwards compatibility. silent doautocmd User ALELint endif @@ -393,7 +422,7 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort \ 'text': l:old_item.text, \ 'lnum': str2nr(l:old_item.lnum), \ 'col': str2nr(get(l:old_item, 'col', 0)), - \ 'vcol': get(l:old_item, 'vcol', 0), + \ 'vcol': 0, \ 'type': get(l:old_item, 'type', 'E'), \ 'nr': get(l:old_item, 'nr', -1), \ 'linter_name': a:linter_name, @@ -453,6 +482,20 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort " When errors go beyond the end of the file, put them at the end. " This is only done for the current buffer. let l:item.lnum = l:last_line_number + elseif get(l:old_item, 'vcol', 0) + " Convert virtual column positions to byte positions. + " The positions will be off if the buffer has changed recently. + let l:line = getbufline(a:buffer, l:item.lnum)[0] + + let l:item.col = ale#util#Col(l:line, l:item.col) + + if has_key(l:item, 'end_col') + let l:end_line = get(l:item, 'end_lnum', l:line) != l:line + \ ? getbufline(a:buffer, l:item.end_lnum)[0] + \ : l:line + + let l:item.end_col = ale#util#Col(l:end_line, l:item.end_col) + endif endif call add(l:new_loclist, l:item) @@ -572,6 +615,8 @@ function! s:RunJob(options) abort \ 'output': [], \ 'next_chain_index': l:next_chain_index, \} + + silent doautocmd User ALEJobStarted endif if g:ale_history_enabled diff --git a/sources_non_forked/ale/autoload/ale/events.vim b/sources_non_forked/ale/autoload/ale/events.vim index c7d17ea5..3d2aa32d 100644 --- a/sources_non_forked/ale/autoload/ale/events.vim +++ b/sources_non_forked/ale/autoload/ale/events.vim @@ -19,7 +19,7 @@ function! ale#events#SaveEvent(buffer) abort endif if ale#Var(a:buffer, 'fix_on_save') - let l:will_fix = ale#fix#Fix('save_file') + let l:will_fix = ale#fix#Fix(a:buffer, 'save_file') let l:should_lint = l:should_lint && !l:will_fix endif diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index 398f57d0..51df1458 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -28,8 +28,6 @@ function! ale#fix#ApplyQueuedFixes() abort call remove(g:ale_fix_buffer_data, l:buffer) if l:data.changes_made - call setline(1, l:data.output) - let l:start_line = len(l:data.output) + 1 let l:end_line = len(l:data.lines_before) @@ -39,6 +37,8 @@ function! ale#fix#ApplyQueuedFixes() abort call winrestview(l:save) endif + call setline(1, l:data.output) + if l:data.should_save if empty(&buftype) noautocmd :w! @@ -356,14 +356,16 @@ function! s:RunFixer(options) abort call ale#fix#ApplyFixes(l:buffer, l:input) endfunction -function! s:GetCallbacks() abort - if type(get(b:, 'ale_fixers')) is type([]) +function! s:GetCallbacks(buffer, linters) abort + if len(a:linters) + let l:callback_list = a:linters + elseif type(get(b:, 'ale_fixers')) is type([]) " Lists can be used for buffer-local variables only let l:callback_list = b:ale_fixers else " buffer and global options can use dictionaries mapping filetypes to " callbacks to run. - let l:fixers = ale#Var(bufnr(''), 'fixers') + let l:fixers = ale#Var(a:buffer, 'fixers') let l:callback_list = [] for l:sub_type in split(&filetype, '\.') @@ -422,19 +424,13 @@ endfunction " Accepts an optional argument for what to do when fixing. " " Returns 0 if no fixes can be applied, and 1 if fixing can be done. -function! ale#fix#Fix(...) abort - if len(a:0) > 1 - throw 'too many arguments!' - endif - - let l:fixing_flag = get(a:000, 0, '') - - if l:fixing_flag isnot# '' && l:fixing_flag isnot# 'save_file' +function! ale#fix#Fix(buffer, fixing_flag, ...) abort + if a:fixing_flag isnot# '' && a:fixing_flag isnot# 'save_file' throw "fixing_flag must be either '' or 'save_file'" endif try - let l:callback_list = s:GetCallbacks() + let l:callback_list = s:GetCallbacks(a:buffer, a:000) catch /E700\|BADNAME/ let l:function_name = join(split(split(v:exception, ':')[3])) let l:echo_message = printf( @@ -447,29 +443,27 @@ function! ale#fix#Fix(...) abort endtry if empty(l:callback_list) - if l:fixing_flag is# '' + if a:fixing_flag is# '' execute 'echom ''No fixers have been defined. Try :ALEFixSuggest''' endif return 0 endif - let l:buffer = bufnr('') - 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 " Clean up any files we might have left behind from a previous run. - call ale#fix#RemoveManagedFiles(l:buffer) - call ale#fix#InitBufferData(l:buffer, l:fixing_flag) + call ale#fix#RemoveManagedFiles(a:buffer) + call ale#fix#InitBufferData(a:buffer, a:fixing_flag) silent doautocmd User ALEFixPre call s:RunFixer({ - \ 'buffer': l:buffer, - \ 'input': g:ale_fix_buffer_data[l:buffer].lines_before, + \ 'buffer': a:buffer, + \ 'input': g:ale_fix_buffer_data[a:buffer].lines_before, \ 'callback_index': 0, \ 'callback_list': l:callback_list, \}) diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 4c0703a5..7b55acfc 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -17,6 +17,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix PEP8 issues with autopep8.', \ }, +\ 'black': { +\ 'function': 'ale#fixers#black#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix PEP8 issues with black.', +\ }, \ 'prettier_standard': { \ 'function': 'ale#fixers#prettier_standard#Fix', \ 'suggested_filetypes': ['javascript'], @@ -90,6 +95,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['ruby'], \ 'description': 'Fix ruby files with rufo', \ }, +\ 'scalafmt': { +\ 'function': 'ale#fixers#scalafmt#Fix', +\ 'suggested_filetypes': ['scala'], +\ 'description': 'Fix Scala files using scalafmt', +\ }, \ 'standard': { \ 'function': 'ale#fixers#standard#Fix', \ 'suggested_filetypes': ['javascript'], @@ -180,6 +190,21 @@ let s:default_registry = { \ 'suggested_filetypes': ['json'], \ 'description': 'Fix JSON files with jq.', \ }, +\ 'perltidy': { +\ 'function': 'ale#fixers#perltidy#Fix', +\ 'suggested_filetypes': ['perl'], +\ 'description': 'Fix Perl files with perltidy.', +\ }, +\ 'xo': { +\ 'function': 'ale#fixers#xo#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'Fix JavaScript files using xo --fix.', +\ }, +\ 'qmlfmt': { +\ 'function': 'ale#fixers#qmlfmt#Fix', +\ 'suggested_filetypes': ['qml'], +\ 'description': 'Fix QML files with qmlfmt.', +\ }, \} " Reset the function registry to the default entries. @@ -272,6 +297,14 @@ function! s:ShouldSuggestForType(suggested_filetypes, type_list) abort return 0 endfunction +function! s:IsGenericFixer(suggested_filetypes) abort + if empty(a:suggested_filetypes) + return 1 + endif + + return 0 +endfunction + function! s:FormatEntry(key, entry) abort let l:aliases_str = '' @@ -291,6 +324,27 @@ function! s:FormatEntry(key, entry) abort \) endfunction +" Get list of applicable fixers for filetype, including generic fixers +function! ale#fix#registry#GetApplicableFixers(filetype) abort + let l:type_list = split(a:filetype, '\.') + let l:fixer_name_list = [] + + for l:key in sort(keys(s:entries)) + let l:suggested_filetypes = s:entries[l:key].suggested_filetypes + + if s:IsGenericFixer(l:suggested_filetypes) || s:ShouldSuggestForType(l:suggested_filetypes, l:type_list) + call add(l:fixer_name_list, l:key) + endif + endfor + + return l:fixer_name_list +endfunction + +" Function that returns autocomplete candidates for ALEFix command +function! ale#fix#registry#CompleteFixers(ArgLead, CmdLine, CursorPos) abort + return filter(ale#fix#registry#GetApplicableFixers(&filetype), 'v:val =~? a:ArgLead') +endfunction + " Suggest functions to use from the registry. function! ale#fix#registry#Suggest(filetype) abort let l:type_list = split(a:filetype, '\.') @@ -310,7 +364,7 @@ function! ale#fix#registry#Suggest(filetype) abort let l:generic_fixer_list = [] for l:key in sort(keys(s:entries)) - if empty(s:entries[l:key].suggested_filetypes) + if s:IsGenericFixer(s:entries[l:key].suggested_filetypes) call add( \ l:generic_fixer_list, \ s:FormatEntry(l:key, s:entries[l:key]), diff --git a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim index e2dd7bfe..5798d827 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim @@ -2,7 +2,7 @@ " Description: Fixing files with autopep8. call ale#Set('python_autopep8_executable', 'autopep8') -call ale#Set('python_autopep8_use_global', 0) +call ale#Set('python_autopep8_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_autopep8_options', '') function! ale#fixers#autopep8#Fix(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim new file mode 100644 index 00000000..4169322a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -0,0 +1,26 @@ +" Author: w0rp +" Description: Fixing Python files with black. +" +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', '') + +function! ale#fixers#black#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_black', + \ ['black'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:options = ale#Var(a:buffer, 'python_black_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/brittany.vim b/sources_non_forked/ale/autoload/ale/fixers/brittany.vim index fed5eb8b..57c77325 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/brittany.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/brittany.vim @@ -1,4 +1,4 @@ -" Author: eborden +" Author: eborden , ifyouseewendy , aspidiets " Description: Integration of brittany with ALE. call ale#Set('haskell_brittany_executable', 'brittany') @@ -8,6 +8,7 @@ function! ale#fixers#brittany#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) + \ . ' --write-mode inplace' \ . ' %t', \ 'read_temporary_file': 1, \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim index b50b7047..eae1a7b4 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim @@ -3,7 +3,7 @@ scriptencoding utf-8 " Description: Fixing C/C++ files with clang-format. call ale#Set('c_clangformat_executable', 'clang-format') -call ale#Set('c_clangformat_use_global', 0) +call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('c_clangformat_options', '') function! ale#fixers#clangformat#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim index b2119d2c..cd2be2c3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim @@ -2,7 +2,7 @@ " Description: Integration of elm-format with ALE. call ale#Set('elm_format_executable', 'elm-format') -call ale#Set('elm_format_use_global', 0) +call ale#Set('elm_format_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('elm_format_options', '--yes') function! ale#fixers#elm_format#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim index 43eb0632..64c6ba81 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim @@ -3,7 +3,7 @@ call ale#Set('json_fixjson_executable', 'fixjson') call ale#Set('json_fixjson_options', '') -call ale#Set('json_fixjson_use_global', 0) +call ale#Set('json_fixjson_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#fixjson#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'json_fixjson', [ diff --git a/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim b/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim index 92632e84..6a2f5491 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim @@ -2,7 +2,7 @@ " Description: Integration of Google-java-format with ALE. call ale#Set('google_java_format_executable', 'google-java-format') -call ale#Set('google_java_format_use_global', 0) +call ale#Set('google_java_format_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('google_java_format_options', '') function! ale#fixers#google_java_format#Fix(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/isort.vim b/sources_non_forked/ale/autoload/ale/fixers/isort.vim index b6318221..74ba3bc8 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/isort.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/isort.vim @@ -2,7 +2,7 @@ " Description: Fixing Python imports with isort. call ale#Set('python_isort_executable', 'isort') -call ale#Set('python_isort_use_global', 0) +call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#isort#Fix(buffer) abort let l:executable = ale#python#FindExecutable( diff --git a/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim b/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim new file mode 100644 index 00000000..a55a572b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim @@ -0,0 +1,18 @@ +" Author: kfly8 +" Description: Integration of perltidy with ALE. + +call ale#Set('perl_perltidy_executable', 'perltidy') +call ale#Set('perl_perltidy_options', '') + +function! ale#fixers#perltidy#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'perl_perltidy_executable') + let l:options = ale#Var(a:buffer, 'perl_perltidy_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -b' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim index 56aa9150..26b8e5de 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim @@ -2,7 +2,8 @@ " Description: Fixing files with php-cs-fixer. call ale#Set('php_cs_fixer_executable', 'php-cs-fixer') -call ale#Set('php_cs_fixer_use_global', 0) +call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_cs_fixer_options', '') function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [ @@ -14,10 +15,9 @@ endfunction function! ale#fixers#php_cs_fixer#Fix(buffer) abort let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer) return { - \ 'command': ale#Escape(l:executable) . ' fix %t', + \ 'command': ale#Escape(l:executable) + \ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options') + \ . ' fix %t', \ 'read_temporary_file': 1, \} endfunction - - - diff --git a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim index 649e17d3..487f369a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim @@ -3,7 +3,7 @@ call ale#Set('php_phpcbf_standard', '') call ale#Set('php_phpcbf_executable', 'phpcbf') -call ale#Set('php_phpcbf_use_global', 0) +call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#phpcbf#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'php_phpcbf', [ diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index d75299eb..dcc35813 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -3,7 +3,7 @@ " Description: Integration of Prettier with ALE. call ale#Set('javascript_prettier_executable', 'prettier') -call ale#Set('javascript_prettier_use_global', 0) +call ale#Set('javascript_prettier_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_prettier_options', '') function! ale#fixers#prettier#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim index 5dd9102e..bc0caadd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim @@ -4,7 +4,7 @@ function! ale#fixers#prettier_eslint#SetOptionDefaults() abort call ale#Set('javascript_prettier_eslint_executable', 'prettier-eslint') - call ale#Set('javascript_prettier_eslint_use_global', 0) + call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_prettier_eslint_options', '') endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim index 7d938e19..b6e0a6f9 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim @@ -2,7 +2,7 @@ " Description: Integration of Prettier Standard with ALE. call ale#Set('javascript_prettier_standard_executable', 'prettier-standard') -call ale#Set('javascript_prettier_standard_use_global', 0) +call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_prettier_standard_options', '') function! ale#fixers#prettier_standard#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim new file mode 100644 index 00000000..d750d1c4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim @@ -0,0 +1,11 @@ +call ale#Set('qml_qmlfmt_executable', 'qmlfmt') + +function! ale#fixers#qmlfmt#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'qml_qmlfmt_executable') +endfunction + +function! ale#fixers#qmlfmt#Fix(buffer) abort + return { + \ 'command': ale#Escape(ale#fixers#qmlfmt#GetExecutable(a:buffer)), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim new file mode 100644 index 00000000..07d28275 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim @@ -0,0 +1,26 @@ +" Author: Jeffrey Lau https://github.com/zoonfafer +" Description: Integration of Scalafmt with ALE. + +call ale#Set('scala_scalafmt_executable', 'scalafmt') +call ale#Set('scala_scalafmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('scala_scalafmt_options', '') + +function! ale#fixers#scalafmt#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'scala_scalafmt_executable') + let l:options = ale#Var(a:buffer, 'scala_scalafmt_options') + let l:exec_args = l:executable =~? 'ng$' + \ ? ' scalafmt' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t' + +endfunction + +function! ale#fixers#scalafmt#Fix(buffer) abort + return { + \ 'command': ale#fixers#scalafmt#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index c998cfd0..2b1f6f92 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -2,7 +2,7 @@ " Description: Fixing files with Standard. call ale#Set('javascript_standard_executable', 'standard') -call ale#Set('javascript_standard_use_global', 0) +call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim index 899fcf4e..30309c7e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -2,7 +2,7 @@ " Description: Fixing files with stylelint. call ale#Set('stylelint_executable', 'stylelint') -call ale#Set('stylelint_use_global', 0) +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', [ diff --git a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim index dcc204b1..304182b2 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim @@ -2,7 +2,7 @@ " Description: Integration of SwiftFormat with ALE. call ale#Set('swift_swiftformat_executable', 'swiftformat') -call ale#Set('swift_swiftformat_use_global', 0) +call ale#Set('swift_swiftformat_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('swift_swiftformat_options', '') function! ale#fixers#swiftformat#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/fixers/xo.vim b/sources_non_forked/ale/autoload/ale/fixers/xo.vim new file mode 100644 index 00000000..882350be --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/xo.vim @@ -0,0 +1,23 @@ +" Author: Albert Marquez - https://github.com/a-marquez +" Description: Fixing files with XO. + +call ale#Set('javascript_xo_executable', 'xo') +call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_xo_options', '') + +function! ale#fixers#xo#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ + \ 'node_modules/xo/cli.js', + \ 'node_modules/.bin/xo', + \]) +endfunction + +function! ale#fixers#xo#Fix(buffer) abort + let l:executable = ale#fixers#xo#GetExecutable(a:buffer) + + return { + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . ' --fix %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim index ba7453b8..f04bb1f9 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim @@ -2,7 +2,7 @@ " Description: Fixing Python files with yapf. call ale#Set('python_yapf_executable', 'yapf') -call ale#Set('python_yapf_use_global', 0) +call ale#Set('python_yapf_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#yapf#Fix(buffer) abort let l:executable = ale#python#FindExecutable( diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim index ff590162..bc10ec21 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -5,7 +5,7 @@ let s:sep = has('win32') ? '\' : '/' call ale#Set('javascript_eslint_options', '') call ale#Set('javascript_eslint_executable', 'eslint') -call ale#Set('javascript_eslint_use_global', 0) +call ale#Set('javascript_eslint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('javascript_eslint_suppress_eslintignore', 0) call ale#Set('javascript_eslint_suppress_missing_config', 0) diff --git a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim index 9ec7b110..4b53652a 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim @@ -48,7 +48,7 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort let l:item = { \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'type': (l:match[4] is# 'error' || l:match[4] is# 'fatal error') ? 'E' : 'W', \ 'text': s:RemoveUnicodeQuotes(l:match[5]), \} diff --git a/sources_non_forked/ale/autoload/ale/handlers/sasslint.vim b/sources_non_forked/ale/autoload/ale/handlers/sasslint.vim new file mode 100644 index 00000000..399bf47c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/sasslint.vim @@ -0,0 +1,8 @@ +" Author: KabbAmine - https://github.com/KabbAmine, +" Ben Falconer + +function! ale#handlers#sasslint#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . ale#Escape('sass-lint') + \ . ' -v -q -f compact %t' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/scala.vim b/sources_non_forked/ale/autoload/ale/handlers/scala.vim new file mode 100644 index 00000000..3fe7a12e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/scala.vim @@ -0,0 +1,37 @@ +" Author: Nils Leuzinger - https://github.com/PawkyPenguin +" Description: Scala linting handlers for scalac-like compilers. + +function! ale#handlers#scala#HandleScalacLintFormat(buffer, lines) abort + " Matches patterns line the following: + " + " /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition + let l:pattern = '^.\+:\(\d\+\): \(\w\+\): \(.\+\)' + let l:output = [] + let l:ln = 0 + + for l:line in a:lines + let l:ln = l:ln + 1 + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:text = l:match[3] + let l:type = l:match[2] is# 'error' ? 'E' : 'W' + let l:col = 0 + + if l:ln + 1 < len(a:lines) + let l:col = stridx(a:lines[l:ln + 1], '^') + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:col + 1, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim index 4e56e127..6d495b0d 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim @@ -2,7 +2,7 @@ " Description: textlint, a proofreading tool (https://textlint.github.io/) call ale#Set('textlint_executable', 'textlint') -call ale#Set('textlint_use_global', 0) +call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('textlint_options', '') function! ale#handlers#textlint#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim index f9d452ea..aee7c4de 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim @@ -4,7 +4,7 @@ function! ale#handlers#writegood#ResetOptions() abort call ale#Set('writegood_options', '') call ale#Set('writegood_executable', 'write-good') - call ale#Set('writegood_use_global', 0) + call ale#Set('writegood_use_global', get(g:, 'ale_use_global_executables', 0)) endfunction " Reset the options so the tests can test how they are set. diff --git a/sources_non_forked/ale/autoload/ale/history.vim b/sources_non_forked/ale/autoload/ale/history.vim index a6282ea5..27ae74c2 100644 --- a/sources_non_forked/ale/autoload/ale/history.vim +++ b/sources_non_forked/ale/autoload/ale/history.vim @@ -1,6 +1,9 @@ " Author: w0rp " Description: Tools for managing command history +" A flag for controlling the maximum size of the command history to store. +let g:ale_max_buffer_history_size = get(g:, 'ale_max_buffer_history_size', 20) + " Return a shallow copy of the command history for a given buffer number. function! ale#history#Get(buffer) abort return copy(getbufvar(a:buffer, 'ale_history', [])) diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim new file mode 100644 index 00000000..3bf92488 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -0,0 +1,152 @@ +" Author: w0rp +" Description: Hover support for LSP linters. + +let s:hover_map = {} + +" Used to get the hover map in tests. +function! ale#hover#GetMap() abort + return deepcopy(s:hover_map) +endfunction + +" Used to set the hover map in tests. +function! ale#hover#SetMap(map) abort + let s:hover_map = a:map +endfunction + +function! ale#hover#ClearLSPData() abort + let s:hover_map = {} +endfunction + +function! ale#hover#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') is# 'quickinfo' + \&& has_key(s:hover_map, a:response.request_seq) + let l:options = remove(s:hover_map, a:response.request_seq) + + if get(a:response, 'success', v:false) is v:true + \&& get(a:response, 'body', v:null) isnot v:null + if get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& ale#Var(l:options.buffer, 'set_balloons') + call balloon_show(a:response.body.displayString) + else + call ale#util#ShowMessage(a:response.body.displayString) + endif + endif + endif +endfunction + +function! ale#hover#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:hover_map, a:response.id) + let l:options = remove(s:hover_map, a:response.id) + + " 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:end = len(getline(l:line)) + + if l:buffer isnot l:options.buffer + \|| l:line isnot l:options.line + \|| min([l:column, l:end]) isnot min([l:options.column, l:end]) + " ... Cancel display the message if the cursor has moved. + return + endif + endif + + " The result can be a Dictionary item, a List of the same, or null. + let l:result = get(a:response, 'result', v:null) + + if l:result is v:null + return + endif + + let l:result = l:result.contents + + if type(l:result) is type('') + " The result can be just a string. + let l:result = [l:result] + endif + + if type(l:result) is type({}) + " If the result is an object, then it's markup content. + let l:result = [l:result.value] + endif + + if type(l:result) is type([]) + " Replace objects with text values. + call map(l:result, 'type(v:val) is type('''') ? v:val : v:val.value') + let l:str = join(l:result, "\n") + let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '') + + if !empty(l:str) + if get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& ale#Var(l:options.buffer, 'set_balloons') + call balloon_show(l:str) + else + call ale#util#ShowMessage(l:str) + endif + endif + endif + endif +endfunction + +function! s:ShowDetails(linter, buffer, line, column, opt) abort + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#hover#HandleTSServerResponse') + \ : function('ale#hover#HandleLSPResponse') + + let l:lsp_details = ale#linter#StartLSP(a:buffer, a:linter, l:Callback) + + if empty(l:lsp_details) + return 0 + endif + + let l:id = l:lsp_details.connection_id + let l:root = l:lsp_details.project_root + + if a:linter.lsp is# 'tsserver' + let l:column = a:column + + let l:message = ale#lsp#tsserver_message#Quickinfo( + \ a:buffer, + \ a:line, + \ l:column + \) + else + " Send a message saying the buffer has changed first, or the + " hover position probably won't make sense. + call ale#lsp#Send(l:id, ale#lsp#message#DidChange(a:buffer), l:root) + + let l:column = min([a:column, len(getbufline(a:buffer, a:line)[0])]) + + let l:message = ale#lsp#message#Hover(a:buffer, a:line, l:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message, l:root) + + let s:hover_map[l:request_id] = { + \ 'buffer': a:buffer, + \ 'line': a:line, + \ 'column': l:column, + \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), + \} +endfunction + +" Obtain Hover information for the specified position +" Pass optional arguments in the dictionary opt. +" Currently, only one key/value is useful: +" - called_from_balloonexpr, this flag marks if we want the result from this +" ale#hover#Show to display in a balloon if possible +" +" Currently, the callbacks displays the info from hover : +" - in the balloon if opt.called_from_balloonexpr and balloon_show is detected +" - as status message otherwise +function! ale#hover#Show(buffer, line, col, opt) abort + for l:linter in ale#linter#Get(getbufvar(a:buffer, '&filetype')) + if !empty(l:linter.lsp) + call s:ShowDetails(l:linter, a:buffer, a:line, a:col, a:opt) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/job.vim b/sources_non_forked/ale/autoload/ale/job.vim index 2909dab4..6ffc2a06 100644 --- a/sources_non_forked/ale/autoload/ale/job.vim +++ b/sources_non_forked/ale/autoload/ale/job.vim @@ -8,6 +8,9 @@ " ale#job#IsRunning(job_id) -> 1 if running, 0 otherwise. " ale#job#Stop(job_id) +" A setting for wrapping commands. +let g:ale_command_wrapper = get(g:, 'ale_command_wrapper', '') + if !has_key(s:, 'job_map') let s:job_map = {} endif @@ -119,7 +122,7 @@ 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, l:info.exit_code) + call ale#util#GetFunction(l:info.exit_cb)(l:job_id, get(l:info, 'exit_code', 1)) endif finally " Automatically forget about the job after it's done. @@ -208,7 +211,7 @@ function! ale#job#PrepareCommand(buffer, command) abort return 'cmd /s/c "' . l:command . '"' endif - if &shell =~? 'fish$' + if &shell =~? 'fish$\|pwsh$' return ['/bin/sh', '-c', l:command] endif diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index d059a12d..5eb2fd82 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -3,15 +3,19 @@ call ale#Set('wrap_command_as_one_argument', 0) " Description: Linter registration and lazy-loading " Retrieves linters as requested by the engine, loading them if needed. +let s:runtime_loaded_map = {} let s:linters = {} " Default filetype aliases. " The user defined aliases will be merged with this Dictionary. +" +" NOTE: Update the g:ale_linter_aliases documentation when modifying this. let s:default_ale_linter_aliases = { \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', \ 'plaintex': 'tex', \ 'systemverilog': 'verilog', +\ 'vimwiki': 'markdown', \ 'zsh': 'sh', \} @@ -38,6 +42,7 @@ let s:default_ale_linters = { " Testing/debugging helper to unload all linters. function! ale#linter#Reset() abort + let s:runtime_loaded_map = {} let s:linters = {} endfunction @@ -49,6 +54,10 @@ function! s:IsBoolean(value) abort return type(a:value) == type(0) && (a:value == 0 || a:value == 1) endfunction +function! s:LanguageGetter(buffer) dict abort + return l:self.language +endfunction + function! ale#linter#PreProcess(linter) abort if type(a:linter) != type({}) throw 'The linter object must be a Dictionary' @@ -183,10 +192,26 @@ function! ale#linter#PreProcess(linter) abort endif if l:needs_lsp_details - let l:obj.language_callback = get(a:linter, 'language_callback') + if has_key(a:linter, 'language') + if has_key(a:linter, 'language_callback') + throw 'Only one of `language` or `language_callback` ' + \ . 'should be set' + endif - if !s:IsCallback(l:obj.language_callback) - throw '`language_callback` must be a callback for LSP linters' + let l:obj.language = get(a:linter, 'language') + + if type(l:obj.language) != type('') + throw '`language` must be a string' + endif + + " Make 'language_callback' return the 'language' value. + let l:obj.language_callback = function('s:LanguageGetter') + else + let l:obj.language_callback = get(a:linter, 'language_callback') + + if !s:IsCallback(l:obj.language_callback) + throw '`language_callback` must be a callback for LSP linters' + endif endif let l:obj.project_root_callback = get(a:linter, 'project_root_callback') @@ -194,6 +219,29 @@ function! ale#linter#PreProcess(linter) abort if !s:IsCallback(l:obj.project_root_callback) throw '`project_root_callback` must be a callback for LSP linters' endif + + if has_key(a:linter, 'completion_filter') + let l:obj.completion_filter = a:linter.completion_filter + + if !s:IsCallback(l:obj.completion_filter) + throw '`completion_filter` must be a callback' + endif + endif + + if has_key(a:linter, 'initialization_options_callback') + if has_key(a:linter, 'initialization_options') + throw 'Only one of `initialization_options` or ' + \ . '`initialization_options_callback` should be set' + endif + + let l:obj.initialization_options_callback = a:linter.initialization_options_callback + + if !s:IsCallback(l:obj.initialization_options_callback) + throw '`initialization_options_callback` must be a callback if defined' + endif + elseif has_key(a:linter, 'initialization_options') + let l:obj.initialization_options = a:linter.initialization_options + endif endif let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout') @@ -242,20 +290,20 @@ function! ale#linter#Define(filetype, linter) abort call add(s:linters[a:filetype], l:new_linter) endfunction +" Prevent any linters from being loaded for a given filetype. +function! ale#linter#PreventLoading(filetype) abort + let s:runtime_loaded_map[a:filetype] = 1 +endfunction + function! ale#linter#GetAll(filetypes) abort let l:combined_linters = [] for l:filetype in a:filetypes - " Load linter defintions from files if we haven't loaded them yet. - if !has_key(s:linters, l:filetype) + " Load linters from runtimepath if we haven't done that yet. + if !has_key(s:runtime_loaded_map, l:filetype) execute 'silent! runtime! ale_linters/' . l:filetype . '/*.vim' - " Always set an empty List for the loaded linters if we don't find - " any. This will prevent us from executing the runtime command - " many times, redundantly. - if !has_key(s:linters, l:filetype) - let s:linters[l:filetype] = [] - endif + let s:runtime_loaded_map[l:filetype] = 1 endif call extend(l:combined_linters, get(s:linters, l:filetype, [])) @@ -418,12 +466,20 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort return {} endif + 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 + endif + if a:linter.lsp is# 'socket' let l:address = ale#linter#GetAddress(a:buffer, a:linter) let l:conn_id = ale#lsp#ConnectToAddress( \ l:address, \ l:root, \ a:callback, + \ l:initialization_options, \) else let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) @@ -441,6 +497,7 @@ function! ale#linter#StartLSP(buffer, linter, callback) abort \ l:command, \ l:root, \ a:callback, + \ l:initialization_options, \) endif diff --git a/sources_non_forked/ale/autoload/ale/list.vim b/sources_non_forked/ale/autoload/ale/list.vim index 30b8f5cf..35304a09 100644 --- a/sources_non_forked/ale/autoload/ale/list.vim +++ b/sources_non_forked/ale/autoload/ale/list.vim @@ -1,6 +1,19 @@ " Author: Bjorn Neergaard , modified by Yann fery " Description: Manages the loclist and quickfix lists +" This flag dictates if ale open the configured loclist +let g:ale_open_list = get(g:, 'ale_open_list', 0) +" This flag dictates if ale keeps open loclist even if there is no error in loclist +let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0) +" This flag dictates that quickfix windows should be opened vertically +let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0) +" The window size to set for the quickfix and loclist windows +let g:ale_list_window_size = get(g:, 'ale_list_window_size', 10) +" A string format for the loclist messages. +let g:ale_loclist_msg_format = get(g:, 'ale_loclist_msg_format', +\ get(g:, 'ale_echo_msg_format', '%code: %%s') +\) + if !exists('s:timer_args') let s:timer_args = {} endif diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index 8db9348f..df4f16dc 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -6,7 +6,7 @@ let s:connections = [] let g:ale_lsp_next_message_id = 1 -function! s:NewConnection() abort +function! s:NewConnection(initialization_options) abort " id: The job ID as a Number, or the server address as a string. " data: The message data received so far. " executable: An executable only set for program connections. @@ -18,6 +18,7 @@ function! s:NewConnection() abort \ 'projects': {}, \ 'open_documents': [], \ 'callback_list': [], + \ 'initialization_options': a:initialization_options, \} call add(s:connections, l:conn) @@ -207,6 +208,11 @@ function! ale#lsp#HandleOtherInitializeResponses(conn, response) abort endfunction function! ale#lsp#HandleMessage(conn, message) abort + if type(a:message) != type('') + " Ignore messages that aren't strings. + return + endif + let a:conn.data .= a:message " Parse the objects now if we can, and keep the remaining text. @@ -266,7 +272,7 @@ endfunction " " The job ID will be returned for for the program if it ran, otherwise " 0 will be returned. -function! ale#lsp#StartProgram(executable, command, project_root, callback) abort +function! ale#lsp#StartProgram(executable, command, project_root, callback, initialization_options) abort if !executable(a:executable) return 0 endif @@ -274,7 +280,7 @@ function! ale#lsp#StartProgram(executable, command, project_root, callback) abor let l:conn = s:FindConnection('executable', a:executable) " Get the current connection or a new one. - let l:conn = !empty(l:conn) ? l:conn : s:NewConnection() + let l:conn = !empty(l:conn) ? l:conn : s:NewConnection(a:initialization_options) let l:conn.executable = a:executable if !has_key(l:conn, 'id') || !ale#job#IsRunning(l:conn.id) @@ -300,10 +306,10 @@ function! ale#lsp#StartProgram(executable, command, project_root, callback) abor endfunction " Connect to an address and set up a callback for handling responses. -function! ale#lsp#ConnectToAddress(address, project_root, callback) abort +function! ale#lsp#ConnectToAddress(address, project_root, callback, initialization_options) abort let l:conn = s:FindConnection('id', a:address) " Get the current connection or a new one. - let l:conn = !empty(l:conn) ? l:conn : s:NewConnection() + let l:conn = !empty(l:conn) ? l:conn : s:NewConnection(a:initialization_options) if !has_key(l:conn, 'channel') || ch_status(l:conn.channel) isnot# 'open' let l:conn.channnel = ch_open(a:address, { @@ -378,7 +384,7 @@ function! ale#lsp#Send(conn_id, message, ...) abort " Only send the init message once. if !l:project.init_request_id let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( - \ ale#lsp#message#Initialize(l:project_root), + \ ale#lsp#message#Initialize(l:project_root, l:conn.initialization_options), \) let l:project.init_request_id = l:init_id diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim index 0b73cfc2..9e05156d 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -24,12 +24,15 @@ function! ale#lsp#message#GetNextVersionID() abort return l:id endfunction -function! ale#lsp#message#Initialize(root_path) abort +function! ale#lsp#message#Initialize(root_path, initialization_options) abort " TODO: Define needed capabilities. + " NOTE: rootPath is deprecated in favour of rootUri return [0, 'initialize', { \ 'processId': getpid(), \ 'rootPath': a:root_path, \ 'capabilities': {}, + \ 'initializationOptions': a:initialization_options, + \ 'rootUri': ale#path#ToURI(a:root_path), \}] endfunction @@ -116,3 +119,22 @@ function! ale#lsp#message#Definition(buffer, line, column) abort \ 'position': {'line': a:line - 1, 'character': a:column}, \}] endfunction + +function! ale#lsp#message#References(buffer, line, column) abort + return [0, 'textDocument/references', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column}, + \ 'context': {'includeDeclaration': v:false}, + \}] +endfunction + +function! ale#lsp#message#Hover(buffer, line, column) abort + return [0, 'textDocument/hover', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column}, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim index 5a431287..94794e98 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/response.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -1,6 +1,20 @@ " Author: w0rp " Description: Parsing and transforming of LSP server responses. +" Constants for error codes. +" Defined by JSON RPC +let s:PARSE_ERROR = -32700 +let s:INVALID_REQUEST = -32600 +let s:METHOD_NOT_FOUND = -32601 +let s:INVALID_PARAMS = -32602 +let s:INTERNAL_ERROR = -32603 +let s:SERVER_ERROR_START = -32099 +let s:SERVER_ERROR_END = -32000 +let s:SERVER_NOT_INITIALIZED = -32002 +let s:UNKNOWN_ERROR_CODE = -32001 +" Defined by the protocol. +let s:REQUEST_CANCELLED = -32800 + " Constants for message severity codes. let s:SEVERITY_ERROR = 1 let s:SEVERITY_WARNING = 2 @@ -72,3 +86,31 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort return l:loclist endfunction + +function! ale#lsp#response#GetErrorMessage(response) abort + if type(get(a:response, 'error', 0)) isnot type({}) + return '' + endif + + let l:code = get(a:response.error, 'code') + + " Only report things for these error codes. + if l:code isnot s:INVALID_PARAMS && l:code isnot s:INTERNAL_ERROR + return '' + endif + + let l:message = get(a:response.error, 'message', '') + + if empty(l:message) + return '' + endif + + " Include the traceback as details, if it's there. + let l:traceback = get(get(a:response.error, 'data', {}), 'traceback', []) + + if type(l:traceback) is type([]) && !empty(l:traceback) + let l:message .= "\n" . join(l:traceback, "\n") + endif + + return l:message +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim index b9bd7a01..d6919516 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -61,3 +61,19 @@ function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort \ 'file': expand('#' . a:buffer . ':p'), \}] endfunction + +function! ale#lsp#tsserver_message#References(buffer, line, column) abort + return [0, 'ts@references', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#Quickinfo(buffer, line, column) abort + return [0, 'ts@quickinfo', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/pattern_options.vim b/sources_non_forked/ale/autoload/ale/pattern_options.vim index e58b8cf2..d1f91785 100644 --- a/sources_non_forked/ale/autoload/ale/pattern_options.vim +++ b/sources_non_forked/ale/autoload/ale/pattern_options.vim @@ -1,6 +1,11 @@ " Author: w0rp " Description: Set options in files based on regex patterns. +" A dictionary mapping regular expression patterns to arbitrary buffer +" variables to be set. Useful for configuring ALE based on filename patterns. +let g:ale_pattern_options = get(g:, 'ale_pattern_options', {}) +let g:ale_pattern_options_enabled = get(g:, 'ale_pattern_options_enabled', !empty(g:ale_pattern_options)) + " These variables are used to cache the sorting of patterns below. let s:last_pattern_options = {} let s:sorted_items = [] @@ -18,7 +23,8 @@ function! s:CmpPatterns(left_item, right_item) abort endfunction function! ale#pattern_options#SetOptions(buffer) abort - if !g:ale_pattern_options_enabled || empty(g:ale_pattern_options) + if !get(g:, 'ale_pattern_options_enabled', 0) + \|| empty(get(g:, 'ale_pattern_options', 0)) return endif diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 3b1c16a6..c03cfe51 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -2,13 +2,16 @@ " Description: Preview windows for showing whatever information in. " Open a preview window and show some lines in it. -function! ale#preview#Show(lines) abort +" An optional second argument can set an alternative filetype for the window. +function! ale#preview#Show(lines, ...) abort + let l:filetype = get(a:000, 0, 'ale-preview') + silent pedit ALEPreviewWindow wincmd P setlocal modifiable setlocal noreadonly setlocal nobuflisted - setlocal filetype=ale-preview + let &l:filetype = l:filetype setlocal buftype=nofile setlocal bufhidden=wipe :%d @@ -16,3 +19,50 @@ function! ale#preview#Show(lines) abort setlocal nomodifiable setlocal readonly 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 + let l:lines = [] + + " Create lines to display to users. + for l:item in a:item_list + call add( + \ l:lines, + \ l:item.filename + \ . ':' . l:item.line + \ . ':' . l:item.column, + \) + endfor + + call ale#preview#Show(l:lines, 'ale-preview-selection') + let b:ale_preview_item_list = a:item_list +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, {}) + + if empty(l:item) + return + endif + + if !a:open_in_tab + :q! + endif + + call ale#util#Open( + \ l:item.filename, + \ l:item.line, + \ l:item.column, + \ {'open_in_tab': a:open_in_tab}, + \) +endfunction + +function! ale#preview#OpenSelectionInBuffer() abort + call s:Open(0) +endfunction + +function! ale#preview#OpenSelectionInTab() abort + call s:Open(1) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index 82dd9d7c..cdc71cdd 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -15,6 +15,7 @@ let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ function! ale#python#FindProjectRootIni(buffer) abort for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + " If you change this, update ale-python-root documentation. if filereadable(l:path . '/MANIFEST.in') \|| filereadable(l:path . '/setup.cfg') \|| filereadable(l:path . '/pytest.ini') diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim new file mode 100644 index 00000000..9777519d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -0,0 +1,111 @@ +let s:references_map = {} + +" Used to get the references map in tests. +function! ale#references#GetMap() abort + return deepcopy(s:references_map) +endfunction + +" Used to set the references map in tests. +function! ale#references#SetMap(map) abort + let s:references_map = a:map +endfunction + +function! ale#references#ClearLSPData() abort + let s:references_map = {} +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) + + if get(a:response, 'success', v:false) is v:true + let l:item_list = [] + + for l:response_item in a:response.body.refs + call add(l:item_list, { + \ 'filename': l:response_item.file, + \ 'line': l:response_item.start.line, + \ 'column': l:response_item.start.offset, + \}) + endfor + + if empty(l:item_list) + call ale#util#Execute('echom ''No references found.''') + else + call ale#preview#ShowSelection(l:item_list) + endif + endif + endif +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) + + " The result can be a Dictionary item, a List of the same, or null. + let l:result = get(a:response, 'result', []) + let l:item_list = [] + + for l:response_item in l:result + call add(l:item_list, { + \ 'filename': ale#path#FromURI(l:response_item.uri), + \ 'line': l:response_item.range.start.line + 1, + \ 'column': l:response_item.range.start.character + 1, + \}) + endfor + + if empty(l:item_list) + call ale#util#Execute('echom ''No references found.''') + else + call ale#preview#ShowSelection(l:item_list) + endif + endif +endfunction + +function! s:FindReferences(linter) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getcurpos()[1:2] + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#references#HandleTSServerResponse') + \ : function('ale#references#HandleLSPResponse') + + let l:lsp_details = ale#linter#StartLSP(l:buffer, a:linter, l:Callback) + + if empty(l:lsp_details) + return 0 + endif + + let l:id = l:lsp_details.connection_id + let l:root = l:lsp_details.project_root + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#References( + \ l:buffer, + \ l:line, + \ l:column + \) + else + " Send a message saying the buffer has changed first, or the + " references position probably won't make sense. + call ale#lsp#Send(l:id, ale#lsp#message#DidChange(l:buffer), l:root) + + let l:column = min([l:column, len(getline(l:line))]) + + let l:message = ale#lsp#message#References(l:buffer, l:line, l:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message, l:root) + + let s:references_map[l:request_id] = {} +endfunction + +function! ale#references#Find() abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:FindReferences(l:linter) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index 1c439bc8..31663721 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -2,6 +2,25 @@ scriptencoding utf8 " Author: w0rp " Description: Draws error and warning signs into signcolumn +" This flag can be set to some integer to control the maximum number of signs +" that ALE will set. +let g:ale_max_signs = get(g:, 'ale_max_signs', -1) +" This flag can be set to 1 to enable changing the sign column colors when +" there are errors. +let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', 0) +" These variables dictate what signs are used to indicate errors and warnings. +let g:ale_sign_error = get(g:, 'ale_sign_error', '>>') +let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error) +let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--') +let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning) +let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning) +" This variable sets an offset which can be set for sign IDs. +" This ID can be changed depending on what IDs are set for other plugins. +" The dummy sign will use the ID exactly equal to the offset. +let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) +" This flag can be set to 1 to keep sign gutter always open +let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) + if !hlexists('ALEErrorSign') highlight link ALEErrorSign error endif @@ -60,55 +79,35 @@ execute 'sign define ALEInfoSign text=' . g:ale_sign_info \ . ' texthl=ALEInfoSign linehl=ALEInfoLine' sign define ALEDummySign -let s:error_priority = 1 -let s:warning_priority = 2 -let s:info_priority = 3 -let s:style_error_priority = 4 -let s:style_warning_priority = 5 - function! ale#sign#GetSignName(sublist) abort - let l:priority = s:style_warning_priority + let l:priority = g:ale#util#style_warning_priority " Determine the highest priority item for the line. for l:item in a:sublist - if l:item.type is# 'I' - let l:item_priority = s:info_priority - elseif l:item.type is# 'W' - if get(l:item, 'sub_type', '') is# 'style' - let l:item_priority = s:style_warning_priority - else - let l:item_priority = s:warning_priority - endif - else - if get(l:item, 'sub_type', '') is# 'style' - let l:item_priority = s:style_error_priority - else - let l:item_priority = s:error_priority - endif - endif + let l:item_priority = ale#util#GetItemPriority(l:item) - if l:item_priority < l:priority + if l:item_priority > l:priority let l:priority = l:item_priority endif endfor - if l:priority is# s:error_priority + if l:priority is# g:ale#util#error_priority return 'ALEErrorSign' endif - if l:priority is# s:warning_priority + if l:priority is# g:ale#util#warning_priority return 'ALEWarningSign' endif - if l:priority is# s:style_error_priority + if l:priority is# g:ale#util#style_error_priority return 'ALEStyleErrorSign' endif - if l:priority is# s:style_warning_priority + if l:priority is# g:ale#util#style_warning_priority return 'ALEStyleWarningSign' endif - if l:priority is# s:info_priority + if l:priority is# g:ale#util#info_priority return 'ALEInfoSign' endif diff --git a/sources_non_forked/ale/autoload/ale/statusline.vim b/sources_non_forked/ale/autoload/ale/statusline.vim index 3f53368b..851618cc 100644 --- a/sources_non_forked/ale/autoload/ale/statusline.vim +++ b/sources_non_forked/ale/autoload/ale/statusline.vim @@ -1,6 +1,14 @@ " Author: KabbAmine " Description: Statusline related function(s) +" remove in 2.0 +" +" A deprecated setting for ale#statusline#Status() +" See :help ale#statusline#Count() for getting status reports. +let g:ale_statusline_format = get(g:, 'ale_statusline_format', +\ ['%d error(s)', '%d warning(s)', 'OK'] +\) + function! s:CreateCountDict() abort " Keys 0 and 1 are for backwards compatibility. " The count object used to be a List of [error_count, warning_count]. @@ -90,6 +98,8 @@ function! s:StatusForListFormat() abort return l:res endfunction +" remove in 2.0 +" " Returns a formatted string that can be integrated in the statusline. " " This function is deprecated, and should not be used. Use the airline plugin diff --git a/sources_non_forked/ale/autoload/ale/toggle.vim b/sources_non_forked/ale/autoload/ale/toggle.vim index 2fa98b4a..d8472cd8 100644 --- a/sources_non_forked/ale/autoload/ale/toggle.vim +++ b/sources_non_forked/ale/autoload/ale/toggle.vim @@ -1,84 +1,6 @@ -function! ale#toggle#InitAuGroups() abort - " This value used to be a Boolean as a Number, and is now a String. - let l:text_changed = '' . g:ale_lint_on_text_changed - - augroup ALEPatternOptionsGroup - autocmd! - autocmd BufEnter,BufRead * call ale#pattern_options#SetOptions(str2nr(expand(''))) - augroup END - - augroup ALERunOnTextChangedGroup - autocmd! - if g:ale_enabled - if l:text_changed is? 'always' || l:text_changed is# '1' - autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) - elseif l:text_changed is? 'normal' - autocmd TextChanged * call ale#Queue(g:ale_lint_delay) - elseif l:text_changed is? 'insert' - autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) - endif - endif - augroup END - - augroup ALERunOnEnterGroup - autocmd! - if g:ale_enabled - " Handle everything that needs to happen when buffers are entered. - autocmd BufEnter * call ale#events#EnterEvent(str2nr(expand(''))) - endif - if g:ale_enabled && g:ale_lint_on_enter - autocmd BufWinEnter,BufRead * call ale#Queue(0, 'lint_file', str2nr(expand(''))) - " Track when the file is changed outside of Vim. - autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''))) - endif - augroup END - - augroup ALERunOnFiletypeChangeGroup - autocmd! - if g:ale_enabled && g:ale_lint_on_filetype_changed - " Only start linting if the FileType actually changes after - " opening a buffer. The FileType will fire when buffers are opened. - autocmd FileType * call ale#events#FileTypeEvent( - \ str2nr(expand('')), - \ expand('') - \) - endif - augroup END - - augroup ALERunOnSaveGroup - autocmd! - autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand(''))) - augroup END - - augroup ALERunOnInsertLeave - autocmd! - if g:ale_enabled && g:ale_lint_on_insert_leave - autocmd InsertLeave * call ale#Queue(0) - endif - augroup END - - augroup ALECursorGroup - autocmd! - if g:ale_enabled && g:ale_echo_cursor - autocmd CursorMoved,CursorHold * call ale#cursor#EchoCursorWarningWithDelay() - " Look for a warning to echo as soon as we leave Insert mode. - " The script's position variable used when moving the cursor will - " not be changed here. - autocmd InsertLeave * call ale#cursor#EchoCursorWarning() - endif - augroup END - - if !g:ale_enabled - augroup! ALERunOnTextChangedGroup - augroup! ALERunOnEnterGroup - augroup! ALERunOnInsertLeave - augroup! ALECursorGroup - endif -endfunction - function! s:EnablePreamble() abort " Set pattern options again, if enabled. - if g:ale_pattern_options_enabled + if get(g:, 'ale_pattern_options_enabled', 0) call ale#pattern_options#SetOptions(bufnr('')) endif @@ -126,16 +48,11 @@ function! ale#toggle#Toggle() abort endif endif - call ale#toggle#InitAuGroups() + call ale#autocmd#InitAuGroups() endfunction function! ale#toggle#Enable() abort if !g:ale_enabled - " Set pattern options again, if enabled. - if g:ale_pattern_options_enabled - call ale#pattern_options#SetOptions(bufnr('')) - endif - call ale#toggle#Toggle() endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index b94a11b7..4e789b72 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -11,6 +11,25 @@ function! ale#util#FeedKeys(...) abort return call('feedkeys', a:000) endfunction +" Show a message in as small a window as possible. +" +" Vim 8 does not support echoing long messages from asynchronous callbacks, +" but NeoVim does. Small messages can be echoed in Vim 8, and larger messages +" have to be shown in preview windows. +function! ale#util#ShowMessage(string) abort + " We have to assume the user is using a monospace font. + if has('nvim') || (a:string !~? "\n" && len(a:string) < &columns) + execute 'echo a:string' + else + call ale#preview#Show(split(a:string, "\n")) + endif +endfunction + +" A wrapper function for execute, so we can test executing some commands. +function! ale#util#Execute(expr) abort + execute a:expr +endfunction + if !exists('g:ale#util#nul_file') " A null file for sending output to nothing. let g:ale#util#nul_file = '/dev/null' @@ -33,6 +52,42 @@ function! ale#util#GetFunction(string_or_ref) abort return a:string_or_ref endfunction +function! ale#util#Open(filename, line, column, options) abort + if get(a:options, 'open_in_tab', 0) + call ale#util#Execute('tabedit ' . fnameescape(a:filename)) + else + call ale#util#Execute('edit ' . fnameescape(a:filename)) + endif + + call cursor(a:line, a:column) +endfunction + +let g:ale#util#error_priority = 5 +let g:ale#util#warning_priority = 4 +let g:ale#util#info_priority = 3 +let g:ale#util#style_error_priority = 2 +let g:ale#util#style_warning_priority = 1 + +function! ale#util#GetItemPriority(item) abort + if a:item.type is# 'I' + return g:ale#util#info_priority + endif + + if a:item.type is# 'W' + if get(a:item, 'sub_type', '') is# 'style' + return g:ale#util#style_warning_priority + endif + + return g:ale#util#warning_priority + endif + + if get(a:item, 'sub_type', '') is# 'style' + return g:ale#util#style_error_priority + endif + + return g:ale#util#error_priority +endfunction + " Compare two loclist items for ALE, sorted by their buffers, filenames, and " line numbers and column numbers. function! ale#util#LocItemCompare(left, right) abort @@ -70,6 +125,23 @@ function! ale#util#LocItemCompare(left, right) abort return 1 endif + " When either of the items lacks a problem type, then the two items should + " be considered equal. This is important for loclist jumping. + if !has_key(a:left, 'type') || !has_key(a:right, 'type') + return 0 + endif + + let l:left_priority = ale#util#GetItemPriority(a:left) + let l:right_priority = ale#util#GetItemPriority(a:right) + + if l:left_priority < l:right_priority + return -1 + endif + + if l:left_priority > l:right_priority + return 1 + endif + return 0 endfunction @@ -139,6 +211,17 @@ function! ale#util#BinarySearch(loclist, buffer, line, column) abort let l:index += 1 endwhile + " Scan forwards to find the last item on the column for the item + " we found, which will have the most serious problem. + let l:item_column = a:loclist[l:index].col + + while l:index < l:max + \&& a:loclist[l:index + 1].bufnr == a:buffer + \&& a:loclist[l:index + 1].lnum == a:line + \&& a:loclist[l:index + 1].col == l:item_column + let l:index += 1 + endwhile + return l:index endif endwhile @@ -287,8 +370,10 @@ if !exists('s:patial_timers') endif function! s:ApplyPartialTimer(timer_id) abort - let [l:Callback, l:args] = remove(s:partial_timers, a:timer_id) - call call(l:Callback, [a:timer_id] + l:args) + if has_key(s:partial_timers, a:timer_id) + let [l:Callback, l:args] = remove(s:partial_timers, a:timer_id) + call call(l:Callback, [a:timer_id] + l:args) + endif endfunction " Given a delay, a callback, a List of arguments, start a timer with @@ -311,3 +396,13 @@ function! ale#util#StopPartialTimer(timer_id) abort call remove(s:partial_timers, a:timer_id) endif endfunction + +" Given a possibly multi-byte string and a 1-based character position on a +" line, return the 1-based byte position on that line. +function! ale#util#Col(str, chr) abort + if a:chr < 2 + return a:chr + endif + + return strlen(join(split(a:str, '\zs')[0:a:chr - 2], '')) + 1 +endfunction diff --git a/sources_non_forked/ale/doc/ale-cpp.txt b/sources_non_forked/ale/doc/ale-cpp.txt index 05e54799..8bd111e4 100644 --- a/sources_non_forked/ale/doc/ale-cpp.txt +++ b/sources_non_forked/ale/doc/ale-cpp.txt @@ -156,6 +156,26 @@ g:ale_cpp_cpplint_options *g:ale_cpp_cpplint_options* This variable can be changed to modify flags given to cpplint. +=============================================================================== +cquery *ale-cpp-cquery* + +g:ale_cpp_cquery_executable *g:ale_cpp_cquery_executable* + *b:ale_cpp_cquery_executable* + Type: |String| + Default: `'cquery'` + + This variable can be changed to use a different executable for cquery. + + +g:ale_cpp_cquery_cache_directory *g:ale_cpp_cquery_cache_directory* + *b:ale_cpp_cquery_cache_directory* + Type: |String| + Default: `'~/.cache/cquery'` + + This variable can be changed to decide which directory cquery uses for its + cache. + + =============================================================================== flawfinder *ale-cpp-flawfinder* diff --git a/sources_non_forked/ale/doc/ale-css.txt b/sources_non_forked/ale/doc/ale-css.txt index 474445b8..f3cae385 100644 --- a/sources_non_forked/ale/doc/ale-css.txt +++ b/sources_non_forked/ale/doc/ale-css.txt @@ -30,7 +30,7 @@ g:ale_css_stylelint_options *g:ale_css_stylelint_options* g:ale_css_stylelint_use_global *g:ale_css_stylelint_use_global* *b:ale_css_stylelint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-elm.txt b/sources_non_forked/ale/doc/ale-elm.txt index e96205df..de7d8939 100644 --- a/sources_non_forked/ale/doc/ale-elm.txt +++ b/sources_non_forked/ale/doc/ale-elm.txt @@ -16,7 +16,7 @@ g:ale_elm_format_executable *g:ale_elm_format_executable* g:ale_elm_format_use_global *g:ale_elm_format_use_global* *b:ale_elm_format_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -34,7 +34,7 @@ elm-make *ale-elm-elm-make* g:ale_elm_make_executable *g:ale_elm_make_executable* *b:ale_elm_make_executable* Type: |String| - Default: `'elm-make'` + Default: `'elm'` See |ale-integrations-local-executables| @@ -42,7 +42,7 @@ g:ale_elm_make_executable *g:ale_elm_make_executable* g:ale_elm_make_use_global *g:ale_elm_make_use_global* *b:ale_elm_make_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-gitcommit.txt b/sources_non_forked/ale/doc/ale-gitcommit.txt index 71813dd0..38f3fd90 100644 --- a/sources_non_forked/ale/doc/ale-gitcommit.txt +++ b/sources_non_forked/ale/doc/ale-gitcommit.txt @@ -19,18 +19,20 @@ g:ale_gitcommit_gitlint_options *g:ale_gitcommit_gitlint_options* Default: `''` This variable can be changed to add command-line arguments to the gitlint - invocation. + invocation. For example, you can specify the path to a configuration file. > - For example, to dinamically set the gitlint configuration file path, you - may want to set > + let g:ale_gitcommit_gitlint_options = '-C /home/user/.config/gitlint.ini' +< + You can also disable particular error codes using this option. For example, + you can ignore errors for git commits with a missing body. > - let g:ale_gitcommit_gitlint_options = '-C /home/user/.config/gitlint.ini' + let g:ale_gitcommit_gitlint_options = '--ignore B6' < g:ale_gitcommit_gitlint_use_global *g:ale_gitcommit_gitlint_use_global* *b:ale_gitcommit_gitlint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable controls whether or not ALE will search for gitlint in a virtualenv directory first. If this variable is set to `1`, then ALE will diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index b80bd454..60d6cb84 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -73,8 +73,8 @@ g:ale_go_gometalinter_options *g:ale_go_gometalinter_options* number of linters known to be slow or consume a lot of resources. -g:ale_go_gometalinter_package *g:ale_go_gometalinter_package* - *b:ale_go_gometalinter_package* +g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package* + *b:ale_go_gometalinter_lint_package* Type: |Number| Default: `0` @@ -94,8 +94,8 @@ g:ale_go_staticcheck_options *g:ale_go_staticcheck_options* linter. -g:ale_go_staticcheck_package *g:ale_go_staticcheck_package* - *b:ale_go_staticcheck_package* +g:ale_go_staticcheck_lint_package *g:ale_go_staticcheck_lint_package* + *b:ale_go_staticcheck_lint_package* Type: |Number| Default: `0` diff --git a/sources_non_forked/ale/doc/ale-handlebars.txt b/sources_non_forked/ale/doc/ale-handlebars.txt index 6908aac6..061c5d3c 100644 --- a/sources_non_forked/ale/doc/ale-handlebars.txt +++ b/sources_non_forked/ale/doc/ale-handlebars.txt @@ -16,7 +16,7 @@ g:ale_handlebars_embertemplatelint_executable g:ale_handlebars_embertemplatelint_use_global *g:ale_handlebars_embertemplatelint_use_global* Type: |Number| *b:ale_handlebars_embertemplatelint_use_global* - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index 9fab39bf..09ecd92d 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -36,10 +36,16 @@ g:ale_haskell_hdevtools_executable *g:ale_haskell_hdevtools_executable* g:ale_haskell_hdevtools_options *g:ale_haskell_hdevtools_options* *b:ale_haskell_hdevtools_options* Type: |String| - Default: `'-g -Wall'` + Default: `get(g:, 'hdevtools_options', '-g -Wall')` This variable can be changed to modify flags given to hdevtools. + The hdevtools documentation recommends setting GHC options for `hdevtools` + with `g:hdevtools_options`. ALE will use the value of `g:hdevtools_options` + for the value of `g:ale_haskell_hdevtools_options` by default, so this + option can be respected and overridden specifically for ALE. + + =============================================================================== hfmt *ale-haskell-hfmt* diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt index 416e932e..2d8873ef 100644 --- a/sources_non_forked/ale/doc/ale-html.txt +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -24,7 +24,7 @@ g:ale_html_htmlhint_options *g:ale_html_htmlhint_options* g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* *b:ale_html_htmlhint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-java.txt b/sources_non_forked/ale/doc/ale-java.txt index 0d2011f8..4481e823 100644 --- a/sources_non_forked/ale/doc/ale-java.txt +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -25,6 +25,14 @@ g:ale_java_javac_classpath *g:ale_java_javac_classpath* This variable can be set to change the global classpath for Java. +g:ale_java_javac_executable *g:ale_java_javac_executable* + *b:ale_java_javac_executable* + Type: |String| + Default: `'javac'` + + This variable can be set to change the executable path used for javac. + + g:ale_java_javac_options *g:ale_java_javac_options* *b:ale_java_javac_options* Type: |String| @@ -53,5 +61,19 @@ g:ale_java_google_java_format_options *g:ale_java_google_java_format_options* This variable can be set to pass additional options + +=============================================================================== +pmd *ale-java-pmd* + +g:ale_java_pmd_options *g:ale_java_pmd_options* + *b:ale_java_pmd_options* + + Type: String + Default: '-R category/java/bestpractices' + + This variable can be changed to modify flags given to PMD. Do not specify -f + and -d. They are added automatically. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-javascript.txt b/sources_non_forked/ale/doc/ale-javascript.txt index f625fd7f..53a70fd7 100644 --- a/sources_non_forked/ale/doc/ale-javascript.txt +++ b/sources_non_forked/ale/doc/ale-javascript.txt @@ -45,7 +45,7 @@ g:ale_javascript_eslint_options *g:ale_javascript_eslint_options* g:ale_javascript_eslint_use_global *g:ale_javascript_eslint_use_global* *b:ale_javascript_eslint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -98,11 +98,22 @@ g:ale_javascript_flow_use_home_config *g:ale_javascript_flow_use_home_config* g:ale_javascript_flow_use_global *g:ale_javascript_flow_use_global* *b:ale_javascript_flow_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| +g:ale_javascript_flow_use_respect_pragma + *g:ale_javascript_flow_use_respect_pragma* + *b:ale_javascript_flow_use_respect_pragma* + Type: |Number| + Default: `1` + + By default, ALE will use the `--respect-pragma` option for `flow`, so only + files with the `@flow` pragma are checked by ALE. This option can be set to + `0` to disable that behaviour, so all files can be checked by `flow`. + + =============================================================================== importjs *ale-javascript-importjs* @@ -126,7 +137,7 @@ g:ale_javascript_jscs_executable *g:ale_javascript_jscs_executable* g:ale_javascript_jscs_use_global *g:ale_javascript_jscs_use_global* *b:ale_javascript_jscs_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -145,7 +156,7 @@ g:ale_javascript_jshint_executable *g:ale_javascript_jshint_executable* g:ale_javascript_jshint_use_global *g:ale_javascript_jshint_use_global* *b:ale_javascript_jshint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -172,7 +183,7 @@ g:ale_javascript_prettier_options *g:ale_javascript_prettier_options* g:ale_javascript_prettier_use_global *g:ale_javascript_prettier_use_global* *b:ale_javascript_prettier_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -202,7 +213,7 @@ g:ale_javascript_prettier_eslint_use_global *g:ale_javascript_prettier_eslint_use_global* *b:ale_javascript_prettier_eslint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -233,7 +244,7 @@ g:ale_javascript_prettier_standard_use_global *g:ale_javascript_prettier_standard_use_global* *b:ale_javascript_prettier_standard_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -262,7 +273,7 @@ g:ale_javascript_standard_options *g:ale_javascript_standard_options* g:ale_javascript_standard_use_global *g:ale_javascript_standard_use_global* *b:ale_javascript_standard_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -289,7 +300,7 @@ g:ale_javascript_xo_options *g:ale_javascript_xo_options* g:ale_javascript_xo_use_global *g:ale_javascript_xo_use_global* *b:ale_javascript_xo_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-json.txt b/sources_non_forked/ale/doc/ale-json.txt index 1e97abce..0ec7932d 100644 --- a/sources_non_forked/ale/doc/ale-json.txt +++ b/sources_non_forked/ale/doc/ale-json.txt @@ -44,7 +44,7 @@ g:ale_json_fixjson_use_global *g:ale_json_fixjson_use_global* *b:ale_json_fixjson_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-less.txt b/sources_non_forked/ale/doc/ale-less.txt index 05f56e2b..040e511e 100644 --- a/sources_non_forked/ale/doc/ale-less.txt +++ b/sources_non_forked/ale/doc/ale-less.txt @@ -24,7 +24,7 @@ g:ale_less_lessc_options *g:ale_less_lessc_options* g:ale_less_lessc_use_global *g:ale_less_lessc_use_global* *b:ale_less_lessc_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -57,7 +57,7 @@ g:ale_less_stylelint_options *g:ale_less_stylelint_options* g:ale_less_stylelint_use_global *g:ale_less_stylelint_use_global* *b:ale_less_stylelint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-markdown.txt b/sources_non_forked/ale/doc/ale-markdown.txt index d7e50093..63ddcae4 100644 --- a/sources_non_forked/ale/doc/ale-markdown.txt +++ b/sources_non_forked/ale/doc/ale-markdown.txt @@ -10,7 +10,8 @@ g:ale_markdown_mdl_executable *g:ale_markdown_mdl_executable* Type: |String| Default: `'mdl'` - See |ale-integrations-local-executables| + Override the invoked mdl binary. This is useful for running mdl from + binstubs or a bundle. g:ale_markdown_mdl_options *g:ale_markdown_mdl_options* diff --git a/sources_non_forked/ale/doc/ale-mercury.txt b/sources_non_forked/ale/doc/ale-mercury.txt new file mode 100644 index 00000000..ca06a0a7 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-mercury.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE Mercury Integration *ale-mercury-options* + + +=============================================================================== +mmc *ale-mercury-mmc* + + +g:ale_mercury_mmc_executable *g:ale_mercury_mmc_executable* + *b:ale_mercury_mmc_executable* + Type: |String| + Default: `'mmc'` + + This variable can be changed to use a different executable for mmc. + + +g:ale_mercury_mmc_options *g:ale_mercury_mmc_options* + *b:ale_mercury_mmc_options* + Type: |String| + Default: `'--make --output-compile-error-lines 100'` + + This variable can be set to pass additional options to mmc. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nasm.txt b/sources_non_forked/ale/doc/ale-nasm.txt new file mode 100644 index 00000000..16c024a1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nasm.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE NASM Integration *ale-nasm-options* + + +=============================================================================== +nasm *ale-nasm-nasm* + +g:ale_nasm_nasm_executable *g:ale_nasm_nasm_executable* + *b:ale_nasm_nasm_executable* + + Type: |String| + Default `'nasm'` + + This variable can be changed to use different executable for NASM. + + +g:ale_nasm_nasm_options *g:ale_nasm_nasm_options* + *b:ale_nasm_nasm_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to NASM. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ocaml.txt b/sources_non_forked/ale/doc/ale-ocaml.txt index cfa365af..a7ef8d29 100644 --- a/sources_non_forked/ale/doc/ale-ocaml.txt +++ b/sources_non_forked/ale/doc/ale-ocaml.txt @@ -28,7 +28,7 @@ g:ale_ocaml_ols_executable *g:ale_ocaml_ols_executable* g:ale_ocaml_ols_use_global *g:ale_ocaml_ols_use_global* *b:ale_ocaml_ols_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable can be set to `1` to always use the globally installed executable. See also |ale-integrations-local-executables|. diff --git a/sources_non_forked/ale/doc/ale-perl.txt b/sources_non_forked/ale/doc/ale-perl.txt index 0a4adfff..761c2735 100644 --- a/sources_non_forked/ale/doc/ale-perl.txt +++ b/sources_non_forked/ale/doc/ale-perl.txt @@ -76,7 +76,16 @@ g:ale_perl_perlcritic_showrules *g:ale_perl_perlcritic_showrules* Controls whether perlcritic rule names are shown after the error message. Defaults to off to reduce length of message. +=============================================================================== +perltidy *ale-perl-perltidy* +g:ale_perl_perltidy_options *g:ale_perl_perltidy_options* + *b:ale_perl_perltidy_options* + Type: |String| + Default: `''` + + This variable can be changed to alter the command-line arguments to + the perltidy invocation. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt index 7edfe231..33796f7c 100644 --- a/sources_non_forked/ale/doc/ale-php.txt +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -37,7 +37,7 @@ g:ale_php_langserver_executable *g:ale_php_langserver_executable* g:ale_php_langserver_use_global *g:ale_php_langserver_use_global* *b:ale_php_langserver_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable can be set to `1` to force the language server to be run with the executable set for |g:ale_php_langserver_executable|. @@ -48,7 +48,7 @@ g:ale_php_langserver_use_global *g:ale_php_langserver_use_global* =============================================================================== phan *ale-php-phan* -WARNING: please do not use this linter if you have an configuration file +WARNING: please use the phan_client linter if you have an configuration file for your project because the phan will look into your entirely project and ale will display in the current buffer warnings that may belong to other file. @@ -57,8 +57,22 @@ g:ale_php_phan_minimum_severity *g:ale_php_phan_minimum_severity* Type: |Number| Default: `0` - This variable defines the minimum severity level + This variable defines the minimum severity level. +g:ale_php_phan_executable *g:ale_php_phan_executable* + *b:ale_php_phan_executable* + Type: |String| + Default: `'phan'` + + This variable sets executable used for phan or phan_client. + +g:ale_php_phan_use_client *g:ale_php_phan_use_client* + *b:ale_php_phan_use_client* + Type: |Number| + Default: `get(g:, 'ale_php_phan_use_client', 0)` + + This variable can be set to 1 to use the phan_client with phan daemon mode + instead of the phan standalone. =============================================================================== phpcbf *ale-php-phpcbf* @@ -84,7 +98,7 @@ g:ale_php_phpcbf_standard *g:ale_php_phpcbf_standard* g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global* *b:ale_php_phpcbf_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -113,7 +127,7 @@ g:ale_php_phpcs_standard *g:ale_php_phpcs_standard* g:ale_php_phpcs_use_global *g:ale_php_phpcs_use_global* *b:ale_php_phpcs_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -179,9 +193,16 @@ g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* *b:ale_php_cs_fixer_use_global* Type: |Boolean| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable force globally installed fixer. +g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* + *b:ale_php_cs_fixer_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cs-fixer. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pug.txt b/sources_non_forked/ale/doc/ale-pug.txt index 01071485..e2836f85 100644 --- a/sources_non_forked/ale/doc/ale-pug.txt +++ b/sources_non_forked/ale/doc/ale-pug.txt @@ -35,7 +35,7 @@ g:ale_pug_puglint_options *g:ale_pug_puglint_options* g:ale_pug_puglint_use_global *g:ale_pug_puglint_use_global* *b:ale_pug_puglint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index 4d55e751..b24b531d 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -2,6 +2,31 @@ ALE Python Integration *ale-python-options* +=============================================================================== +ALE Python Project Root Behavior *ale-python-root* + +For some linters, ALE will search for a Python project root by looking at the +files in directories on or above where a file being checked is. ALE applies +the following methods, in order: + +1. Find the first directory containing a common Python configuration file. +2. If no configuration file can be found, use the first directory which does + not contain a readable file named `__init__.py`. + +ALE will look for configuration files with the following filenames. > + + MANIFEST.in + setup.cfg + pytest.ini + tox.ini + mypy.ini + pycodestyle.cfg + flake8.cfg +< + +The first directory containing any of the files named above will be used. + + =============================================================================== autopep8 *ale-python-autopep8* @@ -24,7 +49,34 @@ g:ale_python_autopep8_options *g:ale_python_autopep8_options* g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* *b:ale_python_autopep8_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +black *ale-python-black* + +g:ale_python_black_executable *g:ale_python_black_executable* + *b:ale_python_black_executable* + Type: |String| + Default: `'black'` + + See |ale-integrations-local-executables| + +autopep8 +g:ale_python_black_options *g:ale_python_black_options* + *b:ale_python_black_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to black. + + +g:ale_python_black_use_global *g:ale_python_black_use_global* + *b:ale_python_black_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -32,12 +84,24 @@ g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* =============================================================================== flake8 *ale-python-flake8* +g:ale_python_flake8_change_directory *g:ale_python_flake8_change_directory* + *b:ale_python_flake8_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, ALE will switch to the directory the Python file being + checked with `flake8` is in before checking it. This helps `flake8` find + configuration files more easily. This option can be turned off if you want + to control the directory Python is executed from yourself. + + g:ale_python_flake8_executable *g:ale_python_flake8_executable* *b:ale_python_flake8_executable* Type: |String| Default: `'flake8'` - This variable can be changed to modify the executable used for flake8. + This variable can be changed to modify the executable used for flake8. Set + this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. g:ale_python_flake8_options *g:ale_python_flake8_options* @@ -61,7 +125,7 @@ g:ale_python_flake8_options *g:ale_python_flake8_options* g:ale_python_flake8_use_global *g:ale_python_flake8_use_global* *b:ale_python_flake8_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable controls whether or not ALE will search for flake8 in a virtualenv directory first. If this variable is set to `1`, then ALE will @@ -84,7 +148,7 @@ g:ale_python_isort_executable *g:ale_python_isort_executable* g:ale_python_isort_use_global *g:ale_python_isort_use_global* *b:ale_python_isort_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -96,6 +160,8 @@ The minimum supported version of mypy that ALE supports is v0.4.4. This is the first version containing the `--shadow-file` option ALE needs to be able to check for errors while you type. +`mypy` will be run from a detected project root, per |ale-python-root|. + g:ale_python_mypy_executable *g:ale_python_mypy_executable* *b:ale_python_mypy_executable* @@ -104,6 +170,8 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable* See |ale-integrations-local-executables| + Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`. + g:ale_python_mypy_ignore_invalid_syntax *g:ale_python_mypy_ignore_invalid_syntax* *b:ale_python_mypy_ignore_invalid_syntax* @@ -127,7 +195,7 @@ g:ale_python_mypy_options *g:ale_python_mypy_options* g:ale_python_mypy_use_global *g:ale_python_mypy_use_global* *b:ale_python_mypy_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -142,6 +210,8 @@ g:ale_python_prospector_executable *g:ale_python_prospector_executable* See |ale-integrations-local-executables| + Set this to `'pipenv'` to invoke `'pipenv` `run` `prospector'`. + g:ale_python_prospector_options *g:ale_python_prospector_options* *b:ale_python_prospector_options* @@ -167,7 +237,7 @@ g:ale_python_prospector_options *g:ale_python_prospector_options* g:ale_python_prospector_use_global *g:ale_python_prospector_use_global* *b:ale_python_prospector_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -183,6 +253,8 @@ g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable* See |ale-integrations-local-executables| + Set this to `'pipenv'` to invoke `'pipenv` `run` `pycodestyle'`. + g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options* *b:ale_python_pycodestyle_options* @@ -196,14 +268,39 @@ g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options* g:ale_python_pycodestyle_use_global *g:ale_python_pycodestyle_use_global* *b:ale_python_pycodestyle_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| +=============================================================================== +pyflakes *ale-python-pyflakes* + + +g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable* + *b:ale_python_pyflakes_executable* + Type: |String| + Default: `'pyflakes'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`. + + =============================================================================== pylint *ale-python-pylint* +g:ale_python_pylint_change_directory *g:ale_python_pylint_change_directory* + *b: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. + + g:ale_python_pylint_executable *g:ale_python_pylint_executable* *b:ale_python_pylint_executable* Type: |String| @@ -211,6 +308,8 @@ g:ale_python_pylint_executable *g:ale_python_pylint_executable* See |ale-integrations-local-executables| + Set this to `'pipenv'` to invoke `'pipenv` `run` `pylint'`. + g:ale_python_pylint_options *g:ale_python_pylint_options* *b:ale_python_pylint_options* @@ -235,7 +334,7 @@ g:ale_python_pylint_options *g:ale_python_pylint_options* g:ale_python_pylint_use_global *g:ale_python_pylint_use_global* *b:ale_python_pylint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -243,6 +342,9 @@ g:ale_python_pylint_use_global *g:ale_python_pylint_use_global* =============================================================================== pyls *ale-python-pyls* +`pyls` will be run from a detected project root, per |ale-python-root|. + + g:ale_python_pyls_executable *g:ale_python_pyls_executable* *b:ale_python_pyls_executable* Type: |String| @@ -250,11 +352,13 @@ g:ale_python_pyls_executable *g:ale_python_pyls_executable* See |ale-integrations-local-executables| + Set this to `'pipenv'` to invoke `'pipenv` `run` `pyls'`. + g:ale_python_pyls_use_global *g:ale_python_pyls_use_global* *b:ale_python_pyls_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -273,7 +377,7 @@ g:ale_python_yapf_executable *g:ale_python_yapf_executable* g:ale_python_yapf_use_global *g:ale_python_yapf_use_global* *b:ale_python_yapf_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-qml.txt b/sources_non_forked/ale/doc/ale-qml.txt new file mode 100644 index 00000000..f6d715a1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-qml.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE QML Integration *ale-qml-options* + + +=============================================================================== +qmlfmt *ale-qml-qmlfmt* + +g:ale_qml_qmlfmt_executable *g:ale_qml_qmlfmt_executable* + *b:ale_qml_qmlfmt_executable* + Type: |String| + Default: `'qmlfmt'` + + This variable can be set to change the path to qmlfmt. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-reasonml.txt b/sources_non_forked/ale/doc/ale-reasonml.txt index 36ddd75d..426d4c46 100644 --- a/sources_non_forked/ale/doc/ale-reasonml.txt +++ b/sources_non_forked/ale/doc/ale-reasonml.txt @@ -28,7 +28,7 @@ g:ale_reason_ols_executable *g:ale_reason_ols_executable* g:ale_reason_ols_use_global *g:ale_reason_ols_use_global* *b:ale_reason_ols_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable can be set to `1` to always use the globally installed executable. See also |ale-integrations-local-executables|. diff --git a/sources_non_forked/ale/doc/ale-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt index dad9ae66..f9afe17d 100644 --- a/sources_non_forked/ale/doc/ale-rust.txt +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -59,6 +59,26 @@ g:ale_rust_cargo_check_all_targets *g:ale_rust_cargo_check_all_targets* is used. See |g:ale_rust_cargo_use_check|, +g:ale_rust_cargo_check_tests *g:ale_rust_cargo_check_tests* + *b:ale_rust_cargo_check_tests* + Type: |Number| + Default: `0` + + When set to `1`, ALE will set the `--tests` option when `cargo check` + is used. This allows for linting of tests which are normally excluded. + See |g:ale_rust_cargo_use_check|, + + +g:ale_rust_cargo_check_examples *g:ale_rust_cargo_check_examples* + *b:ale_rust_cargo_check_examples* + Type: |Number| + Default: `0` + + When set to `1`, ALE will set the `--examples` option when `cargo check` + is used. This allows for linting of examples which are normally excluded. + See |g:ale_rust_cargo_use_check|, + + g:ale_rust_cargo_default_feature_behavior *g:ale_rust_cargo_default_feature_behavior* *b:ale_rust_cargo_default_feature_behavior* diff --git a/sources_non_forked/ale/doc/ale-sass.txt b/sources_non_forked/ale/doc/ale-sass.txt index 5465957a..08e9a381 100644 --- a/sources_non_forked/ale/doc/ale-sass.txt +++ b/sources_non_forked/ale/doc/ale-sass.txt @@ -16,7 +16,7 @@ g:ale_sass_stylelint_executable *g:ale_sass_stylelint_executable* g:ale_sass_stylelint_use_global *g:ale_sass_stylelint_use_global* *b:ale_sass_stylelint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-scala.txt b/sources_non_forked/ale/doc/ale-scala.txt index 9c9472f6..b5474f3b 100644 --- a/sources_non_forked/ale/doc/ale-scala.txt +++ b/sources_non_forked/ale/doc/ale-scala.txt @@ -2,6 +2,31 @@ ALE Scala Integration *ale-scala-options* +=============================================================================== +scalafmt *ale-scala-scalafmt* + +If Nailgun is used, override `g:ale_scala_scalafmt_executable` like so: > + let g:ale_scala_scalafmt_executable = 'ng' + + +g:ale_scala_scalafmt_executable *g:ale_scala_scalafmt_executable* + *b:ale_scala_scalafmt_executable* + Type: |String| + Default: `'scalafmt'` + + Override the invoked `scalafmt` binary. This is useful for running `scalafmt` + with Nailgun. + + +g:ale_scala_scalafmt_options *g:ale_scala_scalafmt_options* + *b:ale_scala_scalafmt_options* + Type: |String| + Default: `''` + + A string containing additional options to pass to `'scalafmt'`, or + `'ng scalafmt'` if Nailgun is used. + + =============================================================================== scalastyle *ale-scala-scalastyle* diff --git a/sources_non_forked/ale/doc/ale-scss.txt b/sources_non_forked/ale/doc/ale-scss.txt index 19695a76..14e6feb7 100644 --- a/sources_non_forked/ale/doc/ale-scss.txt +++ b/sources_non_forked/ale/doc/ale-scss.txt @@ -22,7 +22,7 @@ g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* *b:ale_scss_stylelint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-stylus.txt b/sources_non_forked/ale/doc/ale-stylus.txt index 59d90551..3e6ba906 100644 --- a/sources_non_forked/ale/doc/ale-stylus.txt +++ b/sources_non_forked/ale/doc/ale-stylus.txt @@ -24,7 +24,7 @@ g:ale_stylus_stylelint_options *g:ale_stylus_stylelint_options* g:ale_stylus_stylelint_use_global *g:ale_stylus_stylelint_use_global* *b:ale_stylus_stylelint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-text.txt b/sources_non_forked/ale/doc/ale-text.txt index 844f2ff4..913d7e61 100644 --- a/sources_non_forked/ale/doc/ale-text.txt +++ b/sources_non_forked/ale/doc/ale-text.txt @@ -27,7 +27,7 @@ g:ale_textlint_options *g:ale_textlint_options* g:ale_textlint_use_global *g:ale_textlint_use_global* *b:ale_textlint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index d83a2dfe..1bccf5a3 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -59,7 +59,7 @@ g:ale_typescript_tslint_rules_dir *g:ale_typescript_tslint_rules_dir* g:ale_typescript_tslint_use_global *g:ale_typescript_tslint_use_global* *b:ale_typescript_tslint_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -91,7 +91,7 @@ g:ale_typescript_tsserver_config_path *g:ale_typescript_tsserver_config_path* g:ale_typescript_tsserver_use_global *g:ale_typescript_tsserver_use_global* *b:ale_typescript_tsserver_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` This variable controls whether or not ALE will search for a local path for tsserver first. If this variable is set to `1`, then ALE will always use the diff --git a/sources_non_forked/ale/doc/ale-vim.txt b/sources_non_forked/ale/doc/ale-vim.txt index 30ac3a16..772bad23 100644 --- a/sources_non_forked/ale/doc/ale-vim.txt +++ b/sources_non_forked/ale/doc/ale-vim.txt @@ -5,6 +5,14 @@ ALE Vim Integration *ale-vim-options* =============================================================================== vint *ale-vim-vint* +g:ale_vim_vint_executable *g:ale_vim_vint_executable* + *b:ale_vim_vint_executable* + Type: |String| + Default: `'vint'` + + This option can be set to change the executable path for Vint. + + g:ale_vim_vint_show_style_issues *g:ale_vim_vint_show_style_issues* *b:ale_vim_vint_show_style_issues* Type: |Number| diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index a902f25d..044d0b3d 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -31,7 +31,7 @@ g:ale_yaml_swaglint_executable *g:ale_yaml_swaglint_executable* g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global* *b:ale_yaml_swaglint_use_global* Type: |String| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index 1c8025a4..0531589c 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -13,6 +13,7 @@ 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| 6. Global Options.......................|ale-options| 6.1 Highlights........................|ale-highlights| 6.2 Options for write-good Linter.....|ale-write-good-options| @@ -43,6 +44,7 @@ CONTENTS *ale-contents* clangtidy...........................|ale-cpp-clangtidy| cppcheck............................|ale-cpp-cppcheck| cpplint.............................|ale-cpp-cpplint| + cquery..............................|ale-cpp-cquery| flawfinder..........................|ale-cpp-flawfinder| gcc.................................|ale-cpp-gcc| c#....................................|ale-cs-options| @@ -106,6 +108,7 @@ CONTENTS *ale-contents* checkstyle..........................|ale-java-checkstyle| javac...............................|ale-java-javac| google-java-format..................|ale-java-google-java-format| + pmd.................................|ale-java-pmd| javascript............................|ale-javascript-options| eslint..............................|ale-javascript-eslint| flow................................|ale-javascript-flow| @@ -141,6 +144,10 @@ CONTENTS *ale-contents* prettier............................|ale-markdown-prettier| 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| @@ -153,6 +160,7 @@ CONTENTS *ale-contents* perl..................................|ale-perl-options| perl................................|ale-perl-perl| perlcritic..........................|ale-perl-perlcritic| + perltidy............................|ale-perl-perltidy| php...................................|ale-php-options| hack................................|ale-php-hack| hackfmt.............................|ale-php-hackfmt| @@ -177,14 +185,18 @@ CONTENTS *ale-contents* puppetlint..........................|ale-puppet-puppetlint| python................................|ale-python-options| autopep8............................|ale-python-autopep8| + black...............................|ale-python-black| flake8..............................|ale-python-flake8| isort...............................|ale-python-isort| mypy................................|ale-python-mypy| prospector..........................|ale-python-prospector| pycodestyle.........................|ale-python-pycodestyle| + pyflakes............................|ale-python-pyflakes| pylint..............................|ale-python-pylint| pyls................................|ale-python-pyls| yapf................................|ale-python-yapf| + qml...................................|ale-qml-options| + qmlfmt..............................|ale-qml-qmlfmt| r.....................................|ale-r-options| lintr...............................|ale-r-lintr| reasonml..............................|ale-reasonml-options| @@ -208,6 +220,7 @@ CONTENTS *ale-contents* sass..................................|ale-sass-options| stylelint...........................|ale-sass-stylelint| scala.................................|ale-scala-options| + scalafmt............................|ale-scala-scalafmt| scalastyle..........................|ale-scala-scalastyle| scss..................................|ale-scss-options| prettier............................|ale-scss-prettier| @@ -307,7 +320,7 @@ Notes: * Bash: `shell` (-n flag), `shellcheck`, `shfmt` * Bourne Shell: `shell` (-n flag), `shellcheck`, `shfmt` * C: `cppcheck`, `cpplint`!!, `clang`, `clangtidy`!!, `clang-format`, `flawfinder`, `gcc` -* C++ (filetype cpp): `clang`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `cppcheck`, `cpplint`!!, `flawfinder`, `gcc` +* C++ (filetype cpp): `clang`, `clangcheck`!!, `clangtidy`!!, `clang-format`, `cppcheck`, `cpplint`!!, `cquery`, `flawfinder`, `gcc` * CUDA: `nvcc`!! * C#: `mcs`, `mcsc`!! * Chef: `foodcritic` @@ -316,6 +329,7 @@ Notes: * CoffeeScript: `coffee`, `coffeelint` * Crystal: `crystal`!! * CSS: `csslint`, `prettier`, `stylelint` +* Cucumber: `cucumber` * Cython (pyrex filetype): `cython` * D: `dmd` * Dafny: `dafny`!! @@ -338,7 +352,7 @@ Notes: * Haskell: `brittany`, `ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt` * HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `write-good` * Idris: `idris` -* Java: `checkstyle`, `javac`, `google-java-format` +* Java: `checkstyle`, `javac`, `google-java-format`, `PMD` * JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo` * JSON: `fixjson`, `jsonlint`, `jq`, `prettier` * Kotlin: `kotlinc`, `ktlint` @@ -350,13 +364,15 @@ Notes: * 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` * Objective-C++: `clang` * OCaml: `merlin` (see |ale-ocaml-merlin|), `ols` -* Perl: `perl -c`, `perl-critic` +* Perl: `perl -c`, `perl-critic`, `perltidy` * PHP: `hack`, `hackfmt`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf`, `php-cs-fixer` * PO: `alex`!!, `msgfmt`, `proselint`, `write-good` * Pod: `alex`!!, `proselint`, `write-good` @@ -364,8 +380,8 @@ Notes: * proto: `protoc-gen-lint` * Pug: `pug-lint` * Puppet: `puppet`, `puppet-lint` -* Python: `autopep8`, `flake8`, `isort`, `mypy`, `prospector`, `pycodestyle`, `pyls`, `pylint`!!, `yapf` -* QML: `qmllint` +* Python: `autopep8`, `black`, `flake8`, `isort`, `mypy`, `prospector`, `pycodestyle`, `pyls`, `pylint`!!, `yapf` +* QML: `qmlfmt`, `qmllint` * R: `lintr` * ReasonML: `merlin`, `ols`, `refmt` * reStructuredText: `alex`!!, `proselint`, `redpen`, `rstcheck`, `vale`, `write-good` @@ -375,10 +391,10 @@ Notes: * Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt` * SASS: `sass-lint`, `stylelint` * SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint` -* Scala: `scalac`, `scalastyle` +* Scala: `fsc`, `scalac`, `scalafmt`, `scalastyle` * Slim: `slim-lint` * SML: `smlnj` -* Solidity: `solhint, solium` +* Solidity: `solhint`, `solium` * Stylus: `stylelint` * SQL: `sqlint` * Swift: `swiftlint`, `swiftformat` @@ -462,14 +478,22 @@ the buffer-local options can be used with external plugins for reading Vim project configuration files. Buffer-local settings can also be used in ftplugin files for different filetypes. +ALE offers several options for controlling which linters are run. + +* Selecting linters to run. - |g:ale_linters| +* Aliasing filetypes for linters - |g:ale_linter_aliases| +* Only running linters you asked for. - |g:ale_linters_explicit| + =============================================================================== 4. Fixing Problems *ale-fix* -ALE can fix problems with files with the |ALEFix| command. When |ALEFix| is -run, the variable |g:ale_fixers| will be read for getting a |List| of commands -for filetypes, split on `.`, and the functions named in |g:ale_fixers| will be -executed for fixing the errors. +ALE can fix problems with files with the |ALEFix| command. |ALEFix| +accepts names of fixers to be applied as arguments. Alternatively, +when no arguments are provided, the variable |g:ale_fixers| will be +read for getting a |List| of commands for filetypes, split on `.`, and +the functions named in |g:ale_fixers| will be executed for fixing the +errors. The |ALEFixSuggest| command can be used to suggest tools that be used to fix problems for the current buffer. @@ -619,6 +643,9 @@ delay for completion can be configured with |g:ale_completion_delay|. ALE will only suggest so many possible matches for completion. The maximum number of items can be controlled with |g:ale_completion_max_suggestions|. +If you don't like some of the suggestions you see, you can filter them out +with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|. + ------------------------------------------------------------------------------- 5.2 Go To Definition *ale-go-to-definition* @@ -631,6 +658,32 @@ information returned by LSP servers. The following commands are supported: |ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab. +------------------------------------------------------------------------------- +5.3 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 +referenced in a codebase when a command is run. The following commands are +supported: + +|ALEFindReferences| - Find references for the word under the cursor. + + +------------------------------------------------------------------------------- +5.4 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: + +|ALEHover| - Print information about the symbol at the cursor. + +If |b:ale_set_balloons| is set to `1` and your version of Vim supports the +|balloon_show()| function, then "hover" information also show up when you move +the mouse over a symbol in a buffer. Diagnostic information will take priority +over hover information for balloons. If a line contains a problem, that +problem will be displayed in a balloon instead of hover information. + + =============================================================================== 6. Global Options *ale-options* @@ -648,7 +701,7 @@ g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled* g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures* Type: |Number| - Default: `0` + Default: undefined When set to `1`, ALE will cache failing executable checks for linters. By default, only executable checks which succeed will be cached. @@ -731,6 +784,24 @@ g:ale_completion_enabled *g:ale_completion_enabled* See |ale-completion| +g:ale_completion_excluded_words *g:ale_completion_excluded_words* + *b:ale_completion_excluded_words* + Type: |List| + Default: `[]` + + This option can be set to a list of |String| values for "words" to exclude + from completion results, as in the words for |complete-items|. The strings + will be matched exactly in a case-sensitive manner. (|==#|) + + This setting can be configured in ftplugin files with buffer variables, so + that different lists can be used for different filetypes. For example: > + + " In ~/.vim/ftplugin/typescript.vim + + " Don't suggest `it` or `describe` so we can use snippets for those words. + let b:ale_completion_excluded_words = ['it', 'describe'] +< + g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Type: |Number| @@ -830,20 +901,6 @@ g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* The string used for `%severity%` for warnings. See |g:ale_echo_msg_format| -g:ale_emit_conflict_warnings *g:ale_emit_conflict_warnings* - - Type: |Number| - Default: `1` - - When set to `0`, ALE will not emit any warnings on startup about conflicting - plugins. ALE will probably not work if other linting plugins are installed. - - When this option is set to `1`, ALE will add its `after` directory to - |runtimepath| automatically, so the checks can be applied. Setting this - option to `0` before ALE is loaded will prevent ALE from modifying - |runtimepath|. - - g:ale_enabled *g:ale_enabled* *b:ale_enabled* @@ -1053,8 +1110,12 @@ g:ale_linter_aliases *g:ale_linter_aliases* following values: > { - \ 'zsh': 'sh', + \ 'Dockerfile': 'dockerfile', \ 'csh': 'sh', + \ 'plaintex': 'tex', + \ 'systemverilog': 'verilog', + \ 'vimwiki': 'markdown', + \ 'zsh': 'sh', \} < For example, if you wish to map a new filetype `'foobar'` to run the `'php'` @@ -1213,7 +1274,7 @@ g:ale_max_signs *g:ale_max_signs* g:ale_maximum_file_size *g:ale_maximum_file_size* *b:ale_maximum_file_size* Type: |Number| - Default: `0` + Default: undefined A maximum file size in bytes for ALE to check. If set to any positive number, ALE will skip checking files larger than the given size. @@ -1294,17 +1355,38 @@ g:ale_set_balloons *g:ale_set_balloons* *b:ale_set_balloons* Type: |Number| - Default: `has('balloon_eval')` + Default: `(has('balloon_eval') && has('gui_running'))` + `|| (has('balloon_eval_term') && !has('gui_running'))` When this option is set to `1`, balloon messages will be displayed for - problems. Problems nearest to the cursor on the line the cursor is over will - be displayed. Balloons will not be shown when either |g:ale_enabled| is `0` - or |b:ale_enabled| is `0`. + problems or hover information if available. + + Problems nearest to the line the mouse cursor is over will be displayed. If + there are no problems to show, and one of the linters is an LSP linter + supporting "Hover" information, per |ale-hover|, then brief information + about the symbol under the cursor will be displayed in a balloon. `b:ale_set_balloons` can be set to `0` to disable balloons for a buffer. Balloons cannot be enabled for a specific buffer when not initially enabled globally. + Balloons will not be shown when |g:ale_enabled| or |b:ale_enabled| is `0`. + + +g:ale_set_balloons_legacy_echo *g:ale_set_balloons_legacy_echo* + *b:ale_set_balloons_legacy_echo* + Type: |Number| + Default: undefined + + If set to `1`, moving your mouse over documents in Vim will make ALE ask + `tsserver` or `LSP` servers for information about the symbol where the mouse + cursor is, and print that information into Vim's echo line. This is an + option for supporting older versions of Vim which do not properly support + balloons in an asynchronous manner. + + If your version of Vim supports the |balloon_show| function, then this + option does nothing meaningful. + g:ale_set_highlights *g:ale_set_highlights* @@ -1492,6 +1574,18 @@ g:ale_type_map *g:ale_type_map* Type maps can be set per-buffer with `b:ale_type_map`. +g:ale_use_global_executables *g:ale_use_global_executables* + + Type: |Number| + Default: not set + + This option can be set to change the default for all `_use_global` options. + This option must be set before ALE is loaded, preferably in a vimrc file. + + See |ale-integrations-local-executables| for more information on those + options. + + g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* @@ -1679,7 +1773,7 @@ g:ale_writegood_options *g:ale_writegood_options* g:ale_writegood_use_global *g:ale_writegood_use_global* *b:ale_writegood_use_global* Type: |Number| - Default: `0` + Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| @@ -1713,6 +1807,9 @@ If you prefer to use global executables for those tools, set the relevant 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. @@ -1720,6 +1817,21 @@ ALE will use to search for Python executables. =============================================================================== 8. Commands/Keybinds *ale-commands* +ALEFindReferences *ALEFindReferences* + + Find references in the codebase for the symbol under the cursor using the + enabled LSP linters for the buffer. ALE will display a preview window + containing the results if some references are found. + + The window can be navigated using the usual Vim navigation commands. The + Enter key (``) can be used to jump to a referencing location, or the `t` + key can be used to jump to the location in a new tab. + + You can jump back to the position you were at before going to a reference of + something with jump motions like CTRL-O. See |jump-motions|. + + A plug mapping `(ale_find_references)` is defined for this command. + ALEFix *ALEFix* Fix problems with the current buffer. See |ale-fix| for more information. @@ -1740,6 +1852,9 @@ ALEGoToDefinition *ALEGoToDefinition* linters for the buffer. 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_definition)` is defined for this command. @@ -1750,6 +1865,19 @@ ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* A plug mapping `(ale_go_to_definition_in_tab)` is defined for this command. + +ALEHover *ALEHover* + + Print brief information about the symbol under the cursor, taken from any + available LSP linters. There may be a small non-blocking delay before + information is printed. + + NOTE: In Vim 8, long messages will be shown in a preview window, as Vim 8 + does not support showing a prompt to press enter to continue for long + messages from asynchronous callbacks. + + A plug mapping `(ale_hover)` is defined for this command. + *:ALELint* ALELint *ALELint* @@ -1863,6 +1991,9 @@ ALEInfoToClipboard *ALEInfoToClipboard* The command `:ALEInfoToClipboard` can be used to output ALEInfo directly to your clipboard. This might not work on every machine. + `:ALEInfoToFile` will write the ALE runtime information to a given filename. + The filename works just like |:w|. + ALEReset *ALEReset* ALEResetBuffer *ALEResetBuffer* @@ -2066,6 +2197,13 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* key is also set with a valid number for some other buffer. `vcol` - Defaults to `0`. + + If set to `1`, ALE will convert virtual column + positions for `col` and `end_col` to byte column + positions. If the buffer is changed in-between + checking it and displaying the results, the + calculated byte column positions will probably be + wrong. `type` - Defaults to `'E'`. `nr` - Defaults to `-1`. @@ -2184,14 +2322,21 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* process for a language server runnning, and communicates with it directly via a |channel|. - When this argument is not empty, then the - `project_callback` and `language_callback` arguments - must also be defined. + When this argument is not empty, only one of either + `language` or `language_callback` must be defined, + and `project_root_callback` must be defined. LSP linters handle diagnostics automatically, so the `callback` argument must not be defined. - `project_callback` A |String| or |Funcref| for a callback function + 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. + + `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 @@ -2201,13 +2346,29 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* 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. + + This argument must only be set if the `lsp` argument + is also set to a non-empty string. + `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 argument must only be set if the `lsp` argument - is also set to a non-empty string. + This option can be used instead of `language` if a + linter can check multiple languages. + + `completion_filter` A |String| or |Funcref| for a callback function + accepting a buffer number and a completion item. + + The completion item will be a |Dictionary| following + the Language Server Protocol `CompletionItem` + interface as described in the specification, + available online here: + https://microsoft.github.io/language-server-protocol `aliases` A |List| of aliases for the linter name. @@ -2216,6 +2377,17 @@ 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. + 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. + 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. @@ -2259,6 +2431,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* is not desired, the |ale#engine#EscapeCommandPart()| function can be used to replace those characters to avoid formatting issues. + *ale-linter-loading-behavior* *ale-linter-loading-behaviour* Linters for ALE will be loaded by searching |runtimepath| in the following @@ -2271,6 +2444,21 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* containing `.` characters will be split into individual parts, and files will be loaded for each filetype between the `.` characters. + Linters can be defined from vimrc and other files as long as this function + is loaded first. For example, the following code will define a Hello World + linter in vimrc in Vim 8: > + + " Plugins have to be loaded first. + " If you are using a plugin manager, run that first. + packloadall + + call ale#linter#Define('vim', { + \ 'name': 'echo-test', + \ 'executable': 'echo', + \ 'command': 'echo hello world', + \ 'callback': {buffer, lines -> map(lines, '{"text": v:val, "lnum": 1}')}, + \}) +< ale#linter#Get(filetype) *ale#linter#Get()* @@ -2286,6 +2474,13 @@ ale#linter#Get(filetype) *ale#linter#Get()* components. +ale#linter#PreventLoading(filetype) *ale#linter#PreventLoading()* + + Given a `filetype`, prevent any more linters from being loaded from + |runtimepath| for that filetype. This function can be called from vimrc or + similar to prevent ALE from loading linters. + + ale#statusline#Count(buffer) *ale#statusline#Count()* Given the number of a buffer which may have problems, return a |Dictionary| @@ -2341,7 +2536,15 @@ ALEFixPost *ALEFixPost-autocmd* autocmd User ALELintPre let s:ale_running = 1 | redrawstatus autocmd User ALELintPost let s:ale_running = 0 | redrawstatus augroup end + < +ALEJobStarted *ALEJobStarted-autocmd* + + This |User| autocommand is triggered immediately after a job is successfully + run. This provides better accuracy for checking linter status with + |ale#engine#IsCheckingBuffer()| over |ALELintPre-autocmd|, which is actually + triggered before any linters are executed. + =============================================================================== 10. Special Thanks *ale-special-thanks* diff --git a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim new file mode 100644 index 00000000..d77b4f98 --- /dev/null +++ b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim @@ -0,0 +1,16 @@ +" Close the ALEPreviewWindow window with the q key. +noremap q :q! +" Disable some keybinds for the selection window. +noremap v +noremap i +noremap I +noremap +noremap +noremap +noremap a +noremap A +noremap o +noremap O +" Keybinds for opening selection items. +noremap :call ale#preview#OpenSelectionInBuffer() +noremap t :call ale#preview#OpenSelectionInTab() diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 1aa35826..bea5a49e 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -32,21 +32,12 @@ if !s:has_features finish endif +" remove in 2.0 if has('nvim') && !has('nvim-0.2.0') && !get(g:, 'ale_use_deprecated_neovim') execute 'echom ''ALE support for NeoVim versions below 0.2.0 is deprecated.''' execute 'echom ''Use `let g:ale_use_deprecated_neovim = 1` to silence this warning for now.''' endif -" This flag can be set to 0 to disable emitting conflict warnings. -let g:ale_emit_conflict_warnings = get(g:, 'ale_emit_conflict_warnings', 1) - -if g:ale_emit_conflict_warnings -\&& match(&runtimepath, '[/\\]ale[/\\]after') < 0 - " Add the after directory to the runtimepath - " This is only done if the after directory isn't already in runtimepath - let &runtimepath .= ',' . expand(':p:h:h') . '/after' -endif - " Set this flag so that other plugins can use it, like airline. let g:loaded_ale = 1 @@ -73,9 +64,9 @@ let g:ale_filetype_blacklist = [ \] " This Dictionary configures which linters are enabled for which languages. -call ale#Set('linters', {}) +let g:ale_linters = get(g:, 'ale_linters', {}) " This option can be changed to only enable explicitly selected linters. -call ale#Set('linters_explicit', 0) +let g:ale_linters_explicit = get(g:, 'ale_linters_explicit', 0) " This Dictionary configures which functions will be used for fixing problems. let g:ale_fixers = get(g:, 'ale_fixers', {}) @@ -106,7 +97,8 @@ 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) -call ale#Set('fix_on_save', 0) +" 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) " This flag may be set to 0 to disable ale. After ale is loaded, :ALEToggle " should be used instead. @@ -117,78 +109,26 @@ let g:ale_enabled = get(g:, 'ale_enabled', 1) let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0) -" This flag dictates if ale open the configured loclist -let g:ale_open_list = get(g:, 'ale_open_list', 0) - -" This flag dictates if ale keeps open loclist even if there is no error in loclist -let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0) - -" This flag dictates that quickfix windows should be opened vertically -let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0) - -" The window size to set for the quickfix and loclist windows -call ale#Set('list_window_size', 10) - " This flag can be set to 0 to disable setting signs. " This is enabled by default only if the 'signs' feature exists. let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) -" This flag can be set to some integer to control the maximum number of signs -" that ALE will set. -let g:ale_max_signs = get(g:, 'ale_max_signs', -1) - -" This flag can be set to 1 to enable changing the sign column colors when -" there are errors. -call ale#Set('change_sign_column_color', 0) " This flag can be set to 0 to disable setting error highlights. let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) -" These variables dictate what sign is used to indicate errors and warnings. -call ale#Set('sign_error', '>>') -call ale#Set('sign_style_error', g:ale_sign_error) -call ale#Set('sign_warning', '--') -call ale#Set('sign_style_warning', g:ale_sign_warning) -call ale#Set('sign_info', g:ale_sign_warning) - -" This variable sets an offset which can be set for sign IDs. -" This ID can be changed depending on what IDs are set for other plugins. -" The dummy sign will use the ID exactly equal to the offset. -let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) - -" This flag can be set to 1 to keep sign gutter always open -let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) - -" A string format for the echoed message -call ale#Set('echo_msg_format', '%code: %%s') -" The same for the loclist. -call ale#Set('loclist_msg_format', g:ale_echo_msg_format) - -" Strings used for severity in the echoed message -let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') -let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info') -let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') - " This flag can be set to 0 to disable echoing when the cursor moves. let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) -" Controls the milliseconds delay before echoing a message. -let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10) " This flag can be set to 0 to disable balloon support. -call ale#Set('set_balloons', has('balloon_eval')) - -" A deprecated setting for ale#statusline#Status() -" See :help ale#statusline#Count() for getting status reports. -let g:ale_statusline_format = get(g:, 'ale_statusline_format', -\ ['%d error(s)', '%d warning(s)', 'OK'] +let g:ale_set_balloons = get(g:, 'ale_set_balloons', +\ (has('balloon_eval') && has('gui_running')) +\ || (has('balloon_eval_term') && !has('gui_running')) \) " This flag can be set to 0 to disable warnings for trailing whitespace -call ale#Set('warn_about_trailing_whitespace', 1) +let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1) " This flag can be set to 0 to disable warnings for trailing blank lines -call ale#Set('warn_about_trailing_blank_lines', 1) - -" A flag for controlling the maximum size of the command history to store. -let g:ale_max_buffer_history_size = get(g:, 'ale_max_buffer_history_size', 20) +let g:ale_warn_about_trailing_blank_lines = get(g:, 'ale_warn_about_trailing_blank_lines', 1) " A flag for enabling or disabling the command history. let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1) @@ -196,29 +136,8 @@ let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1) " A flag for storing the full output of commands in the history. let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1) -" A flag for caching failed executable checks. -" This is off by default, because it will cause problems. -call ale#Set('cache_executable_check_failures', 0) - -" A dictionary mapping regular expression patterns to arbitrary buffer -" variables to be set. Useful for configuration ALE based on filename -" patterns. -call ale#Set('pattern_options', {}) -call ale#Set('pattern_options_enabled', !empty(g:ale_pattern_options)) - -" A maximum file size for checking for errors. -call ale#Set('maximum_file_size', 0) - -" Remapping of linter problems. -call ale#Set('type_map', {}) - " Enable automatic completion with LSP servers and tsserver -call ale#Set('completion_enabled', 0) -call ale#Set('completion_delay', 100) -call ale#Set('completion_max_suggestions', 50) - -" A setting for wrapping commands. -call ale#Set('command_wrapper', '') +let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) if g:ale_set_balloons call ale#balloon#Enable() @@ -259,9 +178,11 @@ command! -bar ALELint :call ale#Queue(0, 'lint_file') command! -bar ALEInfo :call ale#debugging#Info() " The same, but copy output to your clipboard. command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard() +" Copy ALE information to a file. +command! -bar -nargs=1 ALEInfoToFile :call ale#debugging#InfoToFile() " Fix problems in files. -command! -bar ALEFix :call ale#fix#Fix() +command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) " Suggest registered functions to use for fixing problems. command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) @@ -269,6 +190,13 @@ command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in_tab': 1}) +" Find references for tsserver and LSP +command! -bar ALEFindReferences :call ale#references#Find() + +" Get information for the cursor. +command! -bar ALEHover :call ale#hover#Show(bufnr(''), getcurpos()[1], + \ getcurpos()[2], {}) + " mappings for commands nnoremap (ale_previous) :ALEPrevious nnoremap (ale_previous_wrap) :ALEPreviousWrap @@ -289,9 +217,11 @@ nnoremap (ale_detail) :ALEDetail nnoremap (ale_fix) :ALEFix nnoremap (ale_go_to_definition) :ALEGoToDefinition nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab +nnoremap (ale_find_references) :ALEFindReferences +nnoremap (ale_hover) :ALEHover " Set up autocmd groups now. -call ale#toggle#InitAuGroups() +call ale#autocmd#InitAuGroups() " Housekeeping @@ -304,6 +234,7 @@ augroup END " Backwards Compatibility +" remove in 2.0 function! ALELint(delay) abort if !get(g:, 'ale_deprecation_ale_lint', 0) execute 'echom ''ALELint() is deprecated, use ale#Queue() instead.''' @@ -313,6 +244,7 @@ function! ALELint(delay) abort call ale#Queue(a:delay) endfunction +" remove in 2.0 function! ALEGetStatusLine() abort if !get(g:, 'ale_deprecation_ale_get_status_line', 0) execute 'echom ''ALEGetStatusLine() is deprecated.''' diff --git a/sources_non_forked/ale/syntax/ale-preview-selection.vim b/sources_non_forked/ale/syntax/ale-preview-selection.vim new file mode 100644 index 00000000..879ba096 --- /dev/null +++ b/sources_non_forked/ale/syntax/ale-preview-selection.vim @@ -0,0 +1,11 @@ +if exists('b:current_syntax') + finish +endif + +syn match alePreviewSelectionFilename /\v^([a-zA-Z]?:?[^:]+)/ +syn match alPreviewNumber /\v:\d+:\d+$/ + +hi def link alePreviewSelectionFilename String +hi def link alePreviewNumber Number + +let b:current_syntax = 'ale-preview-selection' diff --git a/sources_non_forked/auto-pairs/.gitignore b/sources_non_forked/auto-pairs/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/auto-pairs/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/auto-pairs/README.md b/sources_non_forked/auto-pairs/README.md new file mode 100644 index 00000000..7cdcbf92 --- /dev/null +++ b/sources_non_forked/auto-pairs/README.md @@ -0,0 +1,325 @@ +Auto Pairs +========== +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``` + +Features +-------- +* Insert in pair + + input: [ + output: [|] + +* Delete in pair + + input: foo[] + output: foo + +* Insert new indented line after Return + + input: {|} (press at |) + output: { + | + } + +* Insert spaces before closing characters, only for [], (), {} + + input: {|} (press at |) + output: { | } + + input: {|} (press foo} at |) + output: { foo }| + + input: '|' (press at |) + output: ' |' + +* Skip ' when inside a word + + input: foo| (press ' at |) + output: foo' + +* Skip closed bracket. + + input: [] + output: [] + +* Ignore auto pair when previous character is \ + + input: "\' + output: "\'" + +* 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()]) + +* Quick move char to closed pair + + input: (|){["foo"]} (press at |) + output: ({["foo"]}|) + + input: |[foo, bar()] (press ( at |) + output: ([foo, bar()]|) + +* Quick jump to closed pair. + + input: + { + something;| + } + + (press } at |) + + output: + { + + }| + +* 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) + output: if(a[3])| (In Fly Mode) + output: if(a[3)]) (Without Fly Mode) + + input: + { + hello();| + world(); + } + + (press } at |) + + output: + { + hello(); + world(); + }| + + (then press at | to do backinsert) + output: + { + hello();}| + world(); + } + + See Fly Mode section for details + +Fly Mode +-------- +Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]" + +If jumps in mistake, could use AutoPairsBackInsert(Default Key: ``) to jump back and insert closed pair. + +the most situation maybe want to insert single closed pair in the string, eg ")" + +Fly Mode is DISABLED by default. + +add **let g:AutoPairsFlyMode = 1** .vimrc to turn it on + +Default Options: + + let g:AutoPairsFlyMode = 0 + let g:AutoPairsShortcutBackInsert = '' + +Shortcuts +--------- + + System Shortcuts: + : Insert new indented line after return if cursor in blank brackets or quotes. + : Delete brackets in pair + : Toggle Autopairs (g:AutoPairsShortcutToggle) + : Fast Wrap (g:AutoPairsShortcutFastWrap) + : Jump to next closed pair (g:AutoPairsShortcutJump) + : BackInsert (g:AutoPairsShortcutBackInsert) + + If or conflict with another keys or want to bind to another keys, add + + let g:AutoPairsShortcutToggle = '' + + to .vimrc, if the key is empty string '', then the shortcut will be disabled. + +Options +------- +* g:AutoPairs + + Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + +* b:AutoPairs + + Default: g:AutoPairs + + Buffer level pairs set. + +* g:AutoPairsShortcutToggle + + Default: '' + + The shortcut to toggle autopairs. + +* g:AutoPairsShortcutFastWrap + + Default: '' + + Fast wrap the word. all pairs will be consider as a block (include <>). + (|)'hello' after fast wrap at |, the word will be ('hello') + (|) after fast wrap at |, the word will be () + +* g:AutoPairsShortcutJump + + Default: '' + + Jump to the next closed pair + +* g:AutoPairsMapBS + + Default : 1 + + Map to delete brackets, quotes in pair + execute 'inoremap =AutoPairsDelete()' + +* g:AutoPairsMapCh + + Default : 1 + + Map to delete brackets, quotes in pair + +* g:AutoPairsMapCR + + Default : 1 + + Map to insert a new indented line if cursor in (|), {|} [|], '|', "|" + execute 'inoremap =AutoPairsReturn()' + +* g:AutoPairsCenterLine + + Default : 1 + + When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window. + +* g:AutoPairsMapSpace + + Default : 1 + + Map to insert a space after the opening character and before the closing one. + execute 'inoremap =AutoPairsSpace()' + +* g:AutoPairsFlyMode + + Default : 0 + + set it to 1 to enable FlyMode. + see FlyMode section for details. + +* g:AutoPairsMultilineClose + + Default : 1 + + When you press the key for the closing pair (e.g. `)`) it jumps past it. + If set to 1, then it'll jump to the next line, if there is only whitespace. + If set to 0, then it'll only jump to a closing pair on the same line. + +* g:AutoPairsShortcutBackInsert + + Default : + + Work with FlyMode, insert the key at the Fly Mode jumped postion + +* g:AutoPairsMoveCharacter + + Default: "()[]{}\"'" + + Map to + move character under the cursor to the pair. + +Buffer Level Pairs Setting +-------------------------- + +Set b:AutoPairs before BufEnter + +eg: + + " When the filetype is FILETYPE then make AutoPairs only match for parenthesis + au Filetype FILETYPE let b:AutoPairs = {"(": ")"} + +TroubleShooting +--------------- + The script will remap keys ([{'"}]) , + If auto pairs cannot work, use :imap ( to check if the map is corrected. + The correct map should be =AutoPairsInsert("\(") + Or the plugin conflict with some other plugins. + use command :call AutoPairsInit() to remap the keys. + + +* How to insert parens purely + + There are 3 ways + + 1. use Ctrl-V ) to insert paren without trigger the plugin. + + 2. use Alt-P to turn off the plugin. + + 3. use DEL or x to delete the character insert by plugin. + +* Swedish Character Conflict + + Because AutoPairs uses Meta(Alt) key as shortcut, it is conflict with some Swedish character such as å. + 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 + mode by ``. press '.' will insert 'hello' instead of '[hello]'. + Reason: `[` actually equals `[]\` and \ will break '.'. + After version 7.4.849, Vim implements new keyword U to avoid the break + Solution: Update Vim to 7.4.849+ + +Contributors +------------ +* [camthompson](https://github.com/camthompson) + + +License +------- + +Copyright (C) 2011-2013 Miao Jiang + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sources_non_forked/auto-pairs/doc/AutoPairs.txt b/sources_non_forked/auto-pairs/doc/AutoPairs.txt new file mode 100644 index 00000000..49ff5494 --- /dev/null +++ b/sources_non_forked/auto-pairs/doc/AutoPairs.txt @@ -0,0 +1,356 @@ +*AutoPairs.txt* Insert or delete brackets, parens, quotes in pair + +Author: jiangmiao +License: MIT +URL: https://github.com/jiangmiao/auto-pairs + +============================================================================== +CONTENTS *autopairs-contents* + + 1. Installation ............................. |autopairs-installation| + 2. Features ..................................... |autopairs-features| + 3. Fly Mode ..................................... |autopairs-fly-mode| + 4. Shortcuts ................................... |autopairs-shortcuts| + 5. Options ....................................... |autopairs-options| + 6. Troubleshooting ...................... |autopairs-troubleshooting| + +============================================================================== +1. Introduction *autopairs-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 + +============================================================================== +2. Features *autopairs-features* + +Insert in pair: > + + input: [ + output: [|] + +Delete in pair: > + + input: foo[] + output: foo + +Insert new indented line after Return: > + + input: {|} (press at |) + output: { + | + } + +Insert spaces before closing characters, only for [], (), {}: > + + input: {|} (press at |) + output: { | } + + input: {|} (press foo} at |) + output: { foo }| + + input: '|' (press at |) + output: ' |' + +Skip ' when inside a word: > + + input: foo| (press ' at |) + output: foo' + +Skip closed bracket: > + + input: [] + output: [] + +Ignore auto pair when previous character is '\': > + + input: "\' + output: "\'" + +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()]) + +Quick jump to closed pair: > + + input: + { + something;| + } + + (press } at |) + + output: + { + + }| + +Support ```, ''' and """: > + + input: + ''' + + output: + '''|''' + +Delete Repeated Pairs in one time: > + + input: """|""" (press at |) + output: | + + input: {{|}} (press at |) + output: | + + input: [[[[[[|]]]]]] (press at |) + output: | + +Fly Mode (|autopairs-flymode|): > + + input: if(a[3) + output: if(a[3])| (In Fly Mode) + output: if(a[3)]) (Without Fly Mode) + + input: + { + hello();| + world(); + } + + (press } at |) + + output: + { + hello(); + world(); + }| + + (then press at | to do backinsert) + output: + { + hello();}| + world(); + } + + See |Fly Mode| section for details + +============================================================================== +3. Fly Mode *autopairs-flymode* + +Fly Mode will always force closed-pair jumping instead of inserting. Only for +")", "}", "]". If jumps in mistake, you can use |g:AutoPairsBackInsert| (default +Key: ) to jump back and insert closed pair. + +The most situation maybe you want to insert single closed pair in the string, +eg: > + + ")" + +Fly Mode is DISABLED by default. To enable Fly Mode add following to your +'.vimrc': > + + let g:AutoPairsFlyMode = 1 + +Default Options: > + + let g:AutoPairsFlyMode = 0 + let g:AutoPairsShortcutBackInsert = '' + +============================================================================== +4. Shortcuts *autopairs-shortcuts* + +System Shortcuts: + : Insert new indented line after return if cursor in blank brackets + or quotes. + : Delete brackets in pair + : Toggle Autopairs (|g:AutoPairsShortcutToggle|) + : Fast Wrap (|g:AutoPairsShortcutFastWrap|) + : Jump to next closed pair (|g:AutoPairsShortcutJump|) + : BackInsert (|g:AutoPairsShortcutBackInsert|) + + + To rebind keys , or or in case of conflicts conflicts with + another keys: + + let g:AutoPairsShortcutToggle = '' + + If the key is empty string '', then the shortcut will be disabled. + +============================================================================== +5. Options *autopairs-options* + + *g:AutoPairs* +|g:AutoPairs| dict + +Default: > + {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + +Specifies which symbols should be automatically paired. + +To append new pairs without overwriting defaults, add values in your `.vimrc`.: + + let g:AutoPairs['<']='>' + +This example will enable matching of `<` with `>`. + + + *b:AutoPairs* +|b:AutoPairs| dict + +Default: |g:AutoPairs| + +Buffer level pairs set. + +You can set |b:AutoPairs| before |BufEnter|: > + + au Filetype FILETYPE let b:AutoPairs = {"(": ")"} + +This sets |AutoPairs| to only match for parenthesis for 'FILETYPE'. + + + + *g:AutoPairsShortcutToggle* +|g:AutoPairsShortcutToggle| string + +Default: + +The shortcut to toggle autopairs. + + + + *g:AutoPairsShortcutFastWrap* +|g:AutoPairsShortcutFastWrap| string + +Default: + +Fast wrap the word. All pairs will be considered as a block (including <>). + + (|)'hello' after fast wrap at |, the word will be ('hello') + (|) after fast wrap at |, the word will be () + + + + *g:AutoPairsShortcutJump* +|g:AutoPairsShortcutJump| string + +Default: + +Jump to the next closed pair. + + + *g:AutoPairsShortcutBackInsert* +|g:AutoPairsShortcutBackInsert| string + +Default: + +Work with |autopairs-flymode|, insert the key at the Fly Mode jumped position. + + + + *g:AutoPairsMapBS* +|g:AutoPairsMapBS| int + +Default: 1 + +Map to delete brackets and quotes in pair, executes: + + inoremap =AutoPairsDelete() + + + *g:AutoPairsMapCh* +|g:AutoPairsMapCh| int + +Default: 1 + +Map to delete brackets and quotes in pair. + + + *g:AutoPairsMapCR* +|g:AutoPairsMapCR| int + +Default: 1 + +Map to insert a new indented line if cursor in (|), {|} [|], '|', "|". +Executes: + + inoremap =AutoPairsReturn() + + + *g:AutoPairsCenterLine* +|g:AutoPairsCenterLine| int + +Default: 1 + +When |g:AutoPairsMapCR| is on, center current line after return if the line +is at the bottom 1/3 of the window. + + + *g:AutoPairsMapSpace* +|g:AutoPairsMapSpace| int + +Default: 1 + +Map to insert a space after the opening character and before the +closing one. + +Executes: + + inoremap =AutoPairsSpace() + + + *g:AutoPairsFlyMode* +|g:AutoPairsFlyMode| int + +Default: 0 + +Set it to 1 to enable |autopairs-flymode|. + + + *g:AutoPairsMultilineClose* +|g:AutoPairsMultilineClose| int + +Default: 1 + +When you press the key for the closing pair (e.g. `)`) it jumps past it. +If set to 1, then it'll jump to the next line, if there is only 'whitespace'. +If set to 0, then it'll only jump to a closing pair on the same line. + +============================================================================== +6. Troubleshooting *autopairs-troubleshooting* + +This plugin remaps keys `([{'"}]) ` + +If auto pairs cannot work, use |:imap| to check if the map is corrected. + +The correct map should be: > + + =AutoPairsInsert("\(") + +Or the plugin conflicts with some other plugins. Use command: > + + :call AutoPairsInit() to remap the keys. + +--- How to insert parens purely? --- + +There are 3 ways: + + 1. Use Ctrl-V ) to insert paren without trigger the plugin. + + 2. Use Alt-P to turn off the plugin. + + 3. Use DEL or x to delete the character insert by plugin. + +--- Swedish Character Conflict --- + +Because AutoPairs uses Meta(Alt) key as a shortcut, it conflicts with some +Swedish character such as å. To fix the issue, you need remap or disable the +related shortcut. diff --git a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim new file mode 100644 index 00000000..b2a9af7d --- /dev/null +++ b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim @@ -0,0 +1,582 @@ +" Insert or delete brackets, parens, quotes in pairs. +" Maintainer: JiangMiao +" Contributor: camthompson +" Last Change: 2017-06-17 +" Version: 1.3.3 +" Homepage: http://www.vim.org/scripts/script.php?script_id=3599 +" Repository: https://github.com/jiangmiao/auto-pairs +" License: MIT + +if exists('g:AutoPairsLoaded') || &cp + finish +end +let g:AutoPairsLoaded = 1 + +if !exists('g:AutoPairs') + let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} +end + +if !exists('g:AutoPairsParens') + let g:AutoPairsParens = {'(':')', '[':']', '{':'}'} +end + +if !exists('g:AutoPairsMapBS') + let g:AutoPairsMapBS = 1 +end + +" Map as the same BS +if !exists('g:AutoPairsMapCh') + let g:AutoPairsMapCh = 1 +end + +if !exists('g:AutoPairsMapCR') + let g:AutoPairsMapCR = 1 +end + +if !exists('g:AutoPairsMapSpace') + let g:AutoPairsMapSpace = 1 +end + +if !exists('g:AutoPairsCenterLine') + let g:AutoPairsCenterLine = 1 +end + +if !exists('g:AutoPairsShortcutToggle') + let g:AutoPairsShortcutToggle = '' +end + +if !exists('g:AutoPairsShortcutFastWrap') + let g:AutoPairsShortcutFastWrap = '' +end + +if !exists('g:AutoPairsMoveCharacter') + let g:AutoPairsMoveCharacter = "()[]{}\"'" +end + +if !exists('g:AutoPairsShortcutJump') + let g:AutoPairsShortcutJump = '' +endif + +" Fly mode will for closed pair to jump to closed pair instead of insert. +" also support AutoPairsBackInsert to insert pairs where jumped. +if !exists('g:AutoPairsFlyMode') + let g:AutoPairsFlyMode = 0 +endif + +" When skipping the closed pair, look at the current and +" next line as well. +if !exists('g:AutoPairsMultilineClose') + let g:AutoPairsMultilineClose = 1 +endif + +" Work with Fly Mode, insert pair where jumped +if !exists('g:AutoPairsShortcutBackInsert') + let g:AutoPairsShortcutBackInsert = '' +endif + +if !exists('g:AutoPairsSmartQuotes') + let g:AutoPairsSmartQuotes = 1 +endif + +" 7.4.849 support U to avoid breaking '.' +" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3 +" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849 +if v:version > 704 || v:version == 704 && has("patch849") + let s:Go = "\U" +else + let s:Go = "" +endif + +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 + + 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 + break + end + let n = n + 1 + let pos = pos + 1 + endwhile + if n % 2 == 1 + return a:key + endif + endif + + return open.close.s:Left +endfunction + +function! AutoPairsDelete() + if !b:autopairs_enabled + return "\" + end + + let line = getline('.') + let pos = col('.') - 1 + let current_char = get(split(strpart(line, pos), '\zs'), 0, '') + let prev_chars = split(strpart(line, 0, pos), '\zs') + let prev_char = get(prev_chars, -1, '') + let pprev_char = get(prev_chars, -2, '') + + if pprev_char == '\' + return "\" + end + + " Delete last two spaces in parens, work with MapSpace + if has_key(b:AutoPairs, pprev_char) && prev_char == ' ' && current_char == ' ' + return "\\" + endif + + " Delete Repeated Pair eg: '''|''' [[|]] {{|}} + if has_key(b:AutoPairs, prev_char) + let times = 0 + let p = -1 + while get(prev_chars, p, '') == prev_char + let p = p - 1 + let times = times + 1 + endwhile + + let close = b:AutoPairs[prev_char] + let left = repeat(prev_char, times) + let right = repeat(close, times) + + let before = strpart(line, pos-times, times) + let after = strpart(line, pos, times) + if left == before && right == after + return repeat("\\", times) + end + end + + + if has_key(b:AutoPairs, prev_char) + let close = b:AutoPairs[prev_char] + if match(line,'^\s*'.close, col('.')-1) != -1 + " Delete (|___) + let space = matchstr(line, '^\s*', col('.')-1) + return "\". repeat("\", len(space)+1) + elseif match(line, '^\s*$', col('.')-1) != -1 + " Delete (|__\n___) + let nline = getline(line('.')+1) + if nline =~ '^\s*'.close + if &filetype == 'vim' && prev_char == '"' + " Keep next line's comment + return "\" + end + + let space = matchstr(nline, '^\s*') + return "\\". repeat("\", len(space)+1) + end + end + end + + return "\" +endfunction + +function! AutoPairsJump() + call search('["\]'')}]','W') +endfunction +" string_chunk cannot use standalone +let s:string_chunk = '\v%(\\\_.|[^\1]|[\r\n]){-}' +let s:ss_pattern = '\v''' . s:string_chunk . '''' +let s:ds_pattern = '\v"' . s:string_chunk . '"' + +func! s:RegexpQuote(str) + return substitute(a:str, '\v[\[\{\(\<\>\)\}\]]', '\\&', 'g') +endf + +func! s:RegexpQuoteInSquare(str) + return substitute(a:str, '\v[\[\]]', '\\&', 'g') +endf + +" Search next open or close pair +func! s:FormatChunk(open, close) + let open = s:RegexpQuote(a:open) + let close = s:RegexpQuote(a:close) + let open2 = s:RegexpQuoteInSquare(a:open) + let close2 = s:RegexpQuoteInSquare(a:close) + if open == close + return '\v'.open.s:string_chunk.close + else + return '\v%(' . s:ss_pattern . '|' . s:ds_pattern . '|' . '[^'.open2.close2.']|[\r\n]' . '){-}(['.open2.close2.'])' + end +endf + +" Fast wrap the word in brackets +function! AutoPairsFastWrap() + let line = getline('.') + let current_char = line[col('.')-1] + let next_char = line[col('.')] + let open_pair_pattern = '\v[({\[''"]' + let at_end = col('.') >= col('$') - 1 + normal! x + " Skip blank + if next_char =~ '\v\s' || at_end + call search('\v\S', 'W') + let line = getline('.') + let next_char = line[col('.')-1] + end + + if has_key(b:AutoPairs, next_char) + let followed_open_pair = next_char + let inputed_close_pair = current_char + let followed_close_pair = b:AutoPairs[next_char] + if followed_close_pair != followed_open_pair + " TODO replace system searchpair to skip string and nested pair. + " eg: (|){"hello}world"} will transform to ({"hello})world"} + call searchpair('\V'.followed_open_pair, '', '\V'.followed_close_pair, 'W') + else + call search(s:FormatChunk(followed_open_pair, followed_close_pair), 'We') + end + return s:Right.inputed_close_pair.s:Left + else + normal! he + return s:Right.current_char.s:Left + end +endfunction + +function! AutoPairsMap(key) + " | is special key which separate map command from text + let key = a:key + if key == '|' + let key = '' + end + let escaped_key = substitute(key, "'", "''", 'g') + " use expr will cause search() doesn't work + execute 'inoremap '.key." =AutoPairsInsert('".escaped_key."')" + +endfunction + +function! AutoPairsToggle() + if b:autopairs_enabled + let b:autopairs_enabled = 0 + echo 'AutoPairs Disabled.' + else + let b:autopairs_enabled = 1 + echo 'AutoPairs Enabled.' + end + return '' +endfunction + +function! AutoPairsMoveCharacter(key) + let c = getline(".")[col(".")-1] + let escaped_key = substitute(a:key, "'", "''", 'g') + return "\\:call search("."'".escaped_key."'".")\a".c."\" +endfunction + +function! AutoPairsReturn() + if b:autopairs_enabled == 0 + return '' + end + let line = getline('.') + let pline = getline(line('.')-1) + let prev_char = pline[strlen(pline)-1] + let cmd = '' + let cur_char = line[col('.')-1] + if has_key(b:AutoPairs, prev_char) && b:AutoPairs[prev_char] == cur_char + if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2 + " Recenter before adding new line to avoid replacing line content + let cmd = "zz" + end + + " If equalprg has been set, then avoid call = + " https://github.com/jiangmiao/auto-pairs/issues/24 + if &equalprg != '' + return "\".cmd."O" + endif + + " conflict with javascript and coffee + " javascript need indent new line + " coffeescript forbid indent new line + if &filetype == 'coffeescript' || &filetype == 'coffee' + return "\".cmd."k==o" + else + return "\".cmd."=ko" + endif + end + return '' +endfunction + +function! AutoPairsSpace() + let line = getline('.') + let prev_char = line[col('.')-2] + let cmd = '' + let cur_char =line[col('.')-1] + if has_key(g:AutoPairsParens, prev_char) && g:AutoPairsParens[prev_char] == cur_char + let cmd = "\".s:Left + endif + return "\".cmd +endfunction + +function! AutoPairsBackInsert() + if exists('b:autopairs_saved_pair') + let pair = b:autopairs_saved_pair[0] + let pos = b:autopairs_saved_pair[1] + call setpos('.', pos) + return pair + endif + return '' +endfunction + +function! AutoPairsInit() + let b:autopairs_loaded = 1 + if !exists('b:autopairs_enabled') + let b:autopairs_enabled = 1 + end + let b:AutoPairsClosedPairs = {} + + if !exists('b:AutoPairs') + let b:AutoPairs = g:AutoPairs + end + + if !exists('b:AutoPairsMoveCharacter') + let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter + end + + " buffer level map pairs keys + for [open, close] in items(b:AutoPairs) + call AutoPairsMap(open) + if open != close + call AutoPairsMap(close) + end + let b:AutoPairsClosedPairs[close] = open + endfor + + for key in split(b:AutoPairsMoveCharacter, '\s*') + let escaped_key = substitute(key, "'", "''", 'g') + execute 'inoremap =AutoPairsMoveCharacter('".escaped_key."')" + endfor + + " Still use level mapping for + if g:AutoPairsMapBS + " Use instead of for issue #14 sometimes press BS output strange words + execute 'inoremap =AutoPairsDelete()' + end + + if g:AutoPairsMapCh + execute 'inoremap =AutoPairsDelete()' + endif + + if g:AutoPairsMapSpace + " Try to respect abbreviations on a + let do_abbrev = "" + if v:version == 703 && has("patch489") || v:version > 703 + let do_abbrev = "" + endif + execute 'inoremap '.do_abbrev.'=AutoPairsSpace()' + end + + if g:AutoPairsShortcutFastWrap != '' + execute 'inoremap '.g:AutoPairsShortcutFastWrap.' =AutoPairsFastWrap()' + end + + if g:AutoPairsShortcutBackInsert != '' + execute 'inoremap '.g:AutoPairsShortcutBackInsert.' =AutoPairsBackInsert()' + end + + if g:AutoPairsShortcutToggle != '' + " use to ensure showing the status when toggle + execute 'inoremap '.g:AutoPairsShortcutToggle.' AutoPairsToggle()' + execute 'noremap '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()' + end + + if g:AutoPairsShortcutJump != '' + execute 'inoremap ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()a' + execute 'noremap ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()' + end + +endfunction + +function! s:ExpandMap(map) + let map = a:map + let map = substitute(map, '\(\w\+\)', '\=maparg(submatch(1), "i")', 'g') + return map +endfunction + +function! AutoPairsTryInit() + if exists('b:autopairs_loaded') + return + end + + " for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise + " + " vim-endwise doesn't support AutoPairsReturn + " when use AutoPairsReturn will cause isn't expanded + " + " supertab doesn't support AutoPairsReturn + " when use AutoPairsReturn will cause Duplicated + " + " and when load after vim-endwise will cause unexpected endwise inserted. + " so always load AutoPairs at last + + " Buffer level keys mapping + " comptible with other plugin + if g:AutoPairsMapCR + if v:version == 703 && has('patch32') || v:version > 703 + " VIM 7.3 supports advancer maparg which could get info + " then auto-pairs could remap in any case. + let info = maparg('', 'i', 0, 1) + if empty(info) + let old_cr = '' + let is_expr = 0 + else + let old_cr = info['rhs'] + let old_cr = s:ExpandMap(old_cr) + let old_cr = substitute(old_cr, '', '' . info['sid'] . '_', 'g') + let is_expr = info['expr'] + let wrapper_name = 'AutoPairsOldCRWrapper73' + endif + else + " VIM version less than 7.3 + " the mapping's info is lost, so guess it is expr or not, it's + " not accurate. + let old_cr = maparg('', 'i') + if old_cr == '' + let old_cr = '' + let is_expr = 0 + else + let old_cr = s:ExpandMap(old_cr) + " old_cr contain (, I guess the old cr is in expr mode + let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V' + + " The old_cr start with " it must be in expr mode + let is_expr = is_expr || old_cr =~ '\v^"' + let wrapper_name = 'AutoPairsOldCRWrapper' + end + end + + if old_cr !~ 'AutoPairsReturn' + if is_expr + " remap to `name` to avoid mix expr and non-expr mode + execute 'inoremap