diff options
-rw-r--r-- | ale_linters/asm/gcc.vim | 12 | ||||
-rw-r--r-- | ale_linters/eruby/erb.vim | 2 | ||||
-rw-r--r-- | ale_linters/eruby/erubis.vim | 2 | ||||
-rw-r--r-- | autoload/ale/highlight.vim | 16 | ||||
-rw-r--r-- | doc/ale-asm.txt | 8 | ||||
-rw-r--r-- | doc/ale.txt | 26 | ||||
-rw-r--r-- | test/command_callback/test_asm_gcc_command_callbacks.vader | 39 | ||||
-rw-r--r-- | test/command_callback/test_erb_command_callback.vader | 2 | ||||
-rw-r--r-- | test/command_callback/test_erubis_command_callback.vader | 2 | ||||
-rw-r--r-- | test/test_highlight_placement.vader | 21 |
10 files changed, 120 insertions, 10 deletions
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim index 39b1f7c2..4ac876f8 100644 --- a/ale_linters/asm/gcc.vim +++ b/ale_linters/asm/gcc.vim @@ -1,10 +1,16 @@ " Author: Lucas Kolstad <lkolstad@uw.edu> " Description: gcc linter for asm files -let g:ale_asm_gcc_options = get(g:, 'ale_asm_gcc_options', '-Wall') +call ale#Set('asm_gcc_executable', 'gcc') +call ale#Set('asm_gcc_options', '-Wall') + +function! ale_linters#asm#gcc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'asm_gcc_executable') +endfunction function! ale_linters#asm#gcc#GetCommand(buffer) abort - return 'gcc -x assembler -fsyntax-only ' + return ale#Escape(ale_linters#asm#gcc#GetExecutable(a:buffer)) + \ . ' -x assembler -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' endfunction @@ -27,7 +33,7 @@ endfunction call ale#linter#Define('asm', { \ 'name': 'gcc', \ 'output_stream': 'stderr', -\ 'executable': 'gcc', +\ 'executable_callback': 'ale_linters#asm#gcc#GetExecutable', \ 'command_callback': 'ale_linters#asm#gcc#GetCommand', \ 'callback': 'ale_linters#asm#gcc#Handle', \}) diff --git a/ale_linters/eruby/erb.vim b/ale_linters/eruby/erb.vim index 5d0b4003..65de18ee 100644 --- a/ale_linters/eruby/erb.vim +++ b/ale_linters/eruby/erb.vim @@ -11,7 +11,7 @@ function! ale_linters#eruby#erb#GetCommand(buffer) abort " Rails-flavored eRuby does not comply with the standard as understood by " ERB, so we'll have to do some substitution. This does not reduce the " effectiveness of the linter—the translated code is still evaluated. - return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . ' | ruby -c' + return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c' endfunction call ale#linter#Define('eruby', { diff --git a/ale_linters/eruby/erubis.vim b/ale_linters/eruby/erubis.vim index ac356aeb..c9c8ac1e 100644 --- a/ale_linters/eruby/erubis.vim +++ b/ale_linters/eruby/erubis.vim @@ -11,7 +11,7 @@ function! ale_linters#eruby#erubis#GetCommand(buffer) abort " Rails-flavored eRuby does not comply with the standard as understood by " Erubis, so we'll have to do some substitution. This does not reduce the " effectiveness of the linter—the translated code is still evaluated. - return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . ' | ruby -c' + return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c' endfunction call ale#linter#Define('eruby', { diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index 47256f0b..e3c749fb 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -91,6 +91,22 @@ function! ale#highlight#UpdateHighlights() abort \ 'matchaddpos(l:group, v:val)' \) endfor + + " If highlights are enabled and signs are not enabled, we should still + " offer line highlights by adding a separate set of highlights. + if !g:ale_set_signs + for l:item in l:item_list + if l:item.type is# 'W' + let l:group = 'ALEWarningLine' + elseif l:item.type is# 'I' + let l:group = 'ALEInfoLine' + else + let l:group = 'ALEErrorLine' + endif + + call matchaddpos(l:group, [l:item.lnum]) + endfor + endif endfunction function! ale#highlight#BufferHidden(buffer) abort diff --git a/doc/ale-asm.txt b/doc/ale-asm.txt index 63b5441f..a97c6d00 100644 --- a/doc/ale-asm.txt +++ b/doc/ale-asm.txt @@ -5,6 +5,14 @@ ALE ASM Integration *ale-asm-options* =============================================================================== gcc *ale-asm-gcc* +g:ale_asm_gcc_executable *g:ale_asm_gcc_executable* + *b:ale_asm_gcc_executable* + Type: |String| + Default: `'gcc'` + +This variable can be changed to use a different executable for gcc. + + g:ale_asm_gcc_options *g:ale_asm_gcc_options* *b:ale_asm_gcc_options* Type: |String| diff --git a/doc/ale.txt b/doc/ale.txt index 4fb71004..04f187dc 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -1150,6 +1150,17 @@ g:ale_set_highlights *g:ale_set_highlights* |ALEStyleError| - Items with `'type': 'E'` and `'sub_type': 'style'` |ALEStyleWarning| - Items with `'type': 'W'` and `'sub_type': 'style'` + When |g:ale_set_signs| is set to `0`, the following highlights for entire + lines will be set. + + |ALEErrorLine| - All items with `'type': 'E'` + |ALEWarningLine| - All items with `'type': 'W'` + |ALEInfoLine| - All items with `'type': 'I'` + + Vim can only highlight the characters up to the last column in a buffer for + match highlights, whereas the line highlights when signs are enabled will + run to the edge of the screen. + g:ale_set_loclist *g:ale_set_loclist* @@ -1367,7 +1378,10 @@ ALEErrorLine *ALEErrorLine* Default: Undefined - The highlight for lines where error signs appear. See |g:ale_set_signs|. + The highlight for an entire line where errors appear. Only the first + line for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. ALEErrorSign *ALEErrorSign* @@ -1395,7 +1409,10 @@ ALEInfoLine *ALEInfoLine* Default: Undefined - The highlight for lines where info signs appear. See |g:ale_set_signs|. + The highlight for entire lines where info messages appear. Only the first + line for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. ALEStyleError *ALEStyleError* @@ -1437,7 +1454,10 @@ ALEWarningLine *ALEWarningLine* Default: Undefined - The highlight for lines where warning signs appear. See |g:ale_set_signs|. + The highlight for entire lines where warnings appear. Only the first line + for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. ALEWarningSign *ALEWarningSign* diff --git a/test/command_callback/test_asm_gcc_command_callbacks.vader b/test/command_callback/test_asm_gcc_command_callbacks.vader new file mode 100644 index 00000000..ce8b906a --- /dev/null +++ b/test/command_callback/test_asm_gcc_command_callbacks.vader @@ -0,0 +1,39 @@ +Before: + Save g:ale_asm_gcc_executable + Save g:ale_asm_gcc_options + + unlet! g:ale_asm_gcc_executable + unlet! b:ale_asm_gcc_executable + unlet! g:ale_asm_gcc_options + unlet! b:ale_asm_gcc_options + + runtime ale_linters/asm/gcc.vim + + let b:command_tail = ' -x assembler -fsyntax-only -iquote' + \ . ' ' . ale#Escape(getcwd()) + \ . ' -Wall -' + +After: + Restore + unlet! b:command_tail + unlet! b:ale_asm_gcc_executable + unlet! b:ale_asm_gcc_options + call ale#linter#Reset() + +Execute(The executable should be configurable): + AssertEqual 'gcc', ale_linters#asm#gcc#GetExecutable(bufnr('')) + + let b:ale_asm_gcc_executable = 'foobar' + + AssertEqual 'foobar', ale_linters#asm#gcc#GetExecutable(bufnr('')) + +Execute(The executable should be used in the command): + AssertEqual + \ ale#Escape('gcc') . b:command_tail, + \ ale_linters#asm#gcc#GetCommand(bufnr('')) + + let b:ale_asm_gcc_executable = 'foobar' + + AssertEqual + \ ale#Escape('foobar') . b:command_tail, + \ ale_linters#asm#gcc#GetCommand(bufnr('')) diff --git a/test/command_callback/test_erb_command_callback.vader b/test/command_callback/test_erb_command_callback.vader index 2cfff7ed..9b1d223c 100644 --- a/test/command_callback/test_erb_command_callback.vader +++ b/test/command_callback/test_erb_command_callback.vader @@ -17,5 +17,5 @@ Execute(Executable should filter invalid eRuby when inside a Rails project): call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') AssertEqual - \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . ' | ruby -c', + \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c', \ ale_linters#eruby#erb#GetCommand(bufnr('')) diff --git a/test/command_callback/test_erubis_command_callback.vader b/test/command_callback/test_erubis_command_callback.vader index 68624ec6..574dd684 100644 --- a/test/command_callback/test_erubis_command_callback.vader +++ b/test/command_callback/test_erubis_command_callback.vader @@ -17,5 +17,5 @@ Execute(Executable should filter invalid eRuby when inside a Rails project): call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb') AssertEqual - \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . ' | ruby -c', + \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c', \ ale_linters#eruby#erubis#GetCommand(bufnr('')) diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader index 6a84e571..725faff4 100644 --- a/test/test_highlight_placement.vader +++ b/test/test_highlight_placement.vader @@ -1,5 +1,6 @@ Before: Save g:ale_enabled + Save g:ale_set_signs function! GenerateResults(buffer, output) return [ @@ -258,3 +259,23 @@ Execute(Highlights should be cleared when ALE is disabled): call ale#highlight#UpdateHighlights() AssertEqual [], GetMatchesWithoutIDs() + +Execute(Line highlights should be set when signs are disabled): + let g:ale_set_signs = 0 + + call ale#highlight#SetHighlights(bufnr(''), [ + \ {'bufnr': bufnr(''), 'type': 'E', 'lnum': 1, 'col': 1}, + \ {'bufnr': bufnr(''), 'type': 'W', 'lnum': 2, 'col': 1}, + \ {'bufnr': bufnr(''), 'type': 'I', 'lnum': 3, 'col': 1}, + \]) + + AssertEqual + \ [ + \ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]}, + \ {'group': 'ALEWarning', 'priority': 10, 'pos1': [2, 1, 1]}, + \ {'group': 'ALEInfo', 'priority': 10, 'pos1': [3, 1, 1]}, + \ {'group': 'ALEErrorLine', 'priority': 10, 'pos1': [1]}, + \ {'group': 'ALEWarningLine', 'priority': 10, 'pos1': [2]}, + \ {'group': 'ALEInfoLine', 'priority': 10, 'pos1': [3]}, + \ ], + \ GetMatchesWithoutIDs() |