Skip to content

Commit

Permalink
speed up, and modified the popup speed
Browse files Browse the repository at this point in the history
  • Loading branch information
jayli committed Dec 11, 2023
1 parent 504651b commit ed08df7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
14 changes: 9 additions & 5 deletions autoload/easycomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ function! s:CompleteTypingMatch(...)
if len(filtered_menu) == 0
if has('nvim')
call s:AsyncRun(function('s:CloseCompletionMenu'),[], 50)
call s:CloseCompleteInfo()
else
call s:CloseCompletionMenu()
endif
Expand Down Expand Up @@ -675,6 +676,9 @@ function! easycomplete#typing()
return ""
endif

" TODO here,为了防止tab补全 tabnine后自动触发complete动作,这里需要更多测试兼容性
if s:zizzing() | return "" | endif

if !easycomplete#FireCondition()
" tabnine
if easycomplete#sources#tn#available() && easycomplete#sources#tn#FireCondition()
Expand Down Expand Up @@ -1787,11 +1791,7 @@ function! s:flush()
let g:easycomplete_completedone_insert_mode = mode()
if easycomplete#util#InsertMode() && complete_check()
call s:StopAsyncRun()
if g:easycomplete_colorful
call s:AsyncRun(function("easycomplete#colorful#complete"),[col("."),[]], 50)
else
call s:AsyncRun(function("complete"),[col("."),[]], 50)
endif
call s:AsyncRun(function("complete"),[col("."),[]], 50)
endif
let s:easycomplete_start_pos = 0
endfunction
Expand Down Expand Up @@ -1862,6 +1862,10 @@ function! s:zizz()
return "\<BS>"
endfunction

function! easycomplete#zizz()
call s:zizz()
endfunction

function! s:StopZizz()
if exists('s:zizz_timmer') && s:zizz_timmer > 0
call timer_stop(s:zizz_timmer)
Expand Down
45 changes: 27 additions & 18 deletions autoload/easycomplete/popup.vim
Original file line number Diff line number Diff line change
Expand Up @@ -438,33 +438,37 @@ function! s:NVimShow(opt, windowtype, float_type)
else
let hl = 'Pmenu'
endif
if easycomplete#util#ItemIsFromLS(g:easycomplete_completed_item)
let filetype = &filetype == "lua" ? "help" : &filetype
else
let filetype = &filetype
endif
let l:filetype = &filetype == "lua" ? "help" : &filetype
let hl_str = 'Normal:' . hl . ',NormalNC:' . hl
let winargs = [s:buf[a:windowtype], 0, a:opt]
unlet winargs[2].filetype
noa let winid = nvim_open_win(s:buf[a:windowtype], 0, winargs[2])
silent let winid = nvim_open_win(s:buf[a:windowtype], v:false, winargs[2])
call nvim_set_option_value('winhl', hl_str, {'win': winid})
let g:easycomplete_popup_win[a:windowtype] = winid
if a:windowtype == 'popup'
call easycomplete#util#execute(g:easycomplete_popup_win[a:windowtype], "set nowrap")
if exists('*nvim_win_set_config')
call nvim_win_set_config(g:easycomplete_popup_win[a:windowtype], {
\ 'relativenumber': v:false,
\ 'cursorline': v:false,
\ 'cursorcolumn': v:false,
\ 'colorcolumn': '',
\ })
else
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'relativenumber', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'cursorline', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'cursorcolumn', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'colorcolumn', '')
endif
call nvim_win_set_var(g:easycomplete_popup_win[a:windowtype], 'syntax', 'on')
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'winhl', hl_str)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'number', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'relativenumber', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'cursorline', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'cursorcolumn', v:false)
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'colorcolumn', '')
call nvim_win_set_option(g:easycomplete_popup_win[a:windowtype], 'foldenable', v:false)
call nvim_win_set_var(g:easycomplete_popup_win[a:windowtype], 'syntax', 'off')
if has('nvim-0.5.0')
call setwinvar(g:easycomplete_popup_win[a:windowtype], '&scrolloff', 0)
call setwinvar(g:easycomplete_popup_win[a:windowtype], '&spell', 0)
if a:windowtype == 'popup'
call setwinvar(g:easycomplete_popup_win[a:windowtype], '&wrap', 0)
endif
endif
" Popup and Signature
if a:windowtype == 'popup' || (a:windowtype == "float" && a:float_type == "signature")
call setbufvar(winbufnr(winid), '&filetype', filetype)
call setbufvar(winbufnr(winid), '&filetype', l:filetype)
else
" Lint
call setbufvar(winbufnr(winid), '&filetype', 'txt')
Expand Down Expand Up @@ -514,7 +518,12 @@ function! easycomplete#popup#close(...)
let id = win_id2win(g:easycomplete_popup_win[windowtype])
if id > 0
let winid = g:easycomplete_popup_win[windowtype]
call timer_start(50, { -> s:NvimCloseFloatWithPum(winid) })
if !(&completeopt =~ "noselect")
let delay = 0
else
let delay = 30
endif
call timer_start(delay, { -> s:NvimCloseFloatWithPum(winid) })
endif
let g:easycomplete_popup_win[windowtype] = 0
let s:last_winargs = []
Expand Down
3 changes: 3 additions & 0 deletions autoload/easycomplete/sources/ts.vim
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ function! easycomplete#sources#ts#CompleteChanged()
if !easycomplete#CompleteCursored() | return | endif
if empty(s:request_queue_ctx) | return | endif
if s:EntryDetailsIsFetching() | return | endif
if easycomplete#util#GetPluginNameFromUserData(l:item) != "ts"
return
endif
if !empty(
\ easycomplete#util#GetInfoByCompleteItem(
\ l:item,
Expand Down
1 change: 1 addition & 0 deletions autoload/easycomplete/tabnine.vim
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function! s:RemainInsertMode()
else
call execute("normal! A")
endif
call easycomplete#zizz()
endfunction

function! s:GetSnippets(res_array)
Expand Down
5 changes: 4 additions & 1 deletion autoload/easycomplete/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ function! easycomplete#ui#ApplyMarkdownSyntax(winid)
\ "let &filetype='" . original_filetype . "'",
\ ]
endif
call easycomplete#util#execute(a:winid, exec_cmd)
try
call easycomplete#util#execute(a:winid, exec_cmd)
catch
endtry
endfunction " }}}

" Get back ground color form a GroupName {{{
Expand Down

0 comments on commit ed08df7

Please sign in to comment.