dense-analysis / dense-analysis/ale
Limit loclist size to only what is needed
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
Screen space can be a premium. If you only have, say, three errors, there's no need for the loclist to take up 10 lines.
Syntastic solves this by exposing a function (SyntasticCheckHook) to users that is called when the linters run and takes the error list as an argument. The user can then define the function to limit the loclist height to be no greater than the number of errors.
I managed to create similar functionality in ALE after digging through the source code (solution below), but it might be nice to include this functionality with less of a hack, or perhaps add some documentation describing how to accomplish it so future users don't have to go digging through source.
I want to preface that I am still pretty new to both vimscript and ALE, so I apologize if the solution I came up with isn't the most elegant or does not work for all circumstances.
This is what I put in my .vimrc:
```
autocmd User ALELintPost call s:ale_loclist_limit()
function! s:ale_loclist_limit()
if exists("b:ale_list_window_size_max")
let b:ale_list_window_size = min([len(ale#engine#GetLoclist(bufnr('%'))), b:ale_list_window_size_max])
elseif exists("g:ale_list_window_size_max")
let b:ale_list_window_size = min([len(ale#engine#GetLoclist(bufnr('%'))), g:ale_list_window_size_max])
endif
endfunction
```
Contributor guide
Assessment
This issue has not been assessed yet.