diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim index ea6d958..bbe71e3 100644 --- a/autoload/ale/list.vim +++ b/autoload/ale/list.vim @@ -46,9 +46,9 @@ function! ale#list#SetLists(buffer, loclist) abort if !ale#list#IsQuickfixOpen() if g:ale_set_quickfix - copen + execute 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) elseif g:ale_set_loclist - lopen + execute 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) endif endif diff --git a/doc/ale.txt b/doc/ale.txt index 4286812..f206ffb 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -365,6 +365,19 @@ g:ale_keep_list_window_open *g:ale_keep_list_window_open* See: |g:ale_open_list| +g:ale_list_window_size *g:ale_list_window_size* + *b:ale_list_window_size* + Type: |Number| + Default: `10` + + This number configures the number of lines to set for the height of windows + opened automatically for ALE problems. The default of `10` matches the Vim + default height. + + See |g:ale_open_list| for information on automatically opening windows + for quickfix or the loclist. + + g:ale_lint_delay *g:ale_lint_delay* Type: |Number| @@ -550,6 +563,8 @@ g:ale_open_list *g:ale_open_list* including those not set by ALE, unless |g:ale_keep_list_window_open| is set to `1`, in which case the window will be kept open until closed manually. + The window size can be configured with |g:ale_list_window_size|. + g:ale_pattern_options *g:ale_pattern_options* diff --git a/plugin/ale.vim b/plugin/ale.vim index 85930f3..2562231 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -106,6 +106,9 @@ let g:ale_open_list = get(g:, 'ale_open_list', 0) " This flag dictates if ale keeps open loclist even if there is no error in loclist let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0) +" The window size to set for the quickfix and loclist windows +call ale#Set('list_window_size', 10) + " This flag can be set to 0 to disable setting signs. " This is enabled by default only if the 'signs' feature exists. let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) diff --git a/test/test_list_opening.vader b/test/test_list_opening.vader index 6d0164f..89b1416 100644 --- a/test/test_list_opening.vader +++ b/test/test_list_opening.vader @@ -1,6 +1,17 @@ " Author: Yann Fery - Before: + Save g:ale_set_loclist + Save g:ale_set_quickfix + Save g:ale_open_list + Save g:ale_keep_list_window_open + Save g:ale_list_window_size + + let g:ale_set_loclist = 1 + let g:ale_set_quickfix = 0 + let g:ale_open_list = 0 + let g:ale_keep_list_window_open = 0 + let g:ale_list_window_size = 10 + let g:loclist = [ \ {'lnum': 5, 'col': 5}, \ {'lnum': 5, 'col': 4}, @@ -8,18 +19,28 @@ Before: \ {'lnum': 3, 'col': 2}, \] + function GetQuickfixHeight() abort + for l:win in range(1, winnr('$')) + if getwinvar(l:win, '&buftype') ==# 'quickfix' + return winheight(l:win) + endif + endfor + + return 0 + endfunction + After: + Restore + + unlet! g:loclist + unlet! b:ale_list_window_size + delfunction GetQuickfixHeight + " Close quickfix window after every execute block lcl ccl - unlet g:loclist call setloclist(0, []) call setqflist([]) - " Reset options to their default values. - let g:ale_set_loclist = 1 - let g:ale_set_quickfix = 0 - let g:ale_open_list = 0 - let g:ale_keep_list_window_open = 0 Execute(IsQuickfixOpen should return the right output): AssertEqual 0, ale#list#IsQuickfixOpen() @@ -53,6 +74,22 @@ Execute(The quickfix window should open for just the loclist): call ale#list#SetLists(bufnr('%'), []) Assert !ale#list#IsQuickfixOpen() +Execute(The quickfix window height should be correct for the loclist): + let g:ale_open_list = 1 + let g:ale_list_window_size = 7 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 7, GetQuickfixHeight() + +Execute(The quickfix window height should be correct for the loclist with buffer variables): + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 8, GetQuickfixHeight() + Execute(The quickfix window should stay open for just the loclist): let g:ale_open_list = 1 let g:ale_keep_list_window_open = 1 @@ -93,3 +130,21 @@ Execute(The quickfix window should stay open for the quickfix list): call ale#list#SetLists(bufnr('%'), g:loclist) call ale#list#SetLists(bufnr('%'), []) Assert ale#list#IsQuickfixOpen() + +Execute(The quickfix window height should be correct for the quickfix list): + let g:ale_set_quickfix = 1 + let g:ale_open_list = 1 + let g:ale_list_window_size = 7 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 7, GetQuickfixHeight() + +Execute(The quickfix window height should be correct for the quickfix list with buffer variables): + let g:ale_set_quickfix = 1 + let g:ale_open_list = 1 + let b:ale_list_window_size = 8 + + call ale#list#SetLists(bufnr('%'), g:loclist) + + AssertEqual 8, GetQuickfixHeight()