@@ -433,7 +433,7 @@ MiniCompletion.completefunc_lsp = function(findstart, base)
433
433
local process_items , is_incomplete = H .get_config ().lsp_completion .process_items , false
434
434
process_items = process_items or MiniCompletion .default_process_items
435
435
local words = H .process_lsp_response (H .completion .lsp .result , function (response , client_id )
436
- is_incomplete = is_incomplete or response .isIncomplete
436
+ is_incomplete = is_incomplete or ( response .isIncomplete == true )
437
437
-- Response can be `CompletionList` with 'items' field plus their
438
438
-- defaults or `CompletionItem[]`
439
439
local items = H .table_get (response , { ' items' }) or response
@@ -443,7 +443,8 @@ MiniCompletion.completefunc_lsp = function(findstart, base)
443
443
return H .lsp_completion_response_items_to_complete_items (items , client_id )
444
444
end )
445
445
446
- H .completion .lsp .status = is_incomplete and ' done-isincomplete' or ' done'
446
+ H .completion .lsp .status = ' done'
447
+ H .completion .lsp .is_incomplete = is_incomplete
447
448
448
449
-- Maybe trigger fallback action
449
450
if vim .tbl_isempty (words ) and H .completion .fallback then return H .trigger_fallback () end
@@ -544,7 +545,8 @@ H.keys = {
544
545
-- Field `lsp` is a table describing state of all used LSP requests. It has the
545
546
-- following structure:
546
547
-- - id: identifier (consecutive numbers).
547
- -- - status: one of 'sent', 'received', 'done', 'done-isincomplete', 'canceled'
548
+ -- - status: one of 'sent', 'received', 'done', 'canceled'
549
+ -- - is_incomplete: whether request was incomplete and require recomputing
548
550
-- - result: result of request.
549
551
-- - cancel_fun: function which cancels current request.
550
552
@@ -555,7 +557,7 @@ H.completion = {
555
557
source = nil ,
556
558
text_changed_id = 0 ,
557
559
timer = vim .loop .new_timer (),
558
- lsp = { id = 0 , status = nil , result = nil , cancel_fun = nil },
560
+ lsp = { id = 0 , status = nil , is_incomplete = false , result = nil , cancel_fun = nil },
559
561
start_pos = {},
560
562
}
561
563
@@ -693,13 +695,15 @@ H.auto_completion = function()
693
695
694
696
H .completion .timer :stop ()
695
697
696
- local is_incomplete = H .completion .lsp .status == ' done-isincomplete '
698
+ local is_incomplete = H .completion .lsp .is_incomplete
697
699
local force = H .is_lsp_trigger (vim .v .char , ' completion' ) or is_incomplete
698
700
if force then
699
- -- If character is LSP trigger, force fresh LSP completion later
700
- -- Check LSP trigger before checking for pumvisible because it should be
701
- -- forced even if there are visible candidates
702
- H .stop_completion (false )
701
+ -- Force fresh LSP completion if needed. Check before checking pumvisible
702
+ -- because it should be forced even if there are visible candidates.
703
+ -- Keep positive `is_incomplete` to allow fast typing and not "forget" that
704
+ -- list was incomplete after the second fast key press. This will force LSP
705
+ -- completion until `isIncomplete=false` response or general `stop()`.
706
+ H .stop_completion (false , is_incomplete )
703
707
elseif H .pumvisible () then
704
708
-- Do nothing if popup is visible. `H.pumvisible()` might be `true` even if
705
709
-- there is no popup. It is common when manually typing candidate followed
@@ -874,11 +878,11 @@ end
874
878
H .default_fallback_action = function () vim .api .nvim_feedkeys (H .keys .ctrl_n , ' n' , false ) end
875
879
876
880
-- Stop actions ---------------------------------------------------------------
877
- H .stop_completion = function (keep_source )
881
+ H .stop_completion = function (keep_source , keep_lsp_is_incomplete )
878
882
H .completion .timer :stop ()
879
883
H .cancel_lsp ({ H .completion })
880
884
H .completion .fallback , H .completion .force = true , false
881
- if H . completion . lsp . status == ' done-isincomplete ' then H .completion .lsp .status = ' done ' end
885
+ if not keep_lsp_is_incomplete then H .completion .lsp .is_incomplete = false end
882
886
if not keep_source then H .completion .source = nil end
883
887
end
884
888
0 commit comments