summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/sign.vim32
-rw-r--r--doc/ale.txt15
-rw-r--r--plugin/ale.vim4
-rw-r--r--test/sign/test_sign_column_highlighting.vader22
4 files changed, 73 insertions, 0 deletions
diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim
index f16153f8..521d7c30 100644
--- a/autoload/ale/sign.vim
+++ b/autoload/ale/sign.vim
@@ -24,6 +24,24 @@ if !hlexists('ALEInfoSign')
highlight link ALEInfoSign ALEWarningSign
endif
+if !hlexists('ALESignColumnWithErrors')
+ highlight link ALESignColumnWithErrors error
+endif
+
+if !hlexists('ALESignColumnWithoutErrors')
+ function! s:SetSignColumnWithoutErrorsHighlight() abort
+ redir => l:output
+ silent highlight SignColumn
+ redir end
+
+ execute 'highlight ALESignColumnWithoutErrors '
+ \ . join(split(l:output)[2:])
+ endfunction
+
+ call s:SetSignColumnWithoutErrorsHighlight()
+ delfunction s:SetSignColumnWithoutErrorsHighlight
+endif
+
" Signs show up on the left for error markers.
execute 'sign define ALEErrorSign text=' . g:ale_sign_error
\ . ' texthl=ALEErrorSign linehl=ALEErrorLine'
@@ -154,7 +172,21 @@ function! ale#sign#GetSignType(sublist) abort
return 'ALEErrorSign'
endfunction
+function! ale#sign#SetSignColumnHighlight(has_problems) abort
+ highlight clear SignColumn
+
+ if a:has_problems
+ highlight link SignColumn ALESignColumnWithErrors
+ else
+ highlight link SignColumn ALESignColumnWithoutErrors
+ endif
+endfunction
+
function! s:PlaceNewSigns(buffer, grouped_items) abort
+ if g:ale_change_sign_column_color
+ call ale#sign#SetSignColumnHighlight(!empty(a:grouped_items))
+ endif
+
" Add the new signs,
for l:index in range(0, len(a:grouped_items) - 1)
let l:sign_id = l:index + g:ale_sign_offset + 1
diff --git a/doc/ale.txt b/doc/ale.txt
index 56642c2d..df03b53d 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -207,6 +207,21 @@ g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled*
|airline#extensions#ale#warning_symbol|.
+g:ale_change_sign_column_color *g:ale_change_sign_column_color*
+
+ Type: |Number|
+ Default: `0`
+
+ When set to `1`, this option will set different highlights for the sign
+ column itself when ALE reports problems with a file. This option can be
+ combined with |g:ale_sign_column_always|.
+
+ ALE uses the following highlight groups for highlighting the sign column:
+
+ `ALESignColumnWithErrors` - Links to `error` by default.
+ `ALESignColumnWithoutErrors` - Use the value for `SignColumn` by default.
+
+
g:ale_echo_cursor *g:ale_echo_cursor*
Type: |Number|
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 92c1562e..cf97032a 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -108,6 +108,10 @@ let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0)
" This is enabled by default only if the 'signs' feature exists.
let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs'))
+" This flag can be set to 1 to enable changing the sign column colors when
+" there are errors.
+call ale#Set('change_sign_column_color', 0)
+
" This flag can be set to 0 to disable setting error highlights.
let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax'))
diff --git a/test/sign/test_sign_column_highlighting.vader b/test/sign/test_sign_column_highlighting.vader
new file mode 100644
index 00000000..da8bac29
--- /dev/null
+++ b/test/sign/test_sign_column_highlighting.vader
@@ -0,0 +1,22 @@
+Before:
+ function! ParseSignColumnHighlight() abort
+ redir => l:output
+ silent highlight SignColumn
+ redir end
+
+ return join(split(l:output)[2:])
+ endfunction
+
+ let g:sign_highlight = ParseSignColumnHighlight()
+
+After:
+ delfunction ParseSignColumnHighlight
+ execute 'highlight SignColumn ' . g:sign_highlight
+ unlet! g:sign_highlight
+
+Execute(The SignColumn highlight should be set and reset):
+ call ale#sign#SetSignColumnHighlight(1)
+ AssertEqual 'links to ALESignColumnWithErrors', ParseSignColumnHighlight()
+
+ call ale#sign#SetSignColumnHighlight(0)
+ AssertEqual 'links to ALESignColumnWithoutErrors', ParseSignColumnHighlight()