diff options
83 files changed, 1564 insertions, 168 deletions
@@ -35,6 +35,10 @@ If you don't care about Language Server Protocol, ALE won't load any of the code for working with it unless needed. One of ALE's general missions is that you won't pay for the features that you don't use. +**Help Wanted:** If you would like to help maintain this plugin by managing the +many issues and pull requests that are submitted, please send the author an +email at [dev@w0rp.com](mailto:dev@w0rp.com?subject=Helping%20with%20ALE). + If you enjoy this plugin, feel free to contribute or check out the author's other content at [w0rp.com](https://w0rp.com). diff --git a/ale_linters/c/clangd.vim b/ale_linters/c/clangd.vim index 79b600fa..c42d4497 100644 --- a/ale_linters/c/clangd.vim +++ b/ale_linters/c/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('c_clangd_executable', 'clangd') call ale#Set('c_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#c#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('c', { diff --git a/ale_linters/c/clangtidy.vim b/ale_linters/c/clangtidy.vim index f998866a..553cc23b 100644 --- a/ale_linters/c/clangtidy.vim +++ b/ale_linters/c/clangtidy.vim @@ -19,14 +19,17 @@ call ale#Set('c_clangtidy_options', '') call ale#Set('c_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#c#clangtidy#GetCommand(buffer) abort +function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'c_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'c_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options') @@ -43,7 +46,7 @@ call ale#linter#Define('c', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, -\ 'command': function('ale_linters#c#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/ale_linters/cpp/clangcheck.vim b/ale_linters/cpp/clangcheck.vim index 7d32a57c..4cb04864 100644 --- a/ale_linters/cpp/clangcheck.vim +++ b/ale_linters/cpp/clangcheck.vim @@ -20,7 +20,7 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort " being generated. These are only added if no build directory can be " detected. return '%e -analyze %s' - \ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '') + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') \ . ale#Pad(l:user_options) \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') endfunction diff --git a/ale_linters/cpp/clangd.vim b/ale_linters/cpp/clangd.vim index fab605f4..14f3fe55 100644 --- a/ale_linters/cpp/clangd.vim +++ b/ale_linters/cpp/clangd.vim @@ -3,9 +3,14 @@ call ale#Set('cpp_clangd_executable', 'clangd') call ale#Set('cpp_clangd_options', '') +call ale#Set('c_build_dir', '') function! ale_linters#cpp#clangd#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') endfunction call ale#linter#Define('cpp', { diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim index 085bc332..191b7b07 100644 --- a/ale_linters/cpp/clangtidy.vim +++ b/ale_linters/cpp/clangtidy.vim @@ -13,14 +13,17 @@ call ale#Set('cpp_clangtidy_options', '') call ale#Set('cpp_clangtidy_extra_options', '') call ale#Set('c_build_dir', '') -function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort +function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' " Get the extra options if we couldn't find a build directory. - let l:options = empty(l:build_dir) - \ ? ale#Var(a:buffer, 'cpp_clangtidy_options') - \ : '' + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') @@ -37,7 +40,7 @@ call ale#linter#Define('cpp', { \ 'name': 'clangtidy', \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, -\ 'command': function('ale_linters#cpp#clangtidy#GetCommand'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'lint_file': 1, \}) diff --git a/ale_linters/crystal/crystal.vim b/ale_linters/crystal/crystal.vim index 3c2fefb7..8a905b12 100644 --- a/ale_linters/crystal/crystal.vim +++ b/ale_linters/crystal/crystal.vim @@ -5,6 +5,10 @@ function! ale_linters#crystal#crystal#Handle(buffer, lines) abort let l:output = [] for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if !has_key(l:error, 'file') + continue + endif + call add(l:output, { \ 'lnum': l:error.line + 0, \ 'col': l:error.column + 0, diff --git a/ale_linters/elm/elm_ls.vim b/ale_linters/elm/elm_ls.vim index 374ef8de..2fa71adb 100644 --- a/ale_linters/elm/elm_ls.vim +++ b/ale_linters/elm/elm_ls.vim @@ -3,9 +3,12 @@ call ale#Set('elm_ls_executable', 'elm-language-server') call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1)) -call ale#Set('elm_ls_elm_path', 'elm') -call ale#Set('elm_ls_elm_format_path', 'elm-format') -call ale#Set('elm_ls_elm_test_path', 'elm-test') + +" elm-language-server will search for local and global binaries, if empty +call ale#Set('elm_ls_elm_path', '') +call ale#Set('elm_ls_elm_format_path', '') +call ale#Set('elm_ls_elm_test_path', '') +call ale#Set('elm_ls_elm_analyse_trigger', 'change') function! elm_ls#GetRootDir(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') @@ -15,10 +18,10 @@ endfunction function! elm_ls#GetOptions(buffer) abort return { - \ 'runtime': 'node', \ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), \ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), \ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'), + \ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'), \} endfunction diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index 203a803e..1990adce 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/semistandard/bin/cmd.js', \ 'node_modules/.bin/standard', diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim index b5796dcd..b739ca04 100644 --- a/ale_linters/nim/nimcheck.vim +++ b/ale_linters/nim/nimcheck.vim @@ -1,6 +1,15 @@ " Author: Baabelfish " Description: Typechecking for nim files +let s:end_col_patterns = [ +\ '\v''([^'']+)'' is declared but not used.*', +\ '\videntifier expected, but found ''([^'']+)''', +\ '\vimported and not used: ''([^'']+)''.*', +\ '\vundeclared identifier: ''([^'']+)''', +\ '\v''([^'']+)'' cannot be assigned to', +\ '\vredefinition of ''([^'']+)'';', +\] + function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t') let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)' @@ -43,6 +52,11 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort let l:item.code = l:code_match[2] endif + " Find position end_col. + for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns) + let l:item.end_col = l:item.col + len(l:col_match[1]) - 1 + endfor + call add(l:output, l:item) endfor diff --git a/ale_linters/nim/nimlsp.vim b/ale_linters/nim/nimlsp.vim new file mode 100644 index 00000000..5d041043 --- /dev/null +++ b/ale_linters/nim/nimlsp.vim @@ -0,0 +1,33 @@ +" Author: jeremija <https://github.com/jeremija> +" Description: Support for nimlsp (language server for nim) + +call ale#Set('nim_nimlsp_nim_sources', '') + +function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale_linters#nim#nimlsp#GetCommand(buffer) abort + let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources') + + if !empty(l:nim_sources) + let l:nim_sources = ale#Escape(l:nim_sources) + endif + + return '%e' . ale#Pad(l:nim_sources) +endfunction + +call ale#linter#Define('nim', { +\ 'name': 'nimlsp', +\ 'lsp': 'stdio', +\ 'executable': 'nimlsp', +\ 'command': function('ale_linters#nim#nimlsp#GetCommand'), +\ 'language': 'nim', +\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'), +\}) diff --git a/ale_linters/php/psalm.vim b/ale_linters/php/psalm.vim index 3cdb026a..ab4dbbc9 100644 --- a/ale_linters/php/psalm.vim +++ b/ale_linters/php/psalm.vim @@ -1,7 +1,8 @@ " Author: Matt Brown <https://github.com/muglug> " Description: plugin for Psalm, static analyzer for PHP -call ale#Set('psalm_langserver_executable', 'psalm-language-server') +call ale#Set('psalm_langserver_executable', 'psalm') +call ale#Set('psalm_langserver_options', '') call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#psalm#GetProjectRoot(buffer) abort @@ -10,12 +11,16 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' endfunction +function! ale_linters#php#psalm#GetCommand(buffer) abort + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options')) +endfunction + call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', \ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ -\ 'vendor/bin/psalm-language-server', +\ 'vendor/bin/psalm', \ ])}, -\ 'command': '%e', +\ 'command': function('ale_linters#php#psalm#GetCommand'), \ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), \}) diff --git a/ale_linters/powershell/powershell.vim b/ale_linters/powershell/powershell.vim index a63191fd..5f49f72c 100644 --- a/ale_linters/powershell/powershell.vim +++ b/ale_linters/powershell/powershell.vim @@ -12,6 +12,7 @@ endfunction " https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/ function! ale_linters#powershell#powershell#GetCommand(buffer) abort let l:script = ['Param($Script); + \ $ErrorView = "Normal"; \ trap {$_;continue} & { \ $Contents = Get-Content -Path $Script; \ $Contents = [string]::Join([Environment]::NewLine, $Contents); diff --git a/ale_linters/ruby/debride.vim b/ale_linters/ruby/debride.vim new file mode 100644 index 00000000..3b2cc443 --- /dev/null +++ b/ale_linters/ruby/debride.vim @@ -0,0 +1,42 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: debride, a dead method detector for Ruby files + +call ale#Set('ruby_debride_executable', 'debride') +call ale#Set('ruby_debride_options', '') + +function! ale_linters#ruby#debride#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_debride_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'debride') + \ . ale#Var(a:buffer, 'ruby_debride_options') + \ . ' %s' +endfunction + +function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + if l:line !~# '^ ' + continue + endif + + let l:elements = split(l:line) + let l:method_name = l:elements[0] + let l:lnum = split(l:elements[1], ':')[1] + + call add(l:output, { + \ 'lnum': 0 + l:lnum, + \ 'text': 'Possible unused method: ' . l:method_name, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'debride', +\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')}, +\ 'command': function('ale_linters#ruby#debride#GetCommand'), +\ 'callback': 'ale_linters#ruby#debride#HandleOutput', +\}) diff --git a/ale_linters/scala/metals.vim b/ale_linters/scala/metals.vim new file mode 100644 index 00000000..f78c7119 --- /dev/null +++ b/ale_linters/scala/metals.vim @@ -0,0 +1,48 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Metals Language Server for Scala https://scalameta.org/metals/ + +call ale#Set('scala_metals_executable', 'metals-vim') +call ale#Set('scala_metals_project_root', '') + +function! ale_linters#scala#metals#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:potential_roots = [ + \ 'build.sc', + \ 'build.sbt', + \ '.bloop', + \ '.metals', + \] + + for l:root in l:potential_roots + let l:project_root = ale#path#ResolveLocalPath( + \ a:buffer, + \ l:root, + \ '' + \) + + if !empty(l:project_root) + return fnamemodify( + \ l:project_root, + \ ':h', + \) + endif + endfor +endfunction + +function! ale_linters#scala#metals#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'metals', +\ 'lsp': 'stdio', +\ 'language': 'scala', +\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')}, +\ 'command': function('ale_linters#scala#metals#GetCommand'), +\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'), +\}) diff --git a/ale_linters/terraform/tflint.vim b/ale_linters/terraform/tflint.vim index 6d54a8b1..f57ee6b6 100644 --- a/ale_linters/terraform/tflint.vim +++ b/ale_linters/terraform/tflint.vim @@ -9,23 +9,69 @@ call ale#Set('terraform_tflint_executable', 'tflint') function! ale_linters#terraform#tflint#Handle(buffer, lines) abort let l:output = [] + let l:pattern = '\v^(.*):(\d+),(\d+)-(\d+)?,?(\d+): (.{-1,}); (.+)$' + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) - for l:error in ale#util#FuzzyJSONDecode(a:lines, []) - if l:error.type is# 'ERROR' - let l:type = 'E' - elseif l:error.type is# 'NOTICE' - let l:type = 'I' - else - let l:type = 'W' - endif - - call add(l:output, { - \ 'lnum': l:error.line, - \ 'text': l:error.message, - \ 'type': l:type, - \ 'code': l:error.detector, - \}) - endfor + " This is a rough test for tflint's output format + " On versions prior to 0.11 it outputs all errors as a single level list + if type(l:json) is v:t_list + for l:error in l:json + if l:error.type is# 'ERROR' + let l:type = 'E' + elseif l:error.type is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:error.line, + \ 'text': l:error.message, + \ 'type': l:type, + \ 'code': l:error.detector, + \}) + endfor + else + for l:error in get(l:json, 'errors', []) + for l:match in ale#util#GetMatches(l:error.message, [l:pattern]) + if l:match[4] is# '' + let l:match[4] = l:match[2] + endif + + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'end_lnum': str2nr(l:match[4]), + \ 'end_col': str2nr(l:match[5]), + \ 'text': l:match[7], + \ 'code': l:match[6], + \ 'type': 'E', + \}) + endfor + endfor + + for l:error in get(l:json, 'issues', []) + if l:error.rule.severity is# 'ERROR' + let l:type = 'E' + elseif l:error.rule.severity is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:error.range.filename, + \ 'lnum': l:error.range.start.line, + \ 'col': l:error.range.start.column, + \ 'end_lnum': l:error.range.end.line, + \ 'end_col': l:error.range.end.column, + \ 'text': l:error.message, + \ 'code': l:error.rule.name, + \ 'type': l:type, + \}) + endfor + endif return l:output endfunction diff --git a/ale_linters/typescript/standard.vim b/ale_linters/typescript/standard.vim new file mode 100644 index 00000000..da8f14eb --- /dev/null +++ b/ale_linters/typescript/standard.vim @@ -0,0 +1,31 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for typescript files + +call ale#Set('typescript_standard_executable', 'standard') +call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_standard_options', '') + +function! ale_linters#typescript#standard#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'typescript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#typescript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'typescript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('typescript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), +\ 'command': function('ale_linters#typescript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/ale_linters/verilog/vlog.vim b/ale_linters/verilog/vlog.vim index 37d21c4c..951e2037 100644 --- a/ale_linters/verilog/vlog.vim +++ b/ale_linters/verilog/vlog.vim @@ -24,6 +24,20 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort \}) endfor + "Matches patterns like the following: + "** Warning: (vlog-2623) add.v(7): Undefined variable: C. + "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. + " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\)[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[2] . ' ' . l:match[4], + \}) + endfor + return l:output endfunction diff --git a/autoload/ale.vim b/autoload/ale.vim index 3a4e79c8..ee1a0d54 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -5,11 +5,18 @@ " 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_log_str = get(g:, 'ale_echo_msg_log_str', 'Log') let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') " Ignoring linters, for disabling some, or ignoring LSP diagnostics. let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0) +" LSP window/showMessage format +let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s') +" Valid values mimic LSP definitions (error, warning and information; log is +" never shown) +let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error') + let s:lint_timer = -1 let s:getcmdwintype_exists = exists('*getcmdwintype') @@ -156,7 +163,7 @@ function! ale#Queue(delay, ...) abort endif endfunction -let s:current_ale_version = [2, 5, 0] +let s:current_ale_version = [2, 6, 0] " A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim index dac5efb7..291edcee 100644 --- a/autoload/ale/assert.vim +++ b/autoload/ale/assert.vim @@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort endif endfunction -function! ale#assert#SetUpFixerTest(filetype, name) abort +function! ale#assert#SetUpFixerTest(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + " Set up a marker so ALE doesn't create real random temporary filenames. let g:ale_create_dummy_temporary_file = 1 let l:function_name = ale#fix#registry#GetFunc(a:name) let s:FixerFunction = function(l:function_name) - let l:prefix = 'ale_' . a:filetype . '_' . a:name + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' for l:key in filter(keys(g:), b:filter_expr) @@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort unlet b:[l:key] endfor - execute 'runtime autoload/ale/fixers/' . a:name . '.vim' + execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' if !exists('g:dir') call ale#test#SetDirectory('/testplugin/test/fixers') diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index 177a6acb..da24e839 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -1,5 +1,6 @@ " Author: w0rp <devw0rp@gmail.com> " Description: Completion support for LSP linters +scriptencoding utf-8 " The omnicompletion menu is shown through a special Plug mapping which is " only valid in Insert mode. This way, feedkeys() won't send these keys if you @@ -21,24 +22,101 @@ let s:timer_id = -1 let s:last_done_pos = [] " CompletionItemKind values from the LSP protocol. -let s:LSP_COMPLETION_TEXT_KIND = 1 -let s:LSP_COMPLETION_METHOD_KIND = 2 -let s:LSP_COMPLETION_FUNCTION_KIND = 3 -let s:LSP_COMPLETION_CONSTRUCTOR_KIND = 4 -let s:LSP_COMPLETION_FIELD_KIND = 5 -let s:LSP_COMPLETION_VARIABLE_KIND = 6 -let s:LSP_COMPLETION_CLASS_KIND = 7 -let s:LSP_COMPLETION_INTERFACE_KIND = 8 -let s:LSP_COMPLETION_MODULE_KIND = 9 -let s:LSP_COMPLETION_PROPERTY_KIND = 10 -let s:LSP_COMPLETION_UNIT_KIND = 11 -let s:LSP_COMPLETION_VALUE_KIND = 12 -let s:LSP_COMPLETION_ENUM_KIND = 13 -let s:LSP_COMPLETION_KEYWORD_KIND = 14 -let s:LSP_COMPLETION_SNIPPET_KIND = 15 -let s:LSP_COMPLETION_COLOR_KIND = 16 -let s:LSP_COMPLETION_FILE_KIND = 17 -let s:LSP_COMPLETION_REFERENCE_KIND = 18 +let g:ale_lsp_types = { +\ 1: 'text', +\ 2: 'method', +\ 3: 'function', +\ 4: 'constructor', +\ 5: 'field', +\ 6: 'variable', +\ 7: 'class', +\ 8: 'interface', +\ 9: 'module', +\ 10: 'property', +\ 11: 'unit', +\ 12: 'value', +\ 13: 'enum', +\ 14: 'keyword', +\ 15: 'snippet', +\ 16: 'color', +\ 17: 'file', +\ 18: 'reference', +\ 19: 'folder', +\ 20: 'enum_member', +\ 21: 'constant', +\ 22: 'struct', +\ 23: 'event', +\ 24: 'operator', +\ 25: 'type_parameter', +\ } + +" from https://github.com/microsoft/TypeScript/blob/29becf05012bfa7ba20d50b0d16813971e46b8a6/lib/protocol.d.ts#L2472 +let g:ale_tsserver_types = { +\ 'warning': 'text', +\ 'keyword': 'keyword', +\ 'script': 'file', +\ 'module': 'module', +\ 'class': 'class', +\ 'local class': 'class', +\ 'interface': 'interface', +\ 'type': 'class', +\ 'enum': 'enum', +\ 'enum member': 'enum_member', +\ 'var': 'variable', +\ 'local var': 'variable', +\ 'function': 'function', +\ 'local function': 'function', +\ 'method': 'method', +\ 'getter': 'property', +\ 'setter': 'method', +\ 'property': 'property', +\ 'constructor': 'constructor', +\ 'call': 'method', +\ 'index': 'index', +\ 'construct': 'constructor', +\ 'parameter': 'parameter', +\ 'type parameter': 'type_parameter', +\ 'primitive type': 'unit', +\ 'label': 'text', +\ 'alias': 'class', +\ 'const': 'constant', +\ 'let': 'variable', +\ 'directory': 'folder', +\ 'external module name': 'text', +\ 'JSX attribute': 'parameter', +\ 'string': 'text' +\ } + +" For compatibility reasons, we only use built in VIM completion kinds +" See :help complete-items for Vim completion kinds +let g:ale_completion_symbols = get(g:, 'ale_completion_symbols', { +\ 'text': 'v', +\ 'method': 'f', +\ 'function': 'f', +\ 'constructor': 'f', +\ 'field': 'm', +\ 'variable': 'v', +\ 'class': 't', +\ 'interface': 't', +\ 'module': 'd', +\ 'property': 'm', +\ 'unit': 'v', +\ 'value': 'v', +\ 'enum': 't', +\ 'keyword': 'v', +\ 'snippet': 'v', +\ 'color': 'v', +\ 'file': 'v', +\ 'reference': 'v', +\ 'folder': 'v', +\ 'enum_member': 'm', +\ 'constant': 'm', +\ 'struct': 't', +\ 'event': 'v', +\ 'operator': 'f', +\ 'type_parameter': 'p', +\ '<default>': 'v' +\ }) let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 @@ -278,6 +356,27 @@ function! ale#completion#GetAllTriggers() abort return deepcopy(s:trigger_character_map) endfunction +function! ale#completion#GetCompletionKind(kind) abort + let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '') + + if !empty(l:lsp_symbol) + return l:lsp_symbol + endif + + return get(g:ale_tsserver_types, a:kind, '') +endfunction + +function! ale#completion#GetCompletionSymbols(kind) abort + let l:kind = ale#completion#GetCompletionKind(a:kind) + let l:symbol = get(g:ale_completion_symbols, l:kind, '') + + if !empty(l:symbol) + return l:symbol + endif + + return get(g:ale_completion_symbols, '<default>', 'v') +endfunction + function! s:CompletionStillValid(request_id) abort let [l:line, l:column] = getpos('.')[1:2] @@ -329,18 +428,10 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort call add(l:documentationParts, l:part.text) endfor - if l:suggestion.kind is# 'className' - let l:kind = 'f' - elseif l:suggestion.kind is# 'parameterName' - let l:kind = 'f' - else - let l:kind = 'v' - endif - " See :help complete-items let l:result = { \ 'word': l:suggestion.name, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), \ 'icase': 1, \ 'menu': join(l:displayParts, ''), \ 'dup': g:ale_completion_tsserver_autoimport, @@ -425,23 +516,6 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif - " See :help complete-items for Vim completion kinds - if !has_key(l:item, 'kind') - let l:kind = 'v' - elseif l:item.kind is s:LSP_COMPLETION_METHOD_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_CONSTRUCTOR_KIND - let l:kind = 'm' - elseif l:item.kind is s:LSP_COMPLETION_FUNCTION_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_CLASS_KIND - let l:kind = 'f' - elseif l:item.kind is s:LSP_COMPLETION_INTERFACE_KIND - let l:kind = 'f' - else - let l:kind = 'v' - endif - let l:doc = get(l:item, 'documentation', '') if type(l:doc) is v:t_dict && has_key(l:doc, 'value') @@ -450,7 +524,7 @@ function! ale#completion#ParseLSPCompletions(response) abort call add(l:results, { \ 'word': l:word, - \ 'kind': l:kind, + \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, \ 'menu': get(l:item, 'detail', ''), \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), @@ -492,10 +566,17 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort let l:identifiers = [] for l:name in l:names - call add(l:identifiers, { + let l:identifier = { \ 'name': l:name.word, - \ 'source': get(l:name, 'source', ''), - \}) + \} + let l:source = get(l:name, 'source', '') + + " Empty source results in no details for the completed item + if !empty(l:source) + call extend(l:identifier, { 'source': l:source }) + endif + + call add(l:identifiers, l:identifier) endfor let b:ale_completion_info.request_id = ale#lsp#Send( @@ -722,7 +803,7 @@ endfunction function! ale#completion#HandleUserData(completed_item) abort let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' + if l:source isnot# 'ale-automatic' && l:source isnot# 'ale-manual' && l:source isnot# 'ale-callback' return endif @@ -734,6 +815,10 @@ function! ale#completion#HandleUserData(completed_item) abort let l:user_data = json_decode(l:user_data_json) + if type(l:user_data) isnot v:t_dict + return + endif + for l:code_action in get(l:user_data, 'codeActions', []) call ale#code_action#HandleCodeAction(l:code_action) endfor diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 750d2196..1b3ca1a8 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -54,6 +54,11 @@ let s:default_registry = { \ 'description': 'Apply elm-format to a file.', \ 'aliases': ['format'], \ }, +\ 'nimpretty': { +\ 'function': 'ale#fixers#nimpretty#Fix', +\ 'suggested_filetypes': ['nim'], +\ 'description': 'Apply nimpretty to a file.', +\ }, \ 'eslint': { \ 'function': 'ale#fixers#eslint#Fix', \ 'suggested_filetypes': ['javascript', 'typescript'], @@ -235,6 +240,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['haskell'], \ 'description': 'Refactor Haskell files with stylish-haskell.', \ }, +\ 'purty': { +\ 'function': 'ale#fixers#purty#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purty.', +\ }, \ 'ocamlformat': { \ 'function': 'ale#fixers#ocamlformat#Fix', \ 'suggested_filetypes': ['ocaml'], @@ -345,6 +355,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['ada'], \ 'description': 'Format Ada files with gnatpp.', \ }, +\ 'nixpkgs-fmt': { +\ 'function': 'ale#fixers#nixpkgsfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A formatter for Nix code', +\ }, +\ 'html-beautify': { +\ 'function': 'ale#fixers#html_beautify#Fix', +\ 'suggested_filetypes': ['html', 'htmldjango'], +\ 'description': 'Fix HTML files with html-beautify.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/html_beautify.vim b/autoload/ale/fixers/html_beautify.vim new file mode 100644 index 00000000..236cb6ec --- /dev/null +++ b/autoload/ale/fixers/html_beautify.vim @@ -0,0 +1,21 @@ +" Author: WhyNotHugo <hugo@barrera.io> +" Description: Lint HTML files with html-beautify. +" +call ale#Set('html_beautify_executable', 'html-beautify') +call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_beautify_options', '') +call ale#Set('html_beautify_change_directory', 1) + +function! ale#fixers#html_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_beautify', + \ ['html-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'html_beautify_options') + + return { + \ 'command': ale#Escape(l:executable). ' ' . l:options . ' -', + \} +endfunction diff --git a/autoload/ale/fixers/nimpretty.vim b/autoload/ale/fixers/nimpretty.vim new file mode 100644 index 00000000..fe2e7136 --- /dev/null +++ b/autoload/ale/fixers/nimpretty.vim @@ -0,0 +1,15 @@ +" Author: Nhan <hi@imnhan.com> +" Description: Integration of nimpretty with ALE. + +call ale#Set('nim_nimpretty_executable', 'nimpretty') +call ale#Set('nim_nimpretty_options', '--maxLineLen:80') + +function! ale#fixers#nimpretty#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable') + let l:options = ale#Var(a:buffer, 'nim_nimpretty_options') + + return { + \ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/nixpkgsfmt.vim b/autoload/ale/fixers/nixpkgsfmt.vim new file mode 100644 index 00000000..403ce798 --- /dev/null +++ b/autoload/ale/fixers/nixpkgsfmt.vim @@ -0,0 +1,12 @@ +call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt') +call ale#Set('nix_nixpkgsfmt_options', '') + +function! ale#fixers#nixpkgsfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/autoload/ale/fixers/purty.vim b/autoload/ale/fixers/purty.vim new file mode 100644 index 00000000..46d2cacd --- /dev/null +++ b/autoload/ale/fixers/purty.vim @@ -0,0 +1,22 @@ +" Author: iclanzan <sorin@iclanzan.com> +" Description: Integration of purty with ALE. + +call ale#Set('purescript_purty_executable', 'purty') + +function! ale#fixers#purty#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'purescript_purty_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#purty#Fix(buffer) abort + let l:executable = ale#fixers#purty#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/autoload/ale/fixers/standard.vim b/autoload/ale/fixers/standard.vim index 77712d40..cffa9f9d 100644 --- a/autoload/ale/fixers/standard.vim +++ b/autoload/ale/fixers/standard.vim @@ -7,6 +7,7 @@ call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', \]) @@ -14,7 +15,14 @@ endfunction function! ale#fixers#standard#Fix(buffer) abort let l:executable = ale#fixers#standard#GetExecutable(a:buffer) - let l:options = ale#Var(a:buffer, 'javascript_standard_options') + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:options_type = 'javascript_standard_options' + + if l:filetype =~# 'typescript' + let l:options_type = 'typescript_standard_options' + endif + + let l:options = ale#Var(a:buffer, l:options_type) return { \ 'command': ale#node#Executable(a:buffer, l:executable) diff --git a/autoload/ale/fixers/stylelint.vim b/autoload/ale/fixers/stylelint.vim index 6bfb2fde..6f4cf177 100644 --- a/autoload/ale/fixers/stylelint.vim +++ b/autoload/ale/fixers/stylelint.vim @@ -3,6 +3,7 @@ call ale#Set('stylelint_executable', 'stylelint') call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('stylelint_options', '') function! ale#fixers#stylelint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'stylelint', [ @@ -13,10 +14,14 @@ endfunction function! ale#fixers#stylelint#Fix(buffer) abort let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'stylelint_options') return { - \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) + \ . ' %t' + \ . ale#Pad(l:options) + \ . ' --fix', \ 'read_temporary_file': 1, \} endfunction diff --git a/autoload/ale/fixers/styler.vim b/autoload/ale/fixers/styler.vim index 7ff3275c..1c7607bd 100644 --- a/autoload/ale/fixers/styler.vim +++ b/autoload/ale/fixers/styler.vim @@ -2,13 +2,13 @@ " Description: Fixing R files with styler. call ale#Set('r_styler_executable', 'Rscript') -call ale#Set('r_styler_options', 'tidyverse_style') +call ale#Set('r_styler_options', 'tidyverse_style()') function! ale#fixers#styler#Fix(buffer) abort return { \ 'command': 'Rscript --vanilla -e ' \ . '"suppressPackageStartupMessages(library(styler));' - \ . 'style_file(commandArgs(TRUE), style = ' + \ . 'style_file(commandArgs(TRUE), transformers = ' \ . ale#Var(a:buffer, 'r_styler_options') . ')"' \ . ' %t', \ 'read_temporary_file': 1, diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index 4d533ff2..7ef63785 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -84,11 +84,14 @@ function! s:CheckForBadConfig(buffer, lines) abort endfunction function! s:parseJSON(buffer, lines) abort - try - let l:parsed = json_decode(a:lines[-1]) - catch - return [] - endtry + let l:parsed = [] + + for l:line in a:lines + try + let l:parsed = extend(l:parsed, json_decode(l:line)) + catch + endtry + endfor if type(l:parsed) != v:t_list || empty(l:parsed) return [] diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index 190a16b4..e4148ceb 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -130,6 +130,12 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort call s:HandleLSPErrorMessage(l:linter_name, a:response) elseif l:method is# 'textDocument/publishDiagnostics' call s:HandleLSPDiagnostics(a:conn_id, a:response) + elseif l:method is# 'window/showMessage' + call ale#lsp_window#HandleShowMessage( + \ s:lsp_linter_map[a:conn_id], + \ g:ale_lsp_show_message_format, + \ a:response.params + \) elseif get(a:response, 'type', '') is# 'event' \&& get(a:response, 'event', '') is# 'semanticDiag' call s:HandleTSServerDiagnostics(a:response, 'semantic') diff --git a/autoload/ale/lsp_window.vim b/autoload/ale/lsp_window.vim new file mode 100644 index 00000000..9a27f2f1 --- /dev/null +++ b/autoload/ale/lsp_window.vim @@ -0,0 +1,58 @@ +" Author: suoto <andre820@gmail.com> +" Description: Handling of window/* LSP methods, although right now only +" handles window/showMessage + +" Constants for message type codes +let s:LSP_MESSAGE_TYPE_DISABLED = 0 +let s:LSP_MESSAGE_TYPE_ERROR = 1 +let s:LSP_MESSAGE_TYPE_WARNING = 2 +let s:LSP_MESSAGE_TYPE_INFORMATION = 3 +let s:LSP_MESSAGE_TYPE_LOG = 4 + +" Translate strings from the user config to a number so we can check +" severities +let s:CFG_TO_LSP_SEVERITY = { +\ 'disabled': s:LSP_MESSAGE_TYPE_DISABLED, +\ 'error': s:LSP_MESSAGE_TYPE_ERROR, +\ 'warning': s:LSP_MESSAGE_TYPE_WARNING, +\ 'information': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'info': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'log': s:LSP_MESSAGE_TYPE_LOG +\} + +" Handle window/showMessage response. +" - details: dict containing linter name and format (g:ale_lsp_show_message_format) +" - params: dict with the params for the call in the form of {type: number, message: string} +function! ale#lsp_window#HandleShowMessage(linter_name, format, params) abort + let l:message = a:params.message + let l:type = a:params.type + + " Get the configured severity level threshold and check if the message + " should be displayed or not + let l:configured_severity = tolower(get(g:, 'ale_lsp_show_message_severity', 'error')) + " If the user has configured with a value we can't find on the conversion + " dict, fall back to warning + let l:cfg_severity_threshold = get(s:CFG_TO_LSP_SEVERITY, l:configured_severity, s:LSP_MESSAGE_TYPE_WARNING) + + if l:type > l:cfg_severity_threshold + return + endif + + " Severity will depend on the message type + if l:type is# s:LSP_MESSAGE_TYPE_ERROR + let l:severity = g:ale_echo_msg_error_str + elseif l:type is# s:LSP_MESSAGE_TYPE_INFORMATION + let l:severity = g:ale_echo_msg_info_str + elseif l:type is# s:LSP_MESSAGE_TYPE_LOG + let l:severity = g:ale_echo_msg_log_str + else + " Default to warning just in case + let l:severity = g:ale_echo_msg_warning_str + endif + + let l:string = substitute(a:format, '\V%severity%', l:severity, 'g') + let l:string = substitute(l:string, '\V%linter%', a:linter_name, 'g') + let l:string = substitute(l:string, '\V%s\>', l:message, 'g') + + call ale#util#ShowMessage(l:string) +endfunction diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim index 7430c7f2..db0e1ab6 100644 --- a/autoload/ale/sign.vim +++ b/autoload/ale/sign.vim @@ -23,6 +23,8 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) +let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) + if !hlexists('ALEErrorSign') highlight link ALEErrorSign error endif @@ -149,7 +151,7 @@ function! ale#sign#GetSignName(sublist) abort endfunction function! s:PriorityCmd() abort - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if s:supports_sign_groups return ' priority=' . g:ale_sign_priority . ' ' else return '' @@ -157,7 +159,7 @@ function! s:PriorityCmd() abort endfunction function! s:GroupCmd() abort - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if s:supports_sign_groups return ' group=ale ' else return ' ' @@ -175,7 +177,7 @@ function! ale#sign#ReadSigns(buffer) abort endfunction function! ale#sign#ParsePattern() abort - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if s:supports_sign_groups " Matches output like : " line=4 id=1 group=ale name=ALEErrorSign " строка=1 id=1000001 группа=ale имя=ALEErrorSign @@ -460,7 +462,7 @@ endfunction " Remove all signs. function! ale#sign#Clear() abort - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if s:supports_sign_groups sign unplace group=ale * else sign unplace * diff --git a/doc/ale-elm.txt b/doc/ale-elm.txt index 823b53e1..b1510241 100644 --- a/doc/ale-elm.txt +++ b/doc/ale-elm.txt @@ -50,7 +50,7 @@ g:ale_elm_ls_use_global *g:ale_elm_ls_use_global* g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* *b:ale_elm_ls_elm_path* Type: |String| - Default: `'elm'` + Default: `''` See |ale-integrations-local-executables| @@ -58,7 +58,7 @@ g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* *b:ale_elm_ls_elm_format_path* Type: |String| - Default: `'elm-format'` + Default: `''` See |ale-integrations-local-executables| @@ -66,10 +66,18 @@ g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path* *b:ale_elm_ls_elm_test_path* Type: |String| - Default: `'elm-test'` + Default: `''` See |ale-integrations-local-executables| + +g:ale_elm_ls_elm_analyse_trigger *g:ale_elm_ls_elm_analyse_trigger* + *b:ale_elm_ls_elm_analyse_trigger* + Type: |String| + Default: `'change'` + + One of 'change', 'save' or 'never' + =============================================================================== elm-make *ale-elm-elm-make* diff --git a/doc/ale-html.txt b/doc/ale-html.txt index 5d6b20e2..c78dc4cd 100644 --- a/doc/ale-html.txt +++ b/doc/ale-html.txt @@ -9,6 +9,16 @@ fecs *ale-html-fecs* and both of them reads `./.fecsrc` as the default configuration file. See: |ale-javascript-fecs|. +=============================================================================== +html-beautify *ale-html-beautify* + +g:ale_html_beautify_options *g:ale_html_beautify_options* + *b:ale_html_beautify_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to html-beautify. + =============================================================================== htmlhint *ale-html-htmlhint* diff --git a/doc/ale-nim.txt b/doc/ale-nim.txt new file mode 100644 index 00000000..8985aeb8 --- /dev/null +++ b/doc/ale-nim.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE Nim Integration *ale-nim-options* + + +=============================================================================== +nimcheck *ale-nim-nimcheck* + + ALE does not provide additional configuration options for `nimcheck` at this + point. + + +=============================================================================== +nimlsp *ale-nim-nimlsp* + +g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* + + Type: |String| + Default: `''` + + Sets the path to Nim source repository as the first argument to `nimlsp` + command. + + +=============================================================================== +nimpretty *ale-nim-nimpretty* + + +g:ale_nim_nimpretty_executable *g:ale_nim_nimpretty_executable* + *b:ale_nim_nimpretty_executable* + Type: |String| + Default: `'nimpretty'` + + This variable can be changed to use a different executable for nimpretty. + + +g:ale_nim_nimpretty_options *g:ale_nim_nimpretty_options* + *b:ale_nim_nimpretty_options* + Type: |String| + Default: `'--maxLineLen:80'` + + This variable can be changed to modify flags given to nimpretty. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-nix.txt b/doc/ale-nix.txt new file mode 100644 index 00000000..5b2bd6cb --- /dev/null +++ b/doc/ale-nix.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Nix Integration *ale-nix-options* + + +=============================================================================== +nixpkgs-fmt *ale-nix-nixpkgs-fmt* + +g:ale_nix_nixpkgsfmt_executable *g:ale_nix_nixpkgsfmt_executable* + *b:ale_nix_nixpkgsfmt_executable* + Type: |String| + Default: `'nixpkgs-fmt'` + + This variable sets executable used for nixpkgs-fmt. + +g:ale_nix_nixpkgsfmt_options *g:ale_nix_nixpkgsfmt_options* + *b:ale_nix_nixpkgsfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixpkgs-fmt fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-php.txt b/doc/ale-php.txt index d41fb50d..645decd7 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -157,9 +157,9 @@ g:ale_php_phpstan_level *g:ale_php_phpstan_level* Type: |String| Default: `''` - This variable controls the rule levels. 0 is the loosest and 4 is the + This variable controls the rule levels. 0 is the loosest and 7 is the strictest. If this option isn't set, the rule level will be controlled by - the configuration file. If no configuration file can be detected, `'4'` will + the configuration file. If no configuration file can be detected, `'7'` will be used instead. @@ -189,6 +189,13 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable* This variable sets the executable used for psalm. +g:ale_psalm_langserver_options *g:ale_psalm_langserver_options* + *b:ale_psalm_langserver_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to psalm. + =============================================================================== php-cs-fixer *ale-php-php-cs-fixer* diff --git a/doc/ale-purescript.txt b/doc/ale-purescript.txt index 33fd2429..e809f2c9 100644 --- a/doc/ale-purescript.txt +++ b/doc/ale-purescript.txt @@ -30,4 +30,13 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config \ } \} =============================================================================== +purty *ale-purescript-purty* + +g:ale_purescript_purty_executable *g:ale_purescript_purty_executable* + *b:ale_purescript_purty_executable* + Type: |String| + Default: `'purty'` + + This variable can be changed to use a different executable for purty. +=============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt index e373ab8e..a27a20b2 100644 --- a/doc/ale-ruby.txt +++ b/doc/ale-ruby.txt @@ -21,6 +21,26 @@ g:ale_ruby_brakeman_options *g:ale_ruby_brakeman_options* The contents of this variable will be passed through to brakeman. +=============================================================================== +debride *ale-ruby-debride* + +g:ale_ruby_debride_executable *g:ale_ruby_debride_executable* + *b:ale_ruby_debride_executable* + Type: String + Default: `'debride'` + + Override the invoked debride binary. Set this to `'bundle'` to invoke + `'bundle` `exec` debride'. + + +g:ale_ruby_debride_options *g:ale_ruby_debride_options* + *b:ale_ruby_debride_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to debride. + + =============================================================================== rails_best_practices *ale-ruby-rails_best_practices* @@ -91,7 +111,7 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* Type: |String| Default: `''` - This variable can be change to modify flags given to rubocop. + This variable can be changed to modify flags given to rubocop. =============================================================================== @@ -146,7 +166,7 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* Type: |String| Default: `''` - This variable can be change to modify flags given to sorbet. + This variable can be changed to modify flags given to sorbet. =============================================================================== @@ -166,7 +186,7 @@ g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options* Type: |String| Default: `''` - This variable can be change to modify flags given to standardrb. + This variable can be changed to modify flags given to standardrb. =============================================================================== diff --git a/doc/ale-scala.txt b/doc/ale-scala.txt index ff43cd6c..c9638baf 100644 --- a/doc/ale-scala.txt +++ b/doc/ale-scala.txt @@ -3,6 +3,32 @@ ALE Scala Integration *ale-scala-options* =============================================================================== +metals *ale-scala-metals* + +`metals` requires either an SBT project, a Mill project, or a running Bloop +server. + + +g:ale_scala_metals_executable *g:ale_scala_metals_executable* + *b:ale_scala_metals_executable* + Type: |String| + Default: `'metals-vim'` + + Override the invoked `metals` binary. + + +g:ale_scala_metals_project_root *g:ale_scala_metals_project_root* + *b:ale_scala_metals_project_root* + Type: |String| + Default: `''` + + By default the project root is found by searching upwards for `build.sbt`, + `build.sc`, `.bloop` or `.metals`. + If the project root is elsewhere, you can override the project root + directory. + + +=============================================================================== sbtserver *ale-scala-sbtserver* `sbtserver` requires a running ^1.1.x sbt shell to connect to. It will attempt diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index a29ea6a3..29dabab7 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -124,7 +124,7 @@ Notes: * `mix`!! * Elm * `elm-format` - * `elm-lsp` + * `elm-ls` * `elm-make` * Erb * `erb` @@ -194,6 +194,7 @@ Notes: * HTML * `alex`!! * `fecs` + * `html-beautify` * `HTMLHint` * `prettier` * `proselint` @@ -282,8 +283,11 @@ Notes: * `nasm`!! * Nim * `nim check`!! + * `nimlsp` + * `nimpretty` * nix * `nix-instantiate` + * `nixpkgs-fmt` * nroff * `alex`!! * `proselint` @@ -346,6 +350,7 @@ Notes: * `puppet-lint` * PureScript * `purescript-language-server` + * `purty` * Python * `autopep8` * `bandit` @@ -391,6 +396,7 @@ Notes: * `rpmlint` * Ruby * `brakeman` + * `debride` * `rails_best_practices`!! * `reek` * `rubocop` @@ -409,6 +415,7 @@ Notes: * `stylelint` * Scala * `fsc` + * `metals` * `sbtserver` * `scalac` * `scalafmt` @@ -462,6 +469,7 @@ Notes: * `eslint` * `fecs` * `prettier` + * `standard` * `tslint` * `tsserver` * `typecheck` diff --git a/doc/ale-typescript.txt b/doc/ale-typescript.txt index 7dc59820..2c50d119 100644 --- a/doc/ale-typescript.txt +++ b/doc/ale-typescript.txt @@ -17,6 +17,33 @@ See |ale-javascript-prettier| for information about the available options. =============================================================================== +standard *ale-typescript-standard* + +g:ale_typescript_standard_executable *g:ale_typescript_standard_executable* + *b:ale_typescript_standard_executable* + Type: |String| + Default: `'standard'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_standard_options *g:ale_typescript_standard_options* + *b:ale_typescript_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to standard. + + +g:ale_typescript_standard_use_global *g:ale_typescript_standard_use_global* + *b:ale_typescript_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== tslint *ale-typescript-tslint* This linter isn't recommended, because TSLint can't be used for checking for diff --git a/doc/ale.txt b/doc/ale.txt index b368afd3..847a9777 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -172,7 +172,7 @@ address to connect to instead. > call ale#linter#Define('filetype_here', { \ 'name': 'any_name_you_want', - \ 'lsp': 'stdio', + \ 'lsp': 'socket', \ 'address': 'servername:1234', \ 'project_root': '/path/to/root_of_project', \}) @@ -432,7 +432,42 @@ vimrc, and your issues should go away. > set completeopt=menu,menuone,preview,noselect,noinsert < - + *ale-symbols* + +ALE provides a set of basic completion symbols. If you want to replace those +symbols with others, you can set the variable |g:ale_completion_symbols| with +a mapping of the type of completion to the symbol or other string that you +would like to use. An example here shows the available options for symbols > + + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'unit', + \ 'value': 'val', + \ 'enum': '', + \ 'keyword': 'keyword', + \ 'snippet': '', + \ 'color': 'color', + \ 'file': '', + \ 'reference': 'ref', + \ 'folder': '', + \ 'enum member': '', + \ 'constant': '', + \ 'struct': '', + \ 'event': 'event', + \ 'operator': '', + \ 'type_parameter': 'type param', + \ '<default>': 'v' + \ } +< ------------------------------------------------------------------------------- 5.2 Go To Definition *ale-go-to-definition* @@ -671,6 +706,47 @@ g:ale_completion_excluded_words *g:ale_completion_excluded_words* let b:ale_completion_excluded_words = ['it', 'describe'] < +g:ale_completion_symbols *g:ale_completion_symbols* + + Type: |Dictionary| + + + A mapping from completion types to symbols for completions. See + |ale-symbols| for more information. + + By default, this mapping only uses built in Vim completion kinds, but it can + be updated to use any unicode character for the completion kind. For + example: > + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'v', + \ 'value': 'v', + \ 'enum': 't', + \ 'keyword': 'v', + \ 'snippet': 'v', + \ 'color': 'v', + \ 'file': 'v', + \ 'reference': 'v', + \ 'folder': 'v', + \ 'enum_member': 'm', + \ 'constant': 'm', + \ 'struct': 't', + \ 'event': 'v', + \ 'operator': 'f', + \ 'type_parameter': 'p', + \ '<default>': 'v' + \ }) +< + g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* Type: |Number| @@ -801,6 +877,15 @@ g:ale_echo_msg_info_str *g:ale_echo_msg_info_str* The string used for `%severity%` for info. See |g:ale_echo_msg_format| +g:ale_echo_msg_log_str *g:ale_echo_msg_log_str* + + Type: |String| + Default: `'Log'` + + The string used for `%severity%` for log, used only for handling LSP show + message requests. See |g:ale_lsp_show_message_format| + + g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* Type: |String| @@ -1251,6 +1336,47 @@ b:ale_loclist_msg_format *b:ale_loclist_msg_format* The strings for configuring `%severity%` are also used for this option. + +g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* + + Type: |String| + Default: `'%severity%:%linter%: %s'` + + This variable defines the format that messages received from an LSP will + have when echoed. The following sequences of characters will be replaced. + + `%s` - replaced with the message text + `%linter%` - replaced with the name of the linter + `%severity%` - replaced with the severity of the message + + The strings for `%severity%` levels "error", "info" and "warning" are shared + with |g:ale_echo_msg_format|. Severity "log" is unique to + |g:ale_lsp_show_message_format| and it can be configured via + + |g:ale_echo_msg_log_str| - Defaults to `'Log'` + + Please note that |g:ale_lsp_show_message_format| *can not* be configured + separately for each buffer like |g:ale_echo_msg_format| can. + + +g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* + + Type: |String| + Default: `'error'` + + This variable defines the minimum severity level an LSP message needs to be + displayed. Messages below this level are discarded; please note that + messages with `Log` severity level are always discarded. + + Possible values follow the LSP spec `MessageType` definition: + + `'error'` - Displays only errors. + `'warning'` - Displays errors and warnings. + `'information'` - Displays errors, warnings and infos + `'log'` - Same as `'information'` + `'disabled'` - Doesn't display any information at all. + + g:ale_lsp_root *g:ale_lsp_root* b:ale_lsp_root *b:ale_lsp_root* @@ -1709,6 +1835,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* Type: |Number| Default: `0` + This option only has any effect in NeoVim. + When this option is set to `1`, a message will be shown when a cursor is near a warning or error. ALE will attempt to find the warning or error at a column nearest to the cursor when the cursor is resting on a line which @@ -2241,6 +2369,7 @@ documented in additional help files. terraform-fmt.........................|ale-hcl-terraform-fmt| html....................................|ale-html-options| fecs..................................|ale-html-fecs| + html-beautify.........................|ale-html-beautify| htmlhint..............................|ale-html-htmlhint| tidy..................................|ale-html-tidy| prettier..............................|ale-html-prettier| @@ -2305,6 +2434,12 @@ documented in additional help files. mmc...................................|ale-mercury-mmc| nasm....................................|ale-nasm-options| nasm..................................|ale-nasm-nasm| + nim.....................................|ale-nim-options| + nimcheck..............................|ale-nim-nimcheck| + nimlsp................................|ale-nim-nimlsp| + nimpretty.............................|ale-nim-nimpretty| + nix.....................................|ale-nix-options| + nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| nroff...................................|ale-nroff-options| write-good............................|ale-nroff-write-good| objc....................................|ale-objc-options| @@ -2360,6 +2495,7 @@ documented in additional help files. puppet-languageserver.................|ale-puppet-languageserver| purescript..............................|ale-purescript-options| purescript-language-server............|ale-purescript-language-server| + purty.................................|ale-purescript-purty| pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| @@ -2395,6 +2531,7 @@ documented in additional help files. write-good............................|ale-restructuredtext-write-good| ruby....................................|ale-ruby-options| brakeman..............................|ale-ruby-brakeman| + debride...............................|ale-ruby-debride| rails_best_practices..................|ale-ruby-rails_best_practices| reek..................................|ale-ruby-reek| rubocop...............................|ale-ruby-rubocop| @@ -2412,6 +2549,7 @@ documented in additional help files. sasslint..............................|ale-sass-sasslint| stylelint.............................|ale-sass-stylelint| scala...................................|ale-scala-options| + metals................................|ale-scala-metals| sbtserver.............................|ale-scala-sbtserver| scalafmt..............................|ale-scala-scalafmt| scalastyle............................|ale-scala-scalastyle| @@ -2463,6 +2601,7 @@ documented in additional help files. typescript..............................|ale-typescript-options| eslint................................|ale-typescript-eslint| prettier..............................|ale-typescript-prettier| + standard..............................|ale-typescript-standard| tslint................................|ale-typescript-tslint| tsserver..............................|ale-typescript-tsserver| vala....................................|ale-vala-options| diff --git a/supported-tools.md b/supported-tools.md index 1a297946..0abc6b75 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -133,7 +133,7 @@ formatting. * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: * Elm * [elm-format](https://github.com/avh4/elm-format) - * [elm-lsp](https://github.com/antew/elm-lsp) + * [elm-ls](https://github.com/elm-tooling/elm-language-server) * [elm-make](https://github.com/elm/compiler) * Erb * [erb](https://apidock.com/ruby/ERB) @@ -203,6 +203,7 @@ formatting. * HTML * [alex](https://github.com/wooorm/alex) :floppy_disk: * [fecs](http://fecs.baidu.com/) + * [html-beautify](https://beautifier.io/) * [HTMLHint](http://htmlhint.com/) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) @@ -291,8 +292,11 @@ formatting. * [nasm](https://www.nasm.us/) :floppy_disk: * Nim * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: + * [nimlsp](https://github.com/PMunch/nimlsp) + * nimpretty * nix * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) + * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) * nroff * [alex](https://github.com/wooorm/alex) :floppy_disk: * [proselint](http://proselint.com/) @@ -341,8 +345,8 @@ formatting. * Pony * [ponyc](https://github.com/ponylang/ponyc) * PowerShell - * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk - * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk + * [powershell](https://github.com/PowerShell/PowerShell) :floppy_disk: + * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) :floppy_disk: * Prolog * [swipl](https://github.com/SWI-Prolog/swipl-devel) * proto @@ -355,6 +359,7 @@ formatting. * [puppet-lint](https://puppet-lint.com) * PureScript * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) + * [purty](https://gitlab.com/joneshf/purty) * Python * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: @@ -400,6 +405,7 @@ formatting. * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) * Ruby * [brakeman](http://brakemanscanner.org/) :floppy_disk: + * [debride](https://github.com/seattlerb/debride) :floppy_disk: * [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk: * [reek](https://github.com/troessner/reek) * [rubocop](https://github.com/bbatsov/rubocop) @@ -418,6 +424,7 @@ formatting. * [stylelint](https://github.com/stylelint/stylelint) * Scala * [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html) + * [metals](https://scalameta.org/metals/) * [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html) * [scalac](http://scala-lang.org) * [scalafmt](https://scalameta.org/scalafmt/) @@ -471,6 +478,7 @@ formatting. * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) + * [standard](http://standardjs.com/) * [tslint](https://github.com/palantir/tslint) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * typecheck diff --git a/test/command_callback/clangd_paths/compile_commands.json b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json index e69de29b..e69de29b 100644 --- a/test/command_callback/clangd_paths/compile_commands.json +++ b/test/command_callback/clangd_paths/with_build_dir/unusual_build_dir_name/compile_commands.json diff --git a/test/command_callback/psalm-project/vendor/bin/psalm-language-server b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json index e69de29b..e69de29b 100755..100644 --- a/test/command_callback/psalm-project/vendor/bin/psalm-language-server +++ b/test/command_callback/clangd_paths/with_compile_commands/compile_commands.json diff --git a/test/command_callback/html_beautify_paths/html-beautify b/test/command_callback/html_beautify_paths/html-beautify new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/html_beautify_paths/html-beautify diff --git a/test/command_callback/html_beautify_paths/test.html b/test/command_callback/html_beautify_paths/test.html new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/html_beautify_paths/test.html diff --git a/test/command_callback/psalm-project/vendor/bin/psalm b/test/command_callback/psalm-project/vendor/bin/psalm new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/psalm-project/vendor/bin/psalm diff --git a/test/command_callback/test_c_clang_tidy_command_callback.vader b/test/command_callback/test_c_clang_tidy_command_callback.vader index fa76c66c..5ebbbd45 100644 --- a/test/command_callback/test_c_clang_tidy_command_callback.vader +++ b/test/command_callback/test_c_clang_tidy_command_callback.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('c', 'clangtidy') call ale#test#SetFilename('test.c') diff --git a/test/command_callback/test_c_clangd_command_callbacks.vader b/test/command_callback/test_c_clangd_command_callbacks.vader index dc52097d..753dc9a8 100644 --- a/test/command_callback/test_c_clangd_command_callbacks.vader +++ b/test/command_callback/test_c_clangd_command_callbacks.vader @@ -4,6 +4,11 @@ Before: Save &filetype let &filetype = 'c' + Save b:ale_c_clangd_options + Save b:ale_c_build_dir + Save b:ale_c_build_dir_names + Save b:ale_c_parse_compile_commands + After: call ale#assert#TearDownLinterTest() @@ -18,9 +23,9 @@ Execute(The project root should be detected correctly): AssertLSPProject '' - call ale#test#SetFilename('clangd_paths/dummy.c') + call ale#test#SetFilename('clangd_paths/with_compile_commands/dummy.c') - AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths') + AssertLSPProject ale#path#Simplify(g:dir . '/clangd_paths/with_compile_commands') Execute(The executable should be configurable): let g:ale_c_clangd_executable = 'foobar' @@ -32,3 +37,15 @@ Execute(The options should be configurable): AssertLinter 'clangd', ale#Escape('clangd') . ' ' . b:ale_c_clangd_options +Execute(The compile command database should be detected correctly): + call ale#test#SetFilename('clangd_paths/with_build_dir/dummy_src/dummy.c') + + let b:ale_c_clangd_options = '' + let b:ale_c_build_dir = '' + let b:ale_c_build_dir_names = ['unusual_build_dir_name'] + let b:ale_c_parse_compile_commands = 1 + + AssertLinter 'clangd', ale#Escape('clangd') + \ . ' -compile-commands-dir=' + \ . ale#Escape(ale#path#Simplify(g:dir . '/clangd_paths/with_build_dir/unusual_build_dir_name')) + diff --git a/test/command_callback/test_c_import_paths.vader b/test/command_callback/test_c_import_paths.vader index 6c616d89..e6102998 100644 --- a/test/command_callback/test_c_import_paths.vader +++ b/test/command_callback/test_c_import_paths.vader @@ -121,6 +121,16 @@ Execute(The C Clang handler should include root directories for projects with .h \ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/hpp_file_project')) \ . ' -' +Execute(The C ClangTidy handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('c', 'clangtidy') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp') + let g:ale_c_clangtidy_options = '' + + AssertLinter 'clang-tidy', + \ ale#Escape('clang-tidy') + \ . ' %s ' + \ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile): call ale#assert#SetUpLinterTest('cpp', 'gcc') call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp') @@ -225,3 +235,14 @@ Execute(The C++ ClangTidy handler should include json folders for projects with \ ale#Escape('clang-tidy') \ . ' %s ' \ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/json_project/build')) + +Execute(The C++ ClangTidy handler should include 'include' directories for projects with a Makefile): + call ale#assert#SetUpLinterTest('cpp', 'clangtidy') + call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp') + let g:ale_cpp_clangtidy_options = '' + + AssertLinter 'clang-tidy', + \ ale#Escape('clang-tidy') + \ . ' %s ' + \ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include')) + diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader index 53ae311b..c2d18dea 100644 --- a/test/command_callback/test_clang_tidy_command_callback.vader +++ b/test/command_callback/test_clang_tidy_command_callback.vader @@ -1,4 +1,7 @@ Before: + Save g:ale_c_parse_makefile + let g:ale_c_parse_makefile = 0 + call ale#assert#SetUpLinterTest('cpp', 'clangtidy') call ale#test#SetFilename('test.cpp') diff --git a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader index 7aa09eed..188141d5 100644 --- a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader +++ b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader @@ -7,7 +7,7 @@ After: Execute(The executable should be configurable): AssertLinter 'clang-check', \ ale#Escape('clang-check') - \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' let b:ale_cpp_clangcheck_executable = 'foobar' @@ -15,7 +15,7 @@ Execute(The executable should be configurable): " being generated. AssertLinter 'foobar', \ ale#Escape('foobar') - \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' Execute(The options should be configurable): let b:ale_cpp_clangcheck_options = '--something' @@ -23,7 +23,7 @@ Execute(The options should be configurable): AssertLinter 'clang-check', \ ale#Escape('clang-check') \ . ' -analyze %s' - \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text' + \ . ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics' \ . ' --something' Execute(The build directory should be used when set): diff --git a/test/command_callback/test_nimlsp_command_callback.vader b/test/command_callback/test_nimlsp_command_callback.vader new file mode 100644 index 00000000..c109deef --- /dev/null +++ b/test/command_callback/test_nimlsp_command_callback.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpLinterTest('nim', 'nimlsp') + +After: + call ale#assert#TearDownLinterTest() + +Execute(It does not set nim sources by default): + AssertLinter 'nimlsp', ale#Escape('nimlsp') + +Execute(Sets nimlsp and escapes sources from g:ale_nim_nimlsp_nim_sources): + let g:ale_nim_nimlsp_nim_sources = '/path/to /Nim' + AssertLinter 'nimlsp', ale#Escape('nimlsp') . ' ' . ale#Escape('/path/to /Nim') diff --git a/test/command_callback/test_psalm_command_callbacks.vader b/test/command_callback/test_psalm_command_callbacks.vader index 33d770c2..70b5af95 100644 --- a/test/command_callback/test_psalm_command_callbacks.vader +++ b/test/command_callback/test_psalm_command_callbacks.vader @@ -9,18 +9,26 @@ After: call ale#assert#TearDownLinterTest() Execute(The default executable path should be correct): - AssertLinter 'psalm-language-server', - \ ale#Escape('psalm-language-server') + AssertLinter 'psalm', + \ ale#Escape('psalm') . ' --language-server' Execute(Vendor executables should be detected): call ale#test#SetFilename('psalm-project/test.php') AssertLinter - \ ale#path#Simplify(g:dir . '/psalm-project/vendor/bin/psalm-language-server'), + \ ale#path#Simplify(g:dir . '/psalm-project/vendor/bin/psalm'), \ ale#Escape(ale#path#Simplify( \ g:dir - \ . '/psalm-project/vendor/bin/psalm-language-server' - \ )) + \ . '/psalm-project/vendor/bin/psalm' + \ )) . ' --language-server' + +Execute(User provided options should be used): + let g:ale_psalm_langserver_options = '--my-user-provided-option my-value' + + AssertLinter 'psalm', + \ ale#Escape('psalm') + \ . ' --language-server --my-user-provided-option my-value' + Execute(The project path should be correct for .git directories): call ale#test#SetFilename('psalm-project/test.php') diff --git a/test/command_callback/test_ruby_debride_command_callback.vader b/test/command_callback/test_ruby_debride_command_callback.vader new file mode 100644 index 00000000..f7628432 --- /dev/null +++ b/test/command_callback/test_ruby_debride_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('ruby', 'debride') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'debride', ale#Escape('debride') . ' %s' diff --git a/test/command_callback/test_scala_metals.vader b/test/command_callback/test_scala_metals.vader new file mode 100644 index 00000000..70e14c1a --- /dev/null +++ b/test/command_callback/test_scala_metals.vader @@ -0,0 +1,20 @@ +" Author: Jeffrey Lau https://github.com/zoonfafer +" Description: Tests for the Scala Metals linter + +Before: + call ale#assert#SetUpLinterTest('scala', 'metals') + +After: + call ale#assert#TearDownLinterTest() +Execute(should set metals for sbt project with build.sbt): + call ale#test#SetFilename('../scala_fixtures/valid_sbt_project/Main.scala') + AssertLSPLanguage 'scala' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . 'command_callback/../scala_fixtures/valid_sbt_project') +Execute(should not set metals for sbt project without build.sbt): + call ale#test#SetFilename('../scala_fixtures/invalid_sbt_project/Main.scala') + AssertLSPLanguage 'scala' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject '' diff --git a/test/command_callback/test_standardts_command_callback.vader b/test/command_callback/test_standardts_command_callback.vader new file mode 100644 index 00000000..d769e712 --- /dev/null +++ b/test/command_callback/test_standardts_command_callback.vader @@ -0,0 +1,43 @@ +Before: + call ale#assert#SetUpLinterTest('typescript', 'standard') + call ale#test#SetFilename('testfile.js') + unlet! b:executable + +After: + call ale#assert#TearDownLinterTest() + +Execute(bin/cmd.js paths should be preferred): + call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + \) + + AssertLinter b:executable, + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' --stdin %s' + +Execute(.bin directories should be used too): + call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/standard-test-files/with-bin/node_modules/.bin/standard' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin %s' + +Execute(The global executable should be used otherwise): + AssertLinter 'standard', ale#Escape('standard') . ' --stdin %s' + +Execute(The global executable should be configurable): + let b:ale_typescript_standard_executable = 'foobar' + + AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin %s' + +Execute(The options should be configurable): + let b:ale_typescript_standard_options = '--wat' + + AssertLinter 'standard', ale#Escape('standard') . ' --wat --stdin %s' diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader index e06ac98b..d70fefeb 100644 --- a/test/completion/test_completion_events.vader +++ b/test/completion/test_completion_events.vader @@ -431,6 +431,12 @@ Execute(HandleUserData should call ale#code_action#HandleCodeAction): \}) AssertEqual g:handle_code_action_called, 2 + let b:ale_completion_info = {'source': 'ale-callback'} + call ale#completion#HandleUserData({ + \ 'user_data': '{"codeActions": [{"description":"", "changes": []}]}' + \}) + AssertEqual g:handle_code_action_called, 3 + Execute(ale#code_action#HandleCodeAction should not be called when when source is not ALE): call MockHandleCodeAction() let b:ale_completion_info = {'source': 'syntastic'} diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader index b997ac86..4b7392f5 100644 --- a/test/completion/test_lsp_completion_messages.vader +++ b/test/completion/test_lsp_completion_messages.vader @@ -190,10 +190,8 @@ Execute(The right message sent to the tsserver LSP when the first completion mes \ 'source': '/path/to/foo.ts', \ }, { \ 'name': 'FooBar', - \ 'source': '', \ }, { \ 'name': 'frazzle', - \ 'source': '', \ }], \ 'offset': 1, \ 'line': 1, diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader index ef954564..1fdbbd96 100644 --- a/test/completion/test_lsp_completion_parsing.vader +++ b/test/completion/test_lsp_completion_parsing.vader @@ -17,17 +17,17 @@ Execute(Should handle Rust completion results correctly): \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = &''a str>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from_iter', 'menu': 'fn from_iter<I: IntoIterator<Item = Cow<''a, str>>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Searcher', 'menu': 'type Searcher = <&''b str as Pattern<''a>>::Searcher;', 'info': '', 'kind': 'f', 'icase': 1}, + \ {'word': 'Searcher', 'menu': 'type Searcher = <&''b str as Pattern<''a>>::Searcher;', 'info': '', 'kind': 't', 'icase': 1}, \ {'word': 'default', 'menu': 'fn default() -> String', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = String;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Target', 'menu': 'type Target = str;', 'info': '', 'kind': 'f', 'icase': 1}, - \ {'word': 'Err', 'menu': 'type Err = ParseError;', 'info': '', 'kind': 'f', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = String;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Output', 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Target', 'menu': 'type Target = str;', 'info': '', 'kind': 't', 'icase': 1}, + \ {'word': 'Err', 'menu': 'type Err = ParseError;', 'info': '', 'kind': 't', 'icase': 1}, \ {'word': 'from_str', 'menu': 'fn from_str(s: &str) -> Result<String, ParseError>', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from', 'menu': 'fn from(s: &''a str) -> String', 'info': '', 'kind': 'f', 'icase': 1}, \ {'word': 'from', 'menu': 'fn from(s: Box<str>) -> String', 'info': '', 'kind': 'f', 'icase': 1}, diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader index dbb8de32..6beb7b0a 100644 --- a/test/completion/test_tsserver_completion_parsing.vader +++ b/test/completion/test_tsserver_completion_parsing.vader @@ -36,7 +36,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'abc', \ 'menu': '(property) Foo.abc: number', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -44,7 +44,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'def', \ 'menu': '(property) Foo.def: number', \ 'info': 'foo bar baz', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -52,7 +52,7 @@ Execute(TypeScript completion details responses should be parsed correctly): \ 'word': 'ghi', \ 'menu': '(class) Foo', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, @@ -124,7 +124,7 @@ Execute(Entries without details should be included in the responses): \ 'word': 'abc', \ 'menu': 'import { def } from "./Foo"; (property) Foo.abc: number', \ 'info': '', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'user_data': json_encode({ \ 'codeActions': [{ @@ -138,7 +138,7 @@ Execute(Entries without details should be included in the responses): \ 'word': 'def', \ 'menu': '(property) Foo.def: number', \ 'info': 'foo bar baz', - \ 'kind': 'f', + \ 'kind': 'v', \ 'icase': 1, \ 'dup': g:ale_completion_tsserver_autoimport, \ }, diff --git a/test/fixers/test_html_beautify_fixer_callback.vader b/test/fixers/test_html_beautify_fixer_callback.vader new file mode 100644 index 00000000..372572e4 --- /dev/null +++ b/test/fixers/test_html_beautify_fixer_callback.vader @@ -0,0 +1,16 @@ +Before: + call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify') + + call ale#test#SetDirectory('/testplugin/test/fixers') + silent cd .. + silent cd command_callback + +After: + Restore + + call ale#assert#TearDownFixerTest() + +Execute(The html-beautify callback should return the correct default command): + AssertEqual + \ {'command': ale#Escape('html-beautify') . ' -'}, + \ ale#fixers#html_beautify#Fix(bufnr('')) diff --git a/test/fixers/test_nimpretty_fixer_callback.vader b/test/fixers/test_nimpretty_fixer_callback.vader new file mode 100644 index 00000000..a26f649a --- /dev/null +++ b/test/fixers/test_nimpretty_fixer_callback.vader @@ -0,0 +1,23 @@ +Before: + call ale#assert#SetUpFixerTest('nim', 'nimpretty') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The nimpretty callback should return the correct default values): + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('nimpretty') . ' %t --maxLineLen:80' + \ }, + \ ale#fixers#nimpretty#Fix(bufnr('')) + +Execute(The nimpretty callback should include any additional options): + let g:ale_nim_nimpretty_options = '--some-option' + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('nimpretty') . ' %t --some-option' + \ }, + \ ale#fixers#nimpretty#Fix(bufnr('')) diff --git a/test/fixers/test_nixpkgsfmt_fixer_callback.vader b/test/fixers/test_nixpkgsfmt_fixer_callback.vader new file mode 100644 index 00000000..0065f77b --- /dev/null +++ b/test/fixers/test_nixpkgsfmt_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_nix_nixpkgsfmt_executable + Save g:ale_nix_nixpkgsfmt_options + +After: + Restore + +Execute(The nixpkgs-fmt callback should return the correct default values): + AssertEqual + \ { + \ 'command': ale#Escape('nixpkgs-fmt') + \ }, + \ ale#fixers#nixpkgsfmt#Fix(bufnr('')) + +Execute(The nixpkgs-fmt executable and options should be configurable): + let g:ale_nix_nixpkgsfmt_executable = '/path/to/nixpkgs-fmt' + let g:ale_nix_nixpkgsfmt_options = '-h' + + AssertEqual + \ { + \ 'command': ale#Escape('/path/to/nixpkgs-fmt') + \ . ' -h', + \ }, + \ ale#fixers#nixpkgsfmt#Fix(bufnr('')) diff --git a/test/fixers/test_purty_fixer_callback.vader b/test/fixers/test_purty_fixer_callback.vader new file mode 100644 index 00000000..e83b8c18 --- /dev/null +++ b/test/fixers/test_purty_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_purescript_purty_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_purescript_purty_executable = 'my-special-purty' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The purty callback should return the correct options): + call ale#test#SetFilename('../purescript_files/testfile.purs') + + AssertEqual + \ { + \ 'command': ale#Escape('my-special-purty') + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#purty#Fix(bufnr('')) diff --git a/test/fixers/test_stylelint_fixer_callback.vader b/test/fixers/test_stylelint_fixer_callback.vader index 90a9dc1f..f677cdf7 100644 --- a/test/fixers/test_stylelint_fixer_callback.vader +++ b/test/fixers/test_stylelint_fixer_callback.vader @@ -1,17 +1,33 @@ Before: - call ale#test#SetDirectory('/testplugin/test/fixers') + call ale#assert#SetUpFixerTest('css', 'stylelint') After: - call ale#test#RestoreDirectory() + call ale#assert#TearDownFixerTest() -Execute(The executable path should be correct): +Execute(The stylelint callback should return the correct default values): call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') - AssertEqual + AssertFixer \ { \ 'read_temporary_file': 1, - \ 'command': (has('win32') ? 'node.exe ' : '') + \ 'command': ale#path#CdString(expand('%:p:h')) + \ . (has('win32') ? 'node.exe ' : '') \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) - \ . ' --fix %t', - \ }, - \ ale#fixers#stylelint#Fix(bufnr('')) + \ . ' %t' + \ . ' --fix', + \ } + +Execute(The stylelint callback should include custom stylelint options): + let g:ale_stylelint_options = '--cache' + call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css') + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#path#CdString(expand('%:p:h')) + \ . (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) + \ . ' %t' + \ . ' --cache' + \ . ' --fix', + \ } diff --git a/test/fixers/test_styler_fixer_callback.vader b/test/fixers/test_styler_fixer_callback.vader index 85e45c1d..79f71ba9 100644 --- a/test/fixers/test_styler_fixer_callback.vader +++ b/test/fixers/test_styler_fixer_callback.vader @@ -13,7 +13,7 @@ Execute(The styler callback should include custom styler options): \ { \ 'command': 'Rscript --vanilla -e ' \ . '"suppressPackageStartupMessages(library(styler));' - \ . 'style_file(commandArgs(TRUE), style = ' + \ . 'style_file(commandArgs(TRUE), transformers = ' \ . 'a_custom_option)"' \ . ' %t', \ 'read_temporary_file': 1, diff --git a/test/handler/test_crystal_handler.vader b/test/handler/test_crystal_handler.vader index a7b7f3ab..209632e9 100644 --- a/test/handler/test_crystal_handler.vader +++ b/test/handler/test_crystal_handler.vader @@ -16,3 +16,13 @@ Execute(The crystal handler should parse lines correctly and add the column if i \ ale_linters#crystal#crystal#Handle(255, [ \ '[{"file":"/tmp/test.cr","line":2,"column":1,"size":null,"message":"unexpected token: EOF"}]' \ ]) + +Execute(The crystal handler should not fail when a missing file is required): + AssertEqual + \ [ { 'lnum':1, 'col': 1, 'text': 'while requiring "./nonexistent.cr"' } ], + \ ale_linters#crystal#crystal#Handle(255, + \ json_encode([ + \ { "file":"/tmp/file.cr","line":1,"column":1,"size":0,"message":"while requiring \"./nonexistent.cr\"" }, + \ { "message": "can't find file './nonexistent.cr' relative to '/tmp'" }, + \ ]) + \ ) diff --git a/test/handler/test_debride_handler.vader b/test/handler/test_debride_handler.vader new file mode 100644 index 00000000..62851468 --- /dev/null +++ b/test/handler/test_debride_handler.vader @@ -0,0 +1,27 @@ +Before: + runtime ale_linters/ruby/debride.vim + +After: + call ale#linter#Reset() + +Execute(The debride linter parses output correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'text': 'Possible unused method: image_tags', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 7, + \ 'text': 'Possible unused method: not_deleted', + \ 'type': 'W', + \ } + \ ], + \ ale_linters#ruby#debride#HandleOutput(0, [ + \ 'These methods MIGHT not be called:', + \ '', + \ 'Image', + \ ' image_tags app/models/image.rb:2', + \ ' not_deleted app/models/image.rb:7' + \]) diff --git a/test/handler/test_eslint_json_handler.vader b/test/handler/test_eslint_json_handler.vader index 8e07bd80..6235794a 100644 --- a/test/handler/test_eslint_json_handler.vader +++ b/test/handler/test_eslint_json_handler.vader @@ -21,6 +21,7 @@ After: unlet! g:config_error_lines Execute(The eslint handler should parse json correctly): + call ale#test#SetFilename('foo.js') AssertEqual \ [ \ { @@ -53,6 +54,21 @@ Execute(The eslint handler should parse json correctly): \ '[{"filePath":"foo.js","messages":[{"ruleId":"no-unused-vars","severity":1,"message":"''variable'' is assigned a value but never used.","line":1,"column":7,"nodeType":"Identifier","endLine":1,"endColumn":15},{"ruleId":"semi","severity":1,"message":"Missing semicolon.","line":5,"column":15,"nodeType":"ExpressionStatement","fix":{"range":[46,46],"text":";"}},{"ruleId":"no-redeclare","severity":2,"message":"''variable'' is already defined.","line":7,"column":7,"nodeType":"Identifier","endLine":7,"endColumn":15}],"errorCount":1,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":1,"source":"const variable = {\n a: 3\n};\n\nconsole.log(1)\n\nclass variable {\n}\n"}]' \ ]) +Execute(The eslint handler should suppress deprecation warnings): + call ale#test#SetFilename('foo.js') + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 9, + \ 'text': 'Parsing error: Unexpected token Controller', + \ 'type': 'E', + \ } + \ ], + \ ale#handlers#eslint#HandleJSON(bufnr(''), [ + \ '[{"filePath":"foo.js","messages":[{"ruleId":null,"fatal":true,"severity":2 ,"message":"Parsing error: Unexpected token Controller","line":1,"column":9}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount": 0,"source":"i:mport Controller from \"@ember/controller\";\nimport listViewControllerMixin from \"elearning/mixins/list-view-controller\";\nimport { inject as service } from \"@ember/service\";\n\nexport default Controller.extend(listViewControllerMixin(), {\n modelName: \"notification\",\n intl: service(),\n\n flatpickrLocale: computed(\"intl.locale\", function() {\n return this.intl.locale.firstObject.split(\"-\")[0];\n })\n});\n"}]', '(node:616989) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The ''parserOptions.ecmaFeatures.experimentalObjectRestSpread'' option is deprecated. Use ''parser Options.ecmaVersion'' instead. (found in "node_modules/eslint-plugin-ember/lib/config/base.js")]' + \ ]) + Execute(The eslint handler should print a message about a missing configuration file): let g:config_error_lines = [ \ '', @@ -262,7 +278,7 @@ Execute(Suppressing missing configs shouldn't suppress module import errors): \ ale#handlers#eslint#HandleJSON(bufnr(''), g:config_error_lines[:]) Execute(The eslint handler should hint about using typescript-eslint-parser): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.ts') AssertEqual \ [ @@ -326,7 +342,7 @@ Execute(Failing to connect to eslint_d should be handled correctly): \ ]) Execute(Disabling warnings about trailing spaces should work): - silent! noautocmd file foo.ts + call ale#test#SetFilename('foo.js') AssertEqual \ [ diff --git a/test/handler/test_nim_handler.vader b/test/handler/test_nim_handler.vader index e484000e..b6784d84 100644 --- a/test/handler/test_nim_handler.vader +++ b/test/handler/test_nim_handler.vader @@ -21,6 +21,7 @@ Execute(Parsing nim errors should work): \ 'col': 2, \ 'text': 'identifier expected, but found ''a.barfoo''', \ 'type': 'E', + \ 'end_col': 9, \ }, \ { \ 'lnum': 2, @@ -28,6 +29,7 @@ Execute(Parsing nim errors should work): \ 'text': '''NotUsed'' is declared but not used', \ 'code': 'XDeclaredButNotUsed', \ 'type': 'W', + \ 'end_col': 11, \ }, \ { \ 'lnum': 12, @@ -35,6 +37,35 @@ Execute(Parsing nim errors should work): \ 'text': 'with : character', \ 'type': 'E', \ }, + \ { + \ 'lnum': 1, + \ 'col': 8, + \ 'text': 'imported and not used: ''strutils''', + \ 'code': 'UnusedImport', + \ 'type': 'W', + \ 'end_col': 15, + \ }, + \ { + \ 'lnum': 12, + \ 'col': 9, + \ 'text': 'undeclared identifier: ''total''', + \ 'type': 'E', + \ 'end_col': 13, + \ }, + \ { + \ 'lnum': 14, + \ 'col': 1, + \ 'text': '''sum'' cannot be assigned to', + \ 'type': 'E', + \ 'end_col': 3, + \ }, + \ { + \ 'lnum': 15, + \ 'col': 1, + \ 'text': 'redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', + \ 'type': 'E', + \ 'end_col': 7, + \ }, \ ], \ ale_linters#nim#nimcheck#Handle(bufnr(''), [ \ 'Line with wrong( format)', @@ -42,4 +73,8 @@ Execute(Parsing nim errors should work): \ 'foobar.nim(12, 2) Error: identifier expected, but found ''a.barfoo''', \ '/nested/folder/foobar.nim(2, 5) Hint: ''NotUsed'' is declared but not used [XDeclaredButNotUsed]', \ 'foobar.nim(12, 2) Error: with : character', + \ 'foobar.nim(1, 8) Warning: imported and not used: ''strutils'' [UnusedImport]', + \ 'foobar.nim(12, 9) Error: undeclared identifier: ''total''', + \ 'foobar.nim(14, 1) Error: ''sum'' cannot be assigned to', + \ 'foobar.nim(15, 1) Error: redefinition of ''getName''; previous declaration here: /nested/folder/foobar.nim(14, 6)', \ ]) diff --git a/test/handler/test_tflint_handler.vader b/test/handler/test_tflint_handler.vader index 099d0926..6b8173af 100644 --- a/test/handler/test_tflint_handler.vader +++ b/test/handler/test_tflint_handler.vader @@ -4,7 +4,7 @@ Before: After: call ale#linter#Reset() -Execute(The tflint handler should parse items correctly): +Execute(The tflint handler should parse items correctly for pre 0.11): AssertEqual \ [ \ { @@ -29,3 +29,71 @@ Execute(The tflint handler should parse items correctly): \ ale_linters#terraform#tflint#Handle(123, [ \ '[ { "detector": "aws_db_instance_readable_password", "type": "WARNING", "message": "be warned, traveller", "line": 12, "file": "github.com/wata727/example-module/aws_db_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md" }, { "detector": "aws_elasticache_cluster_invalid_type", "type": "ERROR", "message": "error message", "line": 9, "file": "github.com/wata727/example-module/aws_elasticache_cluster.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md" }, { "detector": "aws_instance_not_specified_iam_profile", "type": "NOTICE", "message": "just so ya know", "line": 5, "file": "github.com/wata727/example-module/aws_instance.tf", "link": "https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md" } ]' \ ]) + +Execute(The tflint handler should parse items correctly): + AssertEqual + \ [ + \ { + \ 'filename': 'github.com/wata727/example-module/aws_instance.tf', + \ 'lnum': 1, + \ 'col': 30, + \ 'end_lnum': 2, + \ 'end_col': 1, + \ 'text': 'A block definition must have block content delimited by "{" and "}", starting on the same line as the block header.', + \ 'code': 'Invalid block definition', + \ 'type': 'E', + \ }, + \ { + \ 'filename': 'github.com/wata727/example-module/aws_instance.tf', + \ 'lnum': 2, + \ 'col': 3, + \ 'end_lnum': 2, + \ 'end_col': 6, + \ 'text': 'An argument named "ami" is not expected here.', + \ 'code': 'Unsupported argument', + \ 'type': 'E', + \ }, + \ { + \ 'filename': 'github.com/wata727/example-module/aws_instance.tf', + \ 'lnum': 3, + \ 'col': 3, + \ 'end_lnum': 1, + \ 'end_col': 6, + \ 'text': 'An argument named "instance_type" is not expected here.', + \ 'code': 'Unsupported argument', + \ 'type': 'E', + \ }, + \ { + \ 'filename': 'github.com/wata727/example-module/aws_db_instance.tf', + \ 'lnum': 12, + \ 'col': 11, + \ 'end_lnum': 12, + \ 'end_col': 21, + \ 'text': 'be warned, traveller', + \ 'code': 'aws_db_instance_readable_password', + \ 'type': 'W', + \ }, + \ { + \ 'filename': 'github.com/wata727/example-module/aws_elasticache_cluster.tf', + \ 'lnum': 9, + \ 'col': 29, + \ 'end_lnum': 9, + \ 'end_col': 29, + \ 'text': 'error message', + \ 'code': 'aws_elasticache_cluster_invalid_type', + \ 'type': 'E', + \ }, + \ { + \ 'filename': 'github.com/wata727/example-module/aws_instance.tf', + \ 'lnum': 5, + \ 'col': 15, + \ 'end_lnum': 5, + \ 'end_col': 25, + \ 'text': 'just so ya know', + \ 'code': 'aws_instance_not_specified_iam_profile', + \ 'type': 'I', + \ }, + \ ], + \ ale_linters#terraform#tflint#Handle(123, [ + \ '{"issues":[{"rule":{"name":"aws_db_instance_readable_password","severity":"WARNING","link":"https://github.com/wata727/tflint/blob/master/docs/aws_db_instance_readable_password.md"},"message":"be warned, traveller","range":{"filename":"github.com/wata727/example-module/aws_db_instance.tf","start":{"line":12,"column":11},"end":{"line":12,"column":21},"callers":[]}},{"rule":{"name":"aws_elasticache_cluster_invalid_type","severity":"ERROR","link":"https://github.com/wata727/tflint/blob/master/docs/aws_elasticache_cluster_invalid_type.md"},"message":"error message","range":{"filename":"github.com/wata727/example-module/aws_elasticache_cluster.tf","start":{"line":9,"column":29},"end":{"line":9,"column":29},"callers":[]}},{"rule":{"name":"aws_instance_not_specified_iam_profile","severity":"NOTICE","link":"https://github.com/wata727/tflint/blob/master/docs/aws_instance_not_specified_iam_profile.md"},"message":"just so ya know","range":{"filename":"github.com/wata727/example-module/aws_instance.tf","start":{"line":5,"column":15},"end":{"line":5,"column":25},"callers":[]}}],"errors":[{"message":"github.com/wata727/example-module/aws_instance.tf:1,30-2,1: Invalid block definition; A block definition must have block content delimited by \"{\" and \"}\", starting on the same line as the block header."},{"message":"github.com/wata727/example-module/aws_instance.tf:2,3-6: Unsupported argument; An argument named \"ami\" is not expected here."},{"message":"github.com/wata727/example-module/aws_instance.tf:3,3-16: Unsupported argument; An argument named \"instance_type\" is not expected here."}]}' + \ ]) diff --git a/test/handler/test_vlog_handler.vader b/test/handler/test_vlog_handler.vader index a70665db..daf3cdcf 100644 --- a/test/handler/test_vlog_handler.vader +++ b/test/handler/test_vlog_handler.vader @@ -4,7 +4,7 @@ Before: After: call ale#linter#Reset() -Execute(The vlog handler should parse lines correctly): +Execute(The vlog handler should parse old-style lines correctly): AssertEqual \ [ \ { @@ -22,3 +22,22 @@ Execute(The vlog handler should parse lines correctly): \ '** Warning: add.v(7): (vlog-2623) Undefined variable: C.', \ '** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C.', \ ]) + +Execute(The vlog handler should parse new-style lines correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 7, + \ 'type': 'W', + \ 'text': '(vlog-2623) Undefined variable: C.' + \ }, + \ { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.' + \ }, + \ ], + \ ale_linters#verilog#vlog#Handle(bufnr(''), [ + \ '** Warning: (vlog-2623) add.v(7): Undefined variable: C.', + \ '** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C.', + \ ]) diff --git a/test/lsp/test_handling_window_requests.vader b/test/lsp/test_handling_window_requests.vader new file mode 100644 index 00000000..551d5975 --- /dev/null +++ b/test/lsp/test_handling_window_requests.vader @@ -0,0 +1,94 @@ +Before: + let g:expr_list = [] + let g:linter_name = 'some_linter' + let g:format = '%severity%:%linter%: %s' + " Get the default value to restore it + let g:default_severity = g:ale_lsp_show_message_severity + let g:ale_lsp_show_message_severity = 'information' + + function! ale#util#ShowMessage(expr) abort + call add(g:expr_list, a:expr) + endfunction + +After: + unlet! g:expr_list + unlet! g:linter_name + unlet! g:format + let g:ale_lsp_show_message_severity = g:default_severity + unlet! g:default_severity + +Execute(ale#lsp_window#HandleShowMessage() should only show errors when severity is set to "error"): + let g:ale_lsp_show_message_severity = 'error' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual ['Error:some_linter: an error'], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors and warnings when severity is set to "warning"): + let g:ale_lsp_show_message_severity = 'warning' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual ['Error:some_linter: an error', 'Warning:some_linter: a warning'], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "information"): + let g:ale_lsp_show_message_severity = 'information' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should only show errors, warnings and infos when severity is set to "info"): + let g:ale_lsp_show_message_severity = 'info' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should show all messages is severity is set to "log"): + let g:ale_lsp_show_message_severity = 'log' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning', + \ 'Info:some_linter: an info', + \ 'Log:some_linter: a log'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should not show anything if severity is configured as disabled): + let g:ale_lsp_show_message_severity = 'disabled' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [], g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should use "warning" when severity is set to an invalid value): + let g:ale_lsp_show_message_severity = 'foo' + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':1,'message':'an error'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':2,'message':'a warning'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':'an info'}) + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':4,'message':'a log'}) + AssertEqual [ + \ 'Error:some_linter: an error', + \ 'Warning:some_linter: a warning'], + \ g:expr_list + +Execute(ale#lsp_window#HandleShowMessage() should escape quotes on messages): + call ale#lsp_window#HandleShowMessage(g:linter_name, g:format, {'type':3,'message':"this is an 'info'"}) + AssertEqual ['Info:some_linter: this is an ''info'''], g:expr_list diff --git a/test/nim-test-files/with-git/src/source.nim b/test/nim-test-files/with-git/src/source.nim new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/nim-test-files/with-git/src/source.nim diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader index bb042679..60ae0a83 100644 --- a/test/sign/test_linting_sets_signs.vader +++ b/test/sign/test_linting_sets_signs.vader @@ -32,7 +32,7 @@ Before: function! CollectSigns() redir => l:output - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) silent exec 'sign place group=ale' else silent exec 'sign place' diff --git a/test/sign/test_sign_parsing.vader b/test/sign/test_sign_parsing.vader index 8fb7f8e0..157ff2f4 100644 --- a/test/sign/test_sign_parsing.vader +++ b/test/sign/test_sign_parsing.vader @@ -1,5 +1,5 @@ Execute (Parsing English signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[9, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([ @@ -16,7 +16,7 @@ Execute (Parsing English signs should work): endif Execute (Parsing Russian signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign']) @@ -27,7 +27,7 @@ Execute (Parsing Russian signs should work): endif Execute (Parsing Japanese signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign']) @@ -38,7 +38,7 @@ Execute (Parsing Japanese signs should work): endif Execute (Parsing Spanish signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[12, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign']) @@ -49,7 +49,7 @@ Execute (Parsing Spanish signs should work): endif Execute (Parsing Italian signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[1, 1000001, 'ALEWarningSign']]], \ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign']) @@ -60,7 +60,7 @@ Execute (Parsing Italian signs should work): endif Execute (Parsing German signs should work): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [0, [[235, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign']) @@ -71,7 +71,7 @@ Execute (Parsing German signs should work): endif Execute (The sign parser should indicate if the dummy sign is set): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) AssertEqual \ [1, [[1, 1000001, 'ALEErrorSign']]], \ ale#sign#ParseSigns([ diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 97bd9302..80153b22 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -68,7 +68,7 @@ Before: function! ParseSigns() redir => l:output - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) silent sign place group=ale else silent sign place @@ -152,7 +152,7 @@ Execute(The current signs should be set for running a job): \ ParseSigns() Execute(Loclist items with sign_id values should be kept): - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('') @@ -297,7 +297,7 @@ Execute(No exceptions should be thrown when setting signs for invalid buffers): Execute(Signs should be removed when lines have multiple sign IDs on them): " We can fail to remove signs if there are multiple signs on one line, " say after deleting lines in Vim, etc. - if has('nvim-0.4.0') || (v:version >= 801 && has('patch614')) + if has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('') exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('') exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('') diff --git a/test/test_ale_has.vader b/test/test_ale_has.vader index b2df01fe..b8a99103 100644 --- a/test/test_ale_has.vader +++ b/test/test_ale_has.vader @@ -1,4 +1,5 @@ Execute(Checks for versions below the current version should succeed): + AssertEqual 1, ale#Has('ale-2.6.0') AssertEqual 1, ale#Has('ale-2.5.0') AssertEqual 1, ale#Has('ale-2.4.0') AssertEqual 1, ale#Has('ALE-2.2.1') diff --git a/test/test_nimlsp_project_root.vader b/test/test_nimlsp_project_root.vader new file mode 100644 index 00000000..e7027575 --- /dev/null +++ b/test/test_nimlsp_project_root.vader @@ -0,0 +1,19 @@ +Before: + runtime ale_linters/nim/nimlsp.vim + call ale#test#SetDirectory('/testplugin/test') + +After: + if isdirectory(g:dir . '/.git') + call delete(g:dir . '/.git', 'd') + endif + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + + +Execute(Detect root of nim project with .git/ correctly): + call ale#test#SetFilename('nim-test-files/with-git/src/source.nim') + call mkdir(g:dir . '/.git') + AssertEqual + \ ale#path#Simplify(g:dir), + \ ale_linters#nim#nimlsp#GetProjectRoot(bufnr('')) |