summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-03-11 12:52:41 -0400
committerw0rp <devw0rp@gmail.com>2020-03-11 12:52:41 -0400
commitbbe5153fcb36dec9860ced33ae8ff0b5d76ac02a (patch)
treefcf15f5db23f06ed91371481c4f09470a47c8e35
parent8f7ccdc5e95302223c516a0113f5af7e075dc041 (diff)
downloadale-bbe5153fcb36dec9860ced33ae8ff0b5d76ac02a.zip
Fixes #2982 - Implement g:ale_exclude_highlights
Particular highlights can now be excluded by providing Lists of regular expressions.
-rw-r--r--autoload/ale/highlight.vim6
-rw-r--r--doc/ale.txt17
-rw-r--r--plugin/ale.vim3
-rw-r--r--test/test_highlight_placement.vader21
4 files changed, 47 insertions, 0 deletions
diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim
index 82ad57e0..473ad354 100644
--- a/autoload/ale/highlight.vim
+++ b/autoload/ale/highlight.vim
@@ -210,6 +210,12 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort
" Set the list in the buffer variable.
call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list)
+ let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights')
+
+ if !empty(l:exclude_list)
+ call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))')
+ endif
+
" Update highlights for the current buffer, which may or may not
" be the buffer we just set highlights for.
call ale#highlight#UpdateHighlights()
diff --git a/doc/ale.txt b/doc/ale.txt
index 0d92d6d9..da4328d9 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -923,6 +923,21 @@ g:ale_enabled *g:ale_enabled*
See |g:ale_pattern_options| for more information on that option.
+g:ale_exclude_highlights *g:ale_exclude_highlights*
+b:ale_exclude_highlights *b:ale_exclude_highlights*
+
+ Type: |List|
+ Default: `[]`
+
+ A list of regular expressions for matching against highlight messages to
+ remove. For example: >
+
+ " Do not highlight messages matching strings like these.
+ let b:ale_exclude_highlights = ['line too long', 'foo.*bar']
+<
+ See also: |g:ale_set_highlights|
+
+
g:ale_fixers *g:ale_fixers*
*b:ale_fixers*
@@ -1609,6 +1624,8 @@ g:ale_set_highlights *g:ale_set_highlights*
match highlights, whereas the line highlights when signs are enabled will
run to the edge of the screen.
+ Highlights can be excluded with the |g:ale_exclude_highlights| option.
+
g:ale_set_loclist *g:ale_set_loclist*
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 8fea3bb4..19c86ea6 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -109,6 +109,9 @@ let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs'))
" This flag can be set to 0 to disable setting error highlights.
let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax'))
+" This List can be configured to exclude particular highlights.
+let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', [])
+
" This flag can be set to 0 to disable echoing when the cursor moves.
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index 3b259655..dab73073 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -7,6 +7,8 @@ Before:
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_set_signs
+ Save g:ale_exclude_highlights
+ Save b:ale_exclude_highlights
runtime autoload/ale/highlight.vim
@@ -20,6 +22,8 @@ Before:
let g:ale_set_quickfix = 0
let g:ale_set_loclist = 0
let g:ale_echo_cursor = 0
+ let g:ale_exclude_highlights = []
+ let b:ale_exclude_highlights = []
function! GenerateResults(buffer, output)
return [
@@ -363,6 +367,23 @@ Execute(Highlights should always be cleared when the buffer highlight list is em
\ GetMatchesWithoutIDs()
endif
+Execute(Highlights should be hidden when excluded):
+ let b:ale_exclude_highlights = ['ig.*ore', 'nope']
+
+ call ale#highlight#SetHighlights(bufnr('%'), [
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 1, 'col': 1, 'text': 'hello'},
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 2, 'col': 1, 'text': 'ignore'},
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 1, 'text': 'nope'},
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 4, 'col': 1, 'text': 'world'},
+ \])
+
+ AssertEqual
+ \ [
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [1, 1, 1]},
+ \ {'group': 'ALEError', 'priority': 10, 'pos1': [4, 1, 1]},
+ \ ],
+ \ GetMatchesWithoutIDs()
+
Execute(Highlights should be cleared when ALE is disabled):
let g:ale_enabled = 1
call ale#highlight#SetHighlights(bufnr(''), [