summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-20 23:32:41 +0100
committerw0rp <devw0rp@gmail.com>2017-05-20 23:32:41 +0100
commitf92bbab8cf22becfaf3188474afb10245b489843 (patch)
tree95abe059624aee88ca4ba7096fa07e88d2617f86 /autoload
parentbf8bf0668113a1c5a378f05050722967f88a273f (diff)
downloadale-f92bbab8cf22becfaf3188474afb10245b489843.zip
#149 - Support Info, style error, and style warning types for problems for signs
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale.vim11
-rw-r--r--autoload/ale/engine.vim4
-rw-r--r--autoload/ale/sign.vim54
3 files changed, 64 insertions, 5 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index ca75577a..d8db3bfd 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -124,6 +124,17 @@ function! ale#Var(buffer, variable_name) abort
return getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name])
endfunction
+" Initialize a variable with a default value, if it isn't already set.
+"
+" Every variable name will be prefixed with 'ale_'.
+function! ale#Set(variable_name, default) abort
+ let l:full_name = 'ale_' . a:variable_name
+ let l:value = get(g:, l:full_name, a:default)
+ let g:[l:full_name] = l:value
+
+ return l:value
+endfunction
+
" Escape a string suitably for each platform.
" shellescape does not work on Windows.
function! ale#Escape(str) abort
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index e13562a0..f4f5c1c5 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -293,6 +293,10 @@ function! ale#engine#FixLocList(buffer, linter, loclist) abort
let l:item.end_col = str2nr(l:old_item.end_col)
endif
+ if has_key(l:old_item, 'sub_type')
+ let l:item.sub_type = l:old_item.sub_type
+ endif
+
if l:item.lnum == 0
" When errors appear at line 0, put them at line 1 instead.
let l:item.lnum = 1
diff --git a/autoload/ale/sign.vim b/autoload/ale/sign.vim
index 0e0250bf..f16153f8 100644
--- a/autoload/ale/sign.vim
+++ b/autoload/ale/sign.vim
@@ -8,15 +8,33 @@ if !hlexists('ALEErrorSign')
highlight link ALEErrorSign error
endif
+if !hlexists('ALEStyleErrorSign')
+ highlight link ALEStyleErrorSign ALEErrorSign
+endif
+
if !hlexists('ALEWarningSign')
highlight link ALEWarningSign todo
endif
+if !hlexists('ALEStyleWarningSign')
+ highlight link ALEStyleWarningSign ALEWarningSign
+endif
+
+if !hlexists('ALEInfoSign')
+ highlight link ALEInfoSign ALEWarningSign
+endif
+
" Signs show up on the left for error markers.
execute 'sign define ALEErrorSign text=' . g:ale_sign_error
\ . ' texthl=ALEErrorSign linehl=ALEErrorLine'
+execute 'sign define ALEStyleErrorSign text=' . g:ale_sign_style_error
+\ . ' texthl=ALEStyleErrorSign linehl=ALEStyleErrorSign'
execute 'sign define ALEWarningSign text=' . g:ale_sign_warning
\ . ' texthl=ALEWarningSign linehl=ALEWarningLine'
+execute 'sign define ALEStyleWarningSign text=' . g:ale_sign_style_warning
+\ . ' texthl=ALEStyleWarningSign linehl=ALEStyleWarningSign'
+execute 'sign define ALEInfoSign text=' . g:ale_sign_info
+\ . ' texthl=ALEInfoSign linehl=ALEInfoLine'
sign define ALEDummySign
" Read sign data for a buffer to a list of lines.
@@ -36,7 +54,7 @@ function! ale#sign#ParseSigns(line_list) abort
" 行=1 識別子=1000001 名前=ALEWarningSign
" línea=12 id=1000001 nombre=ALEWarningSign
" riga=1 id=1000001, nome=ALEWarningSign
- let l:pattern = '^.*=\(\d\+\).*=\(\d\+\).*=ALE\(Error\|Warning\|Dummy\)Sign'
+ let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)'
let l:result = []
for l:line in a:line_list
@@ -46,7 +64,7 @@ function! ale#sign#ParseSigns(line_list) abort
call add(l:result, [
\ str2nr(l:match[1]),
\ str2nr(l:match[2]),
- \ 'ALE' . l:match[3] . 'Sign',
+ \ l:match[3],
\])
endif
endfor
@@ -108,14 +126,40 @@ function! s:SetDummySignIfNeeded(buffer, current_sign_list, new_signs) abort
return l:is_dummy_sign_set
endfunction
+function! ale#sign#GetSignType(sublist) abort
+ let l:highest_level = 100
+
+ for l:item in a:sublist
+ let l:level = (l:item.type ==# 'I' ? 2 : l:item.type ==# 'W')
+
+ if get(l:item, 'sub_type', '') ==# 'style'
+ let l:level += 10
+ endif
+
+ if l:level < l:highest_level
+ let l:highest_level = l:level
+ endif
+ endfor
+
+ if l:highest_level == 10
+ return 'ALEStyleErrorSign'
+ elseif l:highest_level == 11
+ return 'ALEStyleWarningSign'
+ elseif l:highest_level == 2
+ return 'ALEInfoSign'
+ elseif l:highest_level == 1
+ return 'ALEWarningSign'
+ endif
+
+ return 'ALEErrorSign'
+endfunction
+
function! s:PlaceNewSigns(buffer, grouped_items) abort
" 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
let l:sublist = a:grouped_items[l:index]
- let l:type = !empty(filter(copy(l:sublist), 'v:val.type ==# ''E'''))
- \ ? 'ALEErrorSign'
- \ : 'ALEWarningSign'
+ let l:type = ale#sign#GetSignType(a:grouped_items[l:index])
" Save the sign IDs we are setting back on our loclist objects.
" These IDs will be used to preserve items which are set many times.