dense-analysis / dense-analysis/ale

Support column alignment for virtual text.

Open
#4,472 5 comments 1 reaction 1 assignee Claimed by @w0rp View on GitHub
enhancement
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

The default virtual text setup causes multiple lines of errors/warning to `cuddle` with the ends of the buffer text.
I find this unsightly and a visual distraction. In languages like 'c' where a single mistype can generate a page of errors on
every line, the resulting visual mess is worse than useless.

I would like to suggest two changes
1. Filter errors in virtualtext#SetTex() so only ONE error is added per buffer line.
2. Modify virtualtext#ShowMessage() to support left aligning all messages at a specific column.

As a test, I added something like the following to test virtualtext.vim around line 177
```vim
silent! call prop_add(l:line, 0, {
\ 'type': l:hl_group,
\ 'text': ' ' . l:msg,
\ 'bufnr': a:buffer,
\ 'text_padding_left': 50-strdisplaywidth(getline(l:line)),
\})
```

This forced all warning to align at the 50th column. Lines already longer than 50 columns had their warnings hidden.

A similar modification to virtualtext#SetText()
```vim
let l:seen = {}

for l:item in a:loclist
if l:item.bufnr == a:buffer
let l:line = max([1, l:item.lnum])
if !has_key(l:seen,l:line)
call ale#virtualtext#ShowMessage(a:buffer, l:item)
let l:seen[l:line] = 1
endif
endif
endfor
```

This eliminates the mess caused by having multiple errors/warnings per line (only the first was usually of any use).

With these two changes, I find the virtual text feature much more usable.

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.