summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/highlight.vim28
-rw-r--r--doc/ale.txt13
-rw-r--r--test/test_highlight_placement.vader23
3 files changed, 59 insertions, 5 deletions
diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim
index 4ac1d1e4..60ae393e 100644
--- a/autoload/ale/highlight.vim
+++ b/autoload/ale/highlight.vim
@@ -6,10 +6,22 @@ if !hlexists('ALEError')
highlight link ALEError SpellBad
endif
+if !hlexists('ALEStyleError')
+ highlight link ALEStyleError ALEError
+endif
+
if !hlexists('ALEWarning')
highlight link ALEWarning SpellCap
endif
+if !hlexists('ALEStyleWarning')
+ highlight link ALEStyleWarning ALEWarning
+endif
+
+if !hlexists('ALEInfo')
+ highlight link ALEInfo ALEWarning
+endif
+
" This map holds highlights to be set when buffers are opened.
" We can only set highlights for whatever the current buffer is, so we will
" wait until the buffer is entered again to show the highlights, unless
@@ -84,7 +96,21 @@ function! ale#highlight#UpdateHighlights() abort
if g:ale_enabled
for l:item in l:loclist
let l:col = l:item.col
- let l:group = l:item.type ==# 'E' ? 'ALEError' : 'ALEWarning'
+
+ if l:item.type ==# 'W'
+ if get(l:item, 'sub_type', '') ==# 'style'
+ let l:group = 'ALEStyleWarning'
+ else
+ let l:group = 'ALEWarning'
+ endif
+ elseif l:item.type ==# 'I'
+ let l:group = 'ALEInfo'
+ elseif get(l:item, 'sub_type', '') ==# 'style'
+ let l:group = 'ALEStyleError'
+ else
+ let l:group = 'ALEError'
+ endif
+
let l:line = l:item.lnum
let l:size = has_key(l:item, 'end_col') ? l:item.end_col - l:col + 1 : 1
diff --git a/doc/ale.txt b/doc/ale.txt
index 3331ba21..56642c2d 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -507,10 +507,15 @@ g:ale_set_highlights *g:ale_set_highlights*
Type: |Number|
Default: `has('syntax')`
- When this option is set to `1`, highlights will be set in for erros and
- warnings. The `ALEError` and `ALEWarning` highlight groups will be used to
- provide highlights, and default to linking to `SpellBad` and `SpellCap`
- respectively by default.
+ When this option is set to `1`, highlights will be set for problems.
+
+ ALE will use the following highlight groups for problems:
+
+ `ALEError` - Items with `'type': 'E'`
+ `ALEWarning` - Items with `'type': 'W'`
+ `ALEInfo` - Items with `'type': 'I'`
+ `ALEStyleError` - Items with `'type': 'E'` and `'sub_type': 'style'`
+ `ALEStyleWarning` - Items with `'type': 'W'` and `'sub_type': 'style'`
g:ale_set_loclist *g:ale_set_loclist*
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index b5878922..454f6209 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -150,3 +150,26 @@ Execute(Higlight end columns should set an appropriate size):
\ {'group': 'ALEWarning', 'id': 16, 'priority': 10, 'pos1': [4, 1, 5]},
\ ],
\ getmatches()
+
+Execute(Higlight end columns should set an appropriate size):
+ call ale#highlight#SetHighlights(bufnr('%'), [
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 1, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 2, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'E', 'sub_type': 'style', 'lnum': 3, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 4, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 5, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'W', 'sub_type': 'style', 'lnum': 6, 'col': 1},
+ \ {'bufnr': bufnr('%'), 'type': 'I', 'lnum': 7, 'col': 1},
+ \])
+
+ AssertEqual
+ \ [
+ \ {'group': 'ALEError', 'id': 17, 'priority': 10, 'pos1': [1, 1, 1]},
+ \ {'group': 'ALEError', 'id': 18, 'priority': 10, 'pos1': [2, 1, 1]},
+ \ {'group': 'ALEStyleError', 'id': 19, 'priority': 10, 'pos1': [3, 1, 1]},
+ \ {'group': 'ALEWarning', 'id': 20, 'priority': 10, 'pos1': [4, 1, 1]},
+ \ {'group': 'ALEWarning', 'id': 21, 'priority': 10, 'pos1': [5, 1, 1]},
+ \ {'group': 'ALEStyleWarning', 'id': 22, 'priority': 10, 'pos1': [6, 1, 1]},
+ \ {'group': 'ALEInfo', 'id': 23, 'priority': 10, 'pos1': [7, 1, 1]},
+ \ ],
+ \ getmatches()