@@ -34,12 +34,12 @@ cmp.setup = function(opts)
34
34
cmp .fuzzy = require (' blink.cmp.fuzzy' )
35
35
cmp .fuzzy .init_db (vim .fn .stdpath (' data' ) .. ' /blink/cmp/fuzzy.db' )
36
36
37
- cmp . trigger . listen_on_show ( function ( context ) cmp . sources . request_completions ( context ) end )
38
- cmp . trigger . listen_on_hide ( function ()
39
- cmp . sources . cancel_completions ()
40
- cmp . windows . autocomplete . close ( )
41
- end )
42
- cmp . sources . listen_on_completions ( function ( context , items )
37
+ -- we store the previous items so we can immediately perform fuzzy matching on keystroke
38
+ -- and then update again when the sources return new results
39
+ local last_items = {}
40
+ local function update_completions ( context , items )
41
+ if items == nil then items = last_items end
42
+ last_items = items
43
43
-- we avoid adding 1-4ms to insertion latency by scheduling for later
44
44
vim .schedule (function ()
45
45
local filtered_items = cmp .fuzzy .filter_items (require (' blink.cmp.util' ).get_query (), items )
@@ -49,7 +49,17 @@ cmp.setup = function(opts)
49
49
cmp .windows .autocomplete .close ()
50
50
end
51
51
end )
52
+ end
53
+
54
+ cmp .trigger .listen_on_show (function (context )
55
+ update_completions (context )
56
+ cmp .sources .request_completions (context )
57
+ end )
58
+ cmp .trigger .listen_on_hide (function ()
59
+ cmp .sources .cancel_completions ()
60
+ cmp .windows .autocomplete .close ()
52
61
end )
62
+ cmp .sources .listen_on_completions (update_completions )
53
63
end
54
64
55
65
cmp .add_default_highlights = function ()
0 commit comments