diff --git a/after/plugin/ale.vim b/after/plugin/ale.vim index 463b65a..d738dbd 100644 --- a/after/plugin/ale.vim +++ b/after/plugin/ale.vim @@ -1,13 +1,22 @@ +" Author: w0rp +" Description: Follow-up checks for the plugin: warn about conflicting plugins. + +" A flag for ensuring that this is not run more than one time. if exists('g:loaded_ale_after') finish endif +" Set the flag so this file is not run more than one time. let g:loaded_ale_after = 1 -if !g:ale_emit_conflict_warnings +" Check if the flag is available and set to 0 to disable checking for and +" emitting conflicting plugin warnings. +if exists('g:ale_emit_conflict_warnings') && !g:ale_emit_conflict_warnings finish endif +" Conflicting Plugins Checks + function! s:GetConflictingPluginWarning(plugin_name) abort return 'ALE conflicts with ' . a:plugin_name \ . '. Uninstall it, or disable this warning with ' diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index 44ab568..0a6807b 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -17,7 +17,6 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort let l:text = l:match[1] - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[3] + 0, diff --git a/ale_linters/coffee/coffeelint.vim b/ale_linters/coffee/coffeelint.vim index e32f7b7..614f45a 100644 --- a/ale_linters/coffee/coffeelint.vim +++ b/ale_linters/coffee/coffeelint.vim @@ -32,15 +32,12 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort endif let l:line = l:match[1] + 0 - let l:column = 1 let l:type = l:match[3] ==# 'error' ? 'E' : 'W' let l:text = l:match[4] - " vcol is needed to indicate that the column is a character call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, - \ 'col': l:column, \ 'text': l:text, \ 'type': l:type, \}) diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim index bf3d3d3..45565d0 100644 --- a/ale_linters/d/dmd.vim +++ b/ale_linters/d/dmd.vim @@ -68,7 +68,6 @@ function! ale_linters#d#dmd#Handle(buffer, lines) abort let l:type = l:match[3] let l:text = l:match[4] - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': bufnr('%'), \ 'lnum': l:line, diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim index f82cb8a..d0789ae 100644 --- a/ale_linters/dockerfile/hadolint.vim +++ b/ale_linters/dockerfile/hadolint.vim @@ -23,7 +23,6 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort let l:type = 'W' let l:text = l:match[3] - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:lnum, diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index 8ce1242..06c2a91 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -23,7 +23,6 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort let l:type = 'W' endif - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim index 871d4c8..d6adf12 100644 --- a/ale_linters/erlang/erlc.vim +++ b/ale_linters/erlang/erlc.vim @@ -73,7 +73,6 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort let l:type = 'E' endif - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim index 6a907ab..77952cf 100644 --- a/ale_linters/haskell/hlint.vim +++ b/ale_linters/haskell/hlint.vim @@ -7,7 +7,6 @@ function! ale_linters#haskell#hlint#Handle(buffer, lines) abort let l:output = [] for l:error in l:errors - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:error.startLine + 0, diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim index de873c8..9067f9d 100644 --- a/ale_linters/html/tidy.vim +++ b/ale_linters/html/tidy.vim @@ -49,7 +49,6 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort let l:type = l:match[3] ==# 'Error' ? 'E' : 'W' let l:text = l:match[4] - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim index 5652d9d..9df9577 100644 --- a/ale_linters/java/javac.vim +++ b/ale_linters/java/javac.vim @@ -34,7 +34,6 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, - \ 'col': 1, \ 'text': l:match[2] . ':' . l:match[3], \ 'type': l:match[2] ==# 'error' ? 'E' : 'W', \}) diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index ac88dd0..4b4660b 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -76,7 +76,6 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines) abort let l:text .= ' [' . l:match[4] . ']' endif - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index 1232b65..891de83 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -47,7 +47,6 @@ function! ale_linters#javascript#standard#Handle(buffer, lines) abort let l:type = 'Error' let l:text = l:match[3] - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, diff --git a/ale_linters/json/jsonlint.vim b/ale_linters/json/jsonlint.vim index e1fb2bd..83e74c7 100644 --- a/ale_linters/json/jsonlint.vim +++ b/ale_linters/json/jsonlint.vim @@ -14,7 +14,6 @@ function! ale_linters#json#jsonlint#Handle(buffer, lines) abort continue endif - " vcol is needed to indicate that the column is a character call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim index c4c79b1..e208c93 100644 --- a/ale_linters/lua/luacheck.vim +++ b/ale_linters/lua/luacheck.vim @@ -19,7 +19,6 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort continue endif - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim index 563cf19..775d431 100644 --- a/ale_linters/matlab/mlint.vim +++ b/ale_linters/matlab/mlint.vim @@ -40,7 +40,6 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort continue endif - " vcol is needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:lnum, diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 9d24ed9..23586a7 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -29,15 +29,12 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort endif let l:line = l:match[3] - let l:column = 1 let l:text = l:match[1] let l:type = 'E' - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, - \ 'col': l:column, \ 'text': l:text, \ 'type': l:type, \}) diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index f146085..8f31e51 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -13,15 +13,12 @@ function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort endif let l:line = l:match[3] - let l:column = 1 let l:text = l:match[1] let l:type = 'E' - " vcol is Needed to indicate that the column is a character. call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, - \ 'col': l:column, \ 'text': l:text, \ 'type': l:type, \}) diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index 6edc66b..3f354de 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -1,11 +1,11 @@ -" Author: Spencer Wood +" Author: Spencer Wood , Adriaan Zonnenberg " Description: This file adds support for checking PHP with php-cli function! ale_linters#php#php#Handle(buffer, lines) abort " Matches patterns like the following: " " PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 15 - let l:pattern = '\vParse error:\s+(.+unexpected ''(.+)%(expecting.+)@= 0 + \ || (exists('*getcmdwintype') && !empty(getcmdwintype())) \ || ale#util#InSandbox() endfunction diff --git a/autoload/ale/cleanup.vim b/autoload/ale/cleanup.vim index 3b0b1d9..8b6494e 100644 --- a/autoload/ale/cleanup.vim +++ b/autoload/ale/cleanup.vim @@ -13,6 +13,7 @@ function! ale#cleanup#Buffer(buffer) abort " Clear delayed highlights for a buffer being removed. if g:ale_set_highlights call ale#highlight#UnqueueHighlights(a:buffer) + call ale#highlight#RemoveHighlights([]) endif call remove(g:ale_buffer_info, a:buffer) diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index 8d70ead..8ff5120 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -46,18 +46,25 @@ function! s:GetCurrentMatchIDs(loclist) abort return l:current_id_map endfunction +" Given a loclist for current items to highlight, remove all highlights +" except these which have matching loclist item entries. +function! ale#highlight#RemoveHighlights(loclist) abort + let l:current_id_map = s:GetCurrentMatchIDs(a:loclist) + + for l:match in s:GetALEMatches() + if !has_key(l:current_id_map, l:match.id) + call matchdelete(l:match.id) + endif + endfor +endfunction + function! ale#highlight#UpdateHighlights() abort let l:buffer = bufnr('%') let l:has_new_items = has_key(s:buffer_highlights, l:buffer) let l:loclist = l:has_new_items ? remove(s:buffer_highlights, l:buffer) : [] - let l:current_id_map = s:GetCurrentMatchIDs(l:loclist) if l:has_new_items || !g:ale_enabled - for l:match in s:GetALEMatches() - if !has_key(l:current_id_map, l:match.id) - call matchdelete(l:match.id) - endif - endfor + call ale#highlight#RemoveHighlights(l:loclist) endif " Remove anything with a current match_id diff --git a/test/handler/test_coffeelint_handler.vader b/test/handler/test_coffeelint_handler.vader index 2d56e7c..1037022 100644 --- a/test/handler/test_coffeelint_handler.vader +++ b/test/handler/test_coffeelint_handler.vader @@ -6,7 +6,6 @@ Execute(The coffeelint handler should parse lines correctly): \ { \ 'bufnr': 347, \ 'lnum': 125, - \ 'col': 1, \ 'text': "Line exceeds maximum allowed length Length is 122, max is 120.", \ 'type': 'E', \ }, diff --git a/test/handler/test_php_handler.vader b/test/handler/test_php_handler.vader index bf6d45c..e7c5dc2 100644 --- a/test/handler/test_php_handler.vader +++ b/test/handler/test_php_handler.vader @@ -3,6 +3,7 @@ Given (Some invalid lines of PHP): class Foo { / } $foo) ['foo' 'bar'] + function count() {} Execute(The php handler should parse lines correctly): runtime ale_linters/php/php.vim @@ -39,6 +40,13 @@ Execute(The php handler should parse lines correctly): \ }, \ { \ 'bufnr': 347, + \ 'lnum': 5, + \ 'col': 0, + \ 'text': "Cannot redeclare count()", + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, \ 'lnum': 21, \ 'col': 0, \ 'text': "syntax error, unexpected end of file", @@ -54,10 +62,12 @@ Execute(The php handler should parse lines correctly): \ ], \ ale_linters#php#php#Handle(347, [ \ 'This line should be ignored completely', + \ "Parse error: syntax error, This line should be ignored completely in - on line 1", \ "PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 1", \ "PHP Parse error: syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST) in - on line 2", \ "PHP Parse error: syntax error, unexpected ')' in - on line 3", \ "PHP Parse error: syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in - on line 4", + \ "PHP Fatal error: Cannot redeclare count() in - on line 5", \ 'PHP Parse error: syntax error, unexpected end of file in - on line 21', \ 'PHP Parse error: Invalid numeric literal in - on line 47', \ ]) diff --git a/test/handler/test_shell_handler.vader b/test/handler/test_shell_handler.vader new file mode 100644 index 0000000..1250682 --- /dev/null +++ b/test/handler/test_shell_handler.vader @@ -0,0 +1,53 @@ +After: + call ale#linter#Reset() + +Execute(The shell handler should parse lines correctly): + runtime ale_linters/sh/shell.vim + + AssertEqual + \ [ + \ { + \ 'bufnr': 347, + \ 'lnum': 13, + \ 'text': 'syntax error near unexpected token d', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 7, + \ 'text': 'line 42: line 36:', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 11, + \ 'text': 'Syntax error: "(" unexpected', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 95, + \ 'text': 'parse error near `out=$(( $1 / 1024. )...', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 22, + \ 'text': ':11: :33: :44:', + \ 'type': 'E', + \ }, + \ { + \ 'bufnr': 347, + \ 'lnum': 9, + \ 'text': '`done'' unexpected', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#sh#shell#Handle(347, [ + \ 'bash: line 13: syntax error near unexpected token d', + \ 'bash: line 7: line 42: line 36:', + \ 'sh: 11: Syntax error: "(" unexpected', + \ 'qfm:95: parse error near `out=$(( $1 / 1024. )...', + \ 'qfm:22: :11: :33: :44:', + \ 'foo.sh: syntax error at line 9: `done'' unexpected', + \ ]) diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader index 52e861d..bca7bfd 100644 --- a/test/test_highlight_placement.vader +++ b/test/test_highlight_placement.vader @@ -74,3 +74,20 @@ Execute(Existing highlights should be kept): \ {'group': 'ALEWarning', 'id': 8, 'priority': 10, 'pos1': [4, 1, 1]}, \ ], \ getmatches() + +" This test is important for preventing ALE from showing highlights for +" the wrong files. +Execute(Highlights set by ALE should be removed when buffer cleanup is done): + call ale#engine#InitBufferInfo(bufnr('%')) + + call ale#highlight#SetHighlights(bufnr('%'), [ + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2}, + \]) + + AssertEqual + \ [{'group': 'ALEError', 'id': 9, 'priority': 10, 'pos1': [3, 2, 1]}], + \ getmatches() + + call ale#cleanup#Buffer(bufnr('%')) + + AssertEqual [], getmatches() diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader index 303a02f..2f1044d 100644 --- a/test/test_history_saving.vader +++ b/test/test_history_saving.vader @@ -1,4 +1,8 @@ Before: + " Temporarily set the shell to /bin/sh, if it isn't already set that way. + " This will make it so the test works when running it directly. + let g:current_shell = &shell + let &shell = '/bin/sh' let g:history = [] let g:ale_buffer_info = {} let g:ale_max_buffer_history_size = 20 @@ -16,6 +20,9 @@ Before: \}) After: + " Reset the shell back to what it was before. + let &shell = g:current_shell + unlet g:current_shell let g:ale_history_enabled = 1 let g:ale_history_log_output = 0 unlet g:history @@ -37,7 +44,7 @@ Execute(History should be set when commands are run): AssertEqual 1, len(g:history) AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0])) - AssertEqual ['/bin/bash', '-c', 'echo command history test'], g:history[0].command + AssertEqual ['/bin/sh', '-c', 'echo command history test'], g:history[0].command AssertEqual 'finished', g:history[0].status AssertEqual 0, g:history[0].exit_code " The Job ID will change each time, but we can check the type. diff --git a/test/vimrc b/test/vimrc index ef67884..57af7e1 100644 --- a/test/vimrc +++ b/test/vimrc @@ -7,6 +7,8 @@ set runtimepath=/home/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/testplu " The following is just an example filetype plugin indent on syntax on +set shell=/bin/sh +set shellcmdflag=-c set nocompatible set tabstop=4 set softtabstop=4