diff --git a/autoload/easycomplete.vim b/autoload/easycomplete.vim index 8a42ef64..963567aa 100644 --- a/autoload/easycomplete.vim +++ b/autoload/easycomplete.vim @@ -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 @@ -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() @@ -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 @@ -1862,6 +1862,10 @@ function! s:zizz() return "\" 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) diff --git a/autoload/easycomplete/popup.vim b/autoload/easycomplete/popup.vim index 05b3e2a9..1ad4c213 100644 --- a/autoload/easycomplete/popup.vim +++ b/autoload/easycomplete/popup.vim @@ -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') @@ -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 = [] diff --git a/autoload/easycomplete/sources/ts.vim b/autoload/easycomplete/sources/ts.vim index 6e5f947b..7e9b15ee 100644 --- a/autoload/easycomplete/sources/ts.vim +++ b/autoload/easycomplete/sources/ts.vim @@ -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, diff --git a/autoload/easycomplete/tabnine.vim b/autoload/easycomplete/tabnine.vim index 591e8cdb..aec09227 100644 --- a/autoload/easycomplete/tabnine.vim +++ b/autoload/easycomplete/tabnine.vim @@ -142,6 +142,7 @@ function! s:RemainInsertMode() else call execute("normal! A") endif + call easycomplete#zizz() endfunction function! s:GetSnippets(res_array) diff --git a/autoload/easycomplete/ui.vim b/autoload/easycomplete/ui.vim index de49dc6d..6c11221f 100644 --- a/autoload/easycomplete/ui.vim +++ b/autoload/easycomplete/ui.vim @@ -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 {{{