diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/engine.vim | 4 | ||||
-rw-r--r-- | autoload/ale/list.vim | 49 |
2 files changed, 51 insertions, 2 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 933be2ac..08852e00 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -161,8 +161,8 @@ function! s:HandleExit(job) abort let g:ale_buffer_info[l:buffer].loclist = g:ale_buffer_info[l:buffer].new_loclist let g:ale_buffer_info[l:buffer].new_loclist = [] - if g:ale_set_loclist - call setloclist(0, g:ale_buffer_info[l:buffer].loclist) + if g:ale_set_quickfix || g:ale_set_loclist + call ale#list#SetLists(g:ale_buffer_info[l:buffer].loclist) endif if g:ale_set_signs diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim new file mode 100644 index 00000000..480880e4 --- /dev/null +++ b/autoload/ale/list.vim @@ -0,0 +1,49 @@ +" Author: Bjorn Neergaard <bjorn@neersighted.com>, modified by Yann fery <yann@fery.me> +" Description: Manages the loclist and quickfix lists + +" Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list +function! ale#list#IsQuickfixOpen() abort + for l:buf in range(1, bufnr('$')) + if getbufvar(l:buf, '&buftype') ==# 'quickfix' + return 1 + endif + endfor + return 0 +endfunction + +function! ale#list#SetLists(loclist) abort + if g:ale_set_quickfix + call setqflist(a:loclist) + elseif g:ale_set_loclist + call setloclist(0, a:loclist) + endif + + " If we don't auto-open lists, bail out here. + if !g:ale_open_list && !g:ale_keep_list_window_open + return + endif + + " If we have errors in our list, open the list. Only if it isn't already open + if len(a:loclist) > 0 || g:ale_keep_list_window_open + let l:winnr = winnr() + + if g:ale_set_quickfix + copen + elseif g:ale_set_loclist + lopen + endif + + " If focus changed, restore it (jump to the last window). + if l:winnr !=# winnr() + wincmd p + endif + + " Only close if the list is totally empty (relying on Vim's state, not our + " own). This keeps us from closing the window when other plugins have + " populated it. + elseif !g:ale_keep_list_window_open && g:ale_set_quickfix && len(getqflist()) == 0 + cclose + elseif !g:ale_keep_list_window_open && len(getloclist(0)) == 0 + lclose + endif +endfunction |