summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-08-20 13:27:18 +0100
committerw0rp <devw0rp@gmail.com>2017-08-20 13:27:18 +0100
commit753cf5da95fa4c64e31c7e3fbfcd0227c89791c1 (patch)
tree604ec1f6c0fb27e81a9757cb7f2bd9403273e315 /autoload
parente5d0a17694897dc8e234f534cfa33fc3483d8e12 (diff)
downloadale-753cf5da95fa4c64e31c7e3fbfcd0227c89791c1.zip
#653 - Automatically accept annoying loclist and quickfix errors from Vim
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/completion.vim11
-rw-r--r--autoload/ale/events.vim22
-rw-r--r--autoload/ale/util.vim20
3 files changed, 39 insertions, 14 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index 44d4e0e1..9f4e3c28 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -1,10 +1,6 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Completion support for LSP linters
-" A do-nothing function so we can load this autoload file in tests.
-function! ale#completion#Nop() abort
-endfunction
-
let s:timer_id = -1
function! s:GetRegex(map, filetype) abort
@@ -110,11 +106,6 @@ function! ale#completion#OmniFunc(findstart, base) abort
endif
endfunction
-" A wrapper function for feedkeys so we can test calls for it.
-function! ale#completion#FeedKeys(string, mode) abort
- call feedkeys(a:string, a:mode)
-endfunction
-
function! ale#completion#Show(response, completion_parser) abort
" Remember the old omnifunc value, if there is one.
" If we don't store an old one, we'll just never reset the option.
@@ -129,7 +120,7 @@ function! ale#completion#Show(response, completion_parser) abort
let b:ale_completion_parser = a:completion_parser
let &l:omnifunc = 'ale#completion#OmniFunc'
call s:ReplaceCompleteopt()
- call ale#completion#FeedKeys("\<C-x>\<C-o>", 'n')
+ call ale#util#FeedKeys("\<C-x>\<C-o>", 'n')
endfunction
function! s:CompletionStillValid(request_id) abort
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim
index a3b74677..c84954c1 100644
--- a/autoload/ale/events.vim
+++ b/autoload/ale/events.vim
@@ -45,3 +45,25 @@ function! ale#events#FileChangedEvent(buffer) abort
call s:LintOnEnter(a:buffer)
endif
endfunction
+
+" When changing quickfix or a loclist window while the window is open
+" from autocmd events and while navigating from one buffer to another, Vim
+" will complain saying that the window has closed or that the lists have
+" changed.
+"
+" This timer callback just accepts those errors when they appear.
+function! s:HitReturn(...) abort
+ if ale#util#Mode() is# 'r'
+ redir => l:output
+ silent mess
+ redir end
+
+ if get(split(l:output, "\n"), -1, '') =~# '^E92[456]'
+ call ale#util#FeedKeys("\<CR>", 'n')
+ endif
+ endif
+endfunction
+
+function! ale#events#BufWinLeave() abort
+ call timer_start(0, function('s:HitReturn'))
+endfunction
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index fd538425..c46579b0 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -1,11 +1,23 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Contains miscellaneous functions
-" A null file for sending output to nothing.
-let g:ale#util#nul_file = '/dev/null'
+" A wrapper function for mode() so we can test calls for it.
+function! ale#util#Mode(...) abort
+ return call('mode', a:000)
+endfunction
+
+" A wrapper function for feedkeys so we can test calls for it.
+function! ale#util#FeedKeys(...) abort
+ return call('feedkeys', a:000)
+endfunction
-if has('win32')
- let g:ale#util#nul_file = 'nul'
+if !exists('g:ale#util#nul_file')
+ " A null file for sending output to nothing.
+ let g:ale#util#nul_file = '/dev/null'
+
+ if has('win32')
+ let g:ale#util#nul_file = 'nul'
+ endif
endif
" Return the number of lines for a given buffer.