Skip to content

NES after inline suggestion - incorrect suggestions #628

@bjarosze

Description

@bjarosze

I have enabled folke/sidekick NES and copilot.lua inline suggestions. I would like to use these features together like this:

Image

Workflow: Go to insert mode, start typing, accept suggestions word-by-word, go to normal mode, and trigger NES.

Currently, this doesn't work.

I tried to debug this and found two issues:

  1. copilot.lua suggestions are accepted using vim.lsp.util.apply_text_edits.

Every time vim.lsp.util.apply_text_edits function is called, mode changes to normal and back to insert. This triggers the "InsertEnter" event and clears the next edit suggestion. Changing this to vim.api.nvim_buf_set_lines solves the issue, since we never leave insert mode and are just updating the current buffer.

  1. Autoindent hack.

Not sure why, but this:

    vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Space><Left><Del>", true, false, true), "n", false)

causes a problem - suggestions are incorrect. E.g.:
Image

It looks like copilot lsp is not aware of this change.
Removing this line solves this issue, but I'm not sure what this hack is supposed to do. In my tests, there is no difference with or without it.

I have prepared a PR with the above changes: #627
Please let me know if vim.lsp.util.apply_text_edits can be safely replaced and if autoindent hack can be removed (and if not, how I could test what it does).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions