mirror of https://github.com/dense-analysis/ale
Make tsserver completion more reliable, but not quite ready for documentation yet
This commit is contained in:
parent
bc97735b6d
commit
f7f6f6541d
|
@ -49,25 +49,32 @@ function! ale#completion#OmniFunc(findstart, base) abort
|
||||||
|
|
||||||
return l:column - len(l:match) - 1
|
return l:column - len(l:match) - 1
|
||||||
else
|
else
|
||||||
" Reset the settings now
|
" Parse a new response if there is one.
|
||||||
let &omnifunc = b:ale_old_omnifunc
|
if exists('b:ale_completion_response')
|
||||||
let &completeopt = b:ale_old_completeopt
|
\&& exists('b:ale_completion_parser')
|
||||||
let l:response = b:ale_completion_response
|
let l:response = b:ale_completion_response
|
||||||
let l:parser = b:ale_completion_parser
|
let l:parser = b:ale_completion_parser
|
||||||
|
|
||||||
unlet b:ale_completion_response
|
unlet b:ale_completion_response
|
||||||
unlet b:ale_completion_parser
|
unlet b:ale_completion_parser
|
||||||
unlet b:ale_old_omnifunc
|
|
||||||
unlet b:ale_old_completeopt
|
|
||||||
|
|
||||||
return function(l:parser)(l:response)
|
let b:ale_completion_result = function(l:parser)(l:response)
|
||||||
|
endif
|
||||||
|
|
||||||
|
return get(b:, 'ale_completion_result', [])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#completion#Show(response, completion_parser) abort
|
function! ale#completion#Show(response, completion_parser) abort
|
||||||
" Remember the old omnifunc value.
|
" Remember the old omnifunc value, if there is one.
|
||||||
if !exists('b:ale_old_omnifunc')
|
" If we don't store an old one, we'll just never reset the option.
|
||||||
|
" This will stop some random exceptions from appearing.
|
||||||
|
if !exists('b:ale_old_omnifunc') && !empty(&omnifunc)
|
||||||
let b:ale_old_omnifunc = &omnifunc
|
let b:ale_old_omnifunc = &omnifunc
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Remember the old completion options, if they are set.
|
||||||
|
if !exists('b:ale_old_completeopt') && !empty(&completeopt)
|
||||||
let b:ale_old_completeopt = &completeopt
|
let b:ale_old_completeopt = &completeopt
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -248,6 +255,12 @@ endfunction
|
||||||
function! ale#completion#Queue() abort
|
function! ale#completion#Queue() abort
|
||||||
let s:timer_pos = getcurpos()[1:2]
|
let s:timer_pos = getcurpos()[1:2]
|
||||||
|
|
||||||
|
" If we changed the text again while we're still waiting for a response,
|
||||||
|
" then invalidate the requests before the timer ticks again.
|
||||||
|
if exists('b:ale_completion_info')
|
||||||
|
let b:ale_completion_info.request_id = 0
|
||||||
|
endif
|
||||||
|
|
||||||
if s:timer_id != -1
|
if s:timer_id != -1
|
||||||
call timer_stop(s:timer_id)
|
call timer_stop(s:timer_id)
|
||||||
endif
|
endif
|
||||||
|
@ -255,13 +268,28 @@ function! ale#completion#Queue() abort
|
||||||
let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
|
let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#completion#Done() abort
|
||||||
|
silent! pclose
|
||||||
|
|
||||||
|
" Reset settings when completion is done.
|
||||||
|
if exists('b:ale_old_omnifunc')
|
||||||
|
let &omnifunc = b:ale_old_omnifunc
|
||||||
|
unlet b:ale_old_omnifunc
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists('b:ale_old_completeopt')
|
||||||
|
let &completeopt = b:ale_old_completeopt
|
||||||
|
unlet b:ale_old_completeopt
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:Setup(enabled) abort
|
function! s:Setup(enabled) abort
|
||||||
augroup ALECompletionGroup
|
augroup ALECompletionGroup
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
if a:enabled
|
if a:enabled
|
||||||
autocmd TextChangedI * call ale#completion#Queue()
|
autocmd TextChangedI * call ale#completion#Queue()
|
||||||
autocmd CompleteDone * silent! pclose
|
autocmd CompleteDone * call ale#completion#Done()
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue