Skip to content

Ability to get the suggestion text #2

@SearidangPa

Description

@SearidangPa

I've been trying out augment completion and loved it much more than copilot. However, sometimes i want to be able to accept only a point. For this, I need something like copilot#GetDisplayedSuggestion.

Example

This is what i have to make copilot.vim accept until some char

local function highlight_jump_accept()
  local char = vim.fn.nr2char(vim.fn.getchar())
  local suggestion = vim.fn['copilot#GetDisplayedSuggestion']()
  local text = suggestion.text
  assert(suggestion, 'copilot#GetDisplayedSuggestion not found')
  assert(text, 'suggestion text not found')

  local matches = parse_suggestion(text, char)
  if #matches == 0 then
    return
  end

  if #matches == 1 then
    local partial = string.sub(text, 1, matches[1])
    vim.api.nvim_feedkeys(partial, 'n', false)
    return
  end
  local labels, ns = hightlight_label_for_jump(matches, text)
  jump_from_user_choice(labels, ns, text)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions