@@ -3,6 +3,7 @@ local api = vim.api
3
3
local util = require ' completion.util'
4
4
local ins = require ' completion.source.ins_complete'
5
5
local match = require ' completion.matching'
6
+ local lsp = require ' completion.source.lsp'
6
7
7
8
local M = {}
8
9
28
29
29
30
M .clearCache = function ()
30
31
cache_complete_items = {}
32
+ lsp .isIncomplete = true
31
33
end
32
34
33
35
-- perform completion
@@ -38,23 +40,29 @@ M.performComplete = function(complete_source, complete_items_map, manager, opt)
38
40
-- ins-complete source
39
41
ins .triggerCompletion (manager , complete_source .mode )
40
42
elseif vim .fn .has_key (complete_source , " complete_items" ) > 0 then
41
- if # cache_complete_items == 0 then
42
- -- use callback_array to handle async behavior
43
- local callback_array = {}
44
- local items_array = {}
45
- -- collect getCompleteItems function of current completion source
46
- for _ , item in ipairs (complete_source .complete_items ) do
47
- local complete_items = complete_items_map [item ]
48
- if complete_items ~= nil then
49
- if complete_items .callback == nil then
50
- table.insert (callback_array , true )
51
- else
52
- table.insert (callback_array , complete_items .callback )
53
- complete_items .trigger (manager , opt )
54
- end
55
- table.insert (items_array , complete_items .item )
43
+ local callback_array = {}
44
+ local items_array = {}
45
+ -- collect getCompleteItems function of current completion source
46
+ for _ , item in ipairs (complete_source .complete_items ) do
47
+ -- check isIncomplete for lsp
48
+ if item == ' lsp' then
49
+ if lsp .isIncomplete then
50
+ cache_complete_items = {}
51
+ end
52
+ end
53
+ local complete_items = complete_items_map [item ]
54
+ if complete_items ~= nil then
55
+ if complete_items .callback == nil then
56
+ table.insert (callback_array , true )
57
+ else
58
+ table.insert (callback_array , complete_items .callback )
59
+ complete_items .trigger (manager , opt )
56
60
end
61
+ table.insert (items_array , complete_items .item )
57
62
end
63
+ end
64
+ if # cache_complete_items == 0 then
65
+ -- use callback_array to handle async behavior
58
66
59
67
local timer = vim .loop .new_timer ()
60
68
timer :start (20 , 50 , vim .schedule_wrap (function ()
0 commit comments