Skip to content

Change LanguageClient#complete to not use runSync #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions autoload/LanguageClient.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,19 @@ function! LanguageClient_filterCompletionItems(item, base) abort
endfunction

let g:LanguageClient_completeResults = []

function! s:CompleteCallback(base, result) abort
let l:result = s:HandleOutput(a:result)
let l:result = l:result is v:null ? [] : l:result
let l:filtered_items = []
for l:item in l:result
if LanguageClient_filterCompletionItems(l:item, a:base)
call add(l:filtered_items, l:item)
endif
endfor
call complete(col('.'), l:filtered_items)
endfunction

function! LanguageClient#complete(findstart, base) abort
if a:findstart
" Before requesting completion, content between l:start and current cursor is removed.
Expand All @@ -1469,20 +1482,11 @@ function! LanguageClient#complete(findstart, base) abort
return l:start
else
" Magic happens that cursor jumps to the previously found l:start.
let l:result = LanguageClient_runSync(
\ 'LanguageClient#omniComplete', {
call LanguageClient#omniComplete({
\ 'character': LSP#character() + len(a:base),
\ 'complete_position': LSP#character(),
\ 'text': s:completeText,
\ })
let l:result = l:result is v:null ? [] : l:result
let l:filtered_items = []
for l:item in l:result
if LanguageClient_filterCompletionItems(l:item, a:base)
call add(l:filtered_items, l:item)
endif
endfor
return filtered_items
\ }, function('s:CompleteCallback', [ a:base ]))
endif
endfunction

Expand Down