summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-03-08 21:32:05 +0000
committerw0rp <devw0rp@gmail.com>2019-03-08 21:32:05 +0000
commit413529f603547bad184358db06f8388047a5c9aa (patch)
treec31cdb07b568077bcbc11c8c7fad81d2699a60db /autoload
parentbe2c0c3af5e9685b3e1235fa062cb148d740e830 (diff)
downloadale-413529f603547bad184358db06f8388047a5c9aa.zip
Fix #2326 - ALEComplete no longer replaces completeopt
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/completion.vim43
1 files changed, 22 insertions, 21 deletions
diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim
index 782a68e4..48fa3963 100644
--- a/autoload/ale/completion.vim
+++ b/autoload/ale/completion.vim
@@ -165,14 +165,18 @@ function! s:ReplaceCompletionOptions() abort
let &l:omnifunc = 'ale#completion#OmniFunc'
- if !exists('b:ale_old_completopt')
- let b:ale_old_completopt = &l:completeopt
- endif
+ let l:info = get(b:, 'ale_completion_info', {})
- if &l:completeopt =~# 'preview'
- let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
- else
- let &l:completeopt = 'menu,menuone,noselect,noinsert'
+ if !get(l:info, 'manual')
+ if !exists('b:ale_old_completeopt')
+ let b:ale_old_completeopt = &l:completeopt
+ endif
+
+ if &l:completeopt =~# 'preview'
+ let &l:completeopt = 'menu,menuone,preview,noselect,noinsert'
+ else
+ let &l:completeopt = 'menu,menuone,noselect,noinsert'
+ endif
endif
endfunction
@@ -186,9 +190,9 @@ function! ale#completion#RestoreCompletionOptions() abort
unlet b:ale_old_omnifunc
endif
- if exists('b:ale_old_completopt')
- let &l:completeopt = b:ale_old_completopt
- unlet b:ale_old_completopt
+ if exists('b:ale_old_completeopt')
+ let &l:completeopt = b:ale_old_completeopt
+ unlet b:ale_old_completeopt
endif
endfunction
@@ -503,22 +507,14 @@ function! s:OnReady(linter, lsp_details) abort
endif
endfunction
-function! ale#completion#GetCompletions() abort
- if !g:ale_completion_enabled
- return
- endif
-
- call ale#completion#AlwaysGetCompletions(1)
-endfunction
-
" This function can be used to manually trigger autocomplete, even when
" g:ale_completion_enabled is set to false
-function! ale#completion#AlwaysGetCompletions(need_prefix) abort
+function! ale#completion#GetCompletions(manual) abort
let [l:line, l:column] = getpos('.')[1:2]
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
- if a:need_prefix && empty(l:prefix)
+ if !a:manual && empty(l:prefix)
return
endif
@@ -531,6 +527,7 @@ function! ale#completion#AlwaysGetCompletions(need_prefix) abort
\ 'prefix': l:prefix,
\ 'conn_id': 0,
\ 'request_id': 0,
+ \ 'manual': a:manual,
\}
let l:buffer = bufnr('')
@@ -544,6 +541,10 @@ function! ale#completion#AlwaysGetCompletions(need_prefix) abort
endfunction
function! s:TimerHandler(...) abort
+ if !g:ale_completion_enabled
+ return
+ endif
+
let s:timer_id = -1
let [l:line, l:column] = getpos('.')[1:2]
@@ -551,7 +552,7 @@ function! s:TimerHandler(...) abort
" When running the timer callback, we have to be sure that the cursor
" hasn't moved from where it was when we requested completions by typing.
if s:timer_pos == [l:line, l:column] && ale#util#Mode() is# 'i'
- call ale#completion#GetCompletions()
+ call ale#completion#GetCompletions(0)
endif
endfunction