autocomplete.nvim icon indicating copy to clipboard operation
autocomplete.nvim copied to clipboard

how to handle the lsp.CompletionTriggerKind.TriggerForIncompleteCompletions?

Open latteyt opened this issue 1 year ago • 2 comments

sorry, i donot how to resolve the lsp.CompletionTriggerKind.TriggerForIncompleteCompletions (the completion response type).

could you suggest where i can find how it implented???

latteyt avatar Jul 20 '24 05:07 latteyt

For example, if we request a textDocument_completion, we may receive the incomplete result, and we need request with lsp.CompletionTriggerKind.TriggerForIncompleteCompletions again so as to acquire all the completion items

latteyt avatar Jul 20 '24 07:07 latteyt

  elseif ctx:get_reason() ~= types.cmp.ContextReason.TriggerOnly then
    if offset < ctx.cursor.col and self:get_keyword_length() <= (ctx.cursor.col - offset) then
      if self.incomplete and self.context.cursor.col ~= ctx.cursor.col and self.status ~= source.SourceStatus.FETCHING then
        completion_context = {
          triggerKind = types.lsp.CompletionTriggerKind.TriggerForIncompleteCompletions,
        }
      elseif not vim.tbl_contains({ self.request_offset, self.offset }, offset) then
        completion_context = {
          triggerKind = types.lsp.CompletionTriggerKind.Invoked,
        }
      end
    else
      self:reset() -- Should clear current completion if the TriggerKind isn't TriggerCharacter or Manual and keyword length does not enough.
    end

An example case of nvim-cmp

latteyt avatar Jul 20 '24 07:07 latteyt

Changed the implementation to use vim native vim.lsp.completion.trigger() so this is now upstream issue if anything

deathbeam avatar Mar 02 '25 01:03 deathbeam