diff options
author | w0rp <devw0rp@gmail.com> | 2016-09-13 22:25:28 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2016-09-13 22:25:28 +0100 |
commit | d2e1348c096f04bde591089ca5ce87c4cbecbf61 (patch) | |
tree | b54d1163e831cf9662605ac413b8df4d0a33960d /plugin | |
parent | 0b8c2525b1719766275f6513900f8b08a6fabacd (diff) | |
download | ale-d2e1348c096f04bde591089ca5ce87c4cbecbf61.zip |
Make signs prefer errors to warnings if there are two loclist items for one line.
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/ale/sign.vim | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/plugin/ale/sign.vim b/plugin/ale/sign.vim index 7eb858ba..4797e52b 100644 --- a/plugin/ale/sign.vim +++ b/plugin/ale/sign.vim @@ -30,14 +30,36 @@ function! ale#sign#SetSigns(loclist) exec 'sign unplace * buffer=' . buffer - for i in range(0, len(a:loclist) - 1) - let obj = a:loclist[i] + let signlist = [] + + for obj in a:loclist + let should_append = 1 + + if len(signlist) > 0 && signlist[-1].lnum == obj.lnum + " We can't add the same line twice, because signs must be + " unique per line. + let should_append = 0 + + if signlist[-1].type ==# 'W' && obj.type ==# 'E' + " If we had a warning previously, but now have an error, + " we replace the object to set an error instead. + let signlist[-1] = obj + endif + endif + + if should_append + call add(signlist, obj) + endif + endfor + + for i in range(0, len(signlist) - 1) + let obj = signlist[i] let name = obj['type'] ==# 'W' ? 'ALEWarningSign' : 'ALEErrorSign' let sign_line = 'sign place ' . (i + 1) \. ' line=' . obj['lnum'] \. ' name=' . name - \. ' buffer=' . obj['bufnr'] + \. ' buffer=' . buffer exec sign_line endfor |