zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.45k stars 67 forks source link

Unable to manually trigger suggestion #135

Closed matthewsia98 closed 1 year ago

matthewsia98 commented 1 year ago

Config in the left window Keymaps defined in the upper right window

  1. Suggestion auto triggers
  2. I dismiss suggestion with <C-c>
  3. I try to manually complete with <C-y> but it doesn't work

https://user-images.githubusercontent.com/71731492/221452483-6caab648-d71d-492b-9421-692393b22809.mp4

Steps to reproduce

  1. nvim -u minimal.lua test.lua
  2. :Copilot auth
  3. Type -- print hello world in first line
  4. Virtual text should auto trigger
  5. Dismiss suggestion with <C-c>
  6. Press <C-n> to trigger next suggestion

Expected behavior

Same suggestion that was just dismissed should appear again

minimal.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    "folke/noice.nvim",
    -- add any other plugins here
    {
        "neovim/nvim-lspconfig",
        event = "BufReadPre",
        config = function() end,
    },
    {
        "zbirenbaum/copilot.lua",
        cmd = "Copilot",
        event = "InsertEnter",
        config = function()
            require("copilot").setup({
                panel = { enabled = false },
                suggestion = {
                    enabled = true,
                    auto_trigger = true,
                    debounce = 75,
                    -- Keymaps defined in ~/.config/nvim/lua/plugins/completion/keymaps.lua
                    keymap = {
                        accept = "<C-CR>",
                        accept_word = false,
                        accept_line = "<C-Space>",
                        next = "<C-n>",
                        prev = "<C-p>",
                        dismiss = "<C-c>",
                    },
                },
                server_opts_overrides = {
                    settings = {
                        advanced = {
                            inlineSuggestCount = 5,
                        },
                    },
                },
            })
        end,
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
MunifTanjim commented 1 year ago

What's the output of :verbose imap <C-y>?

matthewsia98 commented 1 year ago
11:58:14 PM msg_show   verbose imap <C-y> i  <C-Y>       * <Lua 413: ~/.config/nvim/lua/plugins/completion/keymaps.lua:14>
    Last set from Lua
MunifTanjim commented 1 year ago

I see that you're hitting <C-y> repeatedly. Can you try waiting a bit? Sometimes it takes copilot a while to generate suggestion.

Also, try writing a few characters and then hit <C-y> to see if it works.

matthewsia98 commented 1 year ago

Doesn't seem to work reliably. Updated original post with minimal config and steps to reproduce

MunifTanjim commented 1 year ago

Can you try with https://github.com/zbirenbaum/copilot.lua/pull/136? @matthewsia98

matthewsia98 commented 1 year ago

Seems to work