Closed MariaSolOs closed 1 year ago
Reproduction steps would really help.
I fixed it with a simple autocommand for
InsertLeave
What did you do inside that autocmd?
@MunifTanjim unfortunately I haven't been able to pinpoint exactly when it happens :( I apologize for the lack of information. I do use the vim.b.copilot_suggestion_hidden
toggling described in the README to make it not step over completions, so maybe something is going out of sync there?
What did you do inside that autocmd?
Just this:
local dismiss = function()
if copilot.is_visible() then copilot.dismiss() end
end
vim.api.nvim_create_autocmd('InsertLeave', {
pattern = '*',
callback = dismiss,
})
@MunifTanjim Would you be against me preparing a PR for this? :)
I'm not against a PR. But I'd like to reproduce it with minimal config first... You know, just to rule out that it is indeed a bug caused by this plugin, and not by your config or some other plugins.
Can you please create a repro.lua
file:
local root = vim.fn.fnamemodify(vim.trim(vim.fn.system("git rev-parse --show-toplevel")), ":p") .. ".repro"
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
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)
local plugins = {
"folke/tokyonight.nvim",
{
"zbirenbaum/copilot.lua",
opts = {},
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd("colorscheme tokyonight")
nvim -u repro.lua
If it's reproducible, share the modified repro.lua
file?
Found the repro! :) It doesn't require any special setup, just use the <C-c>
mapping to exit insert mode.
Now I understand why this doesn't dismiss the suggestion: According to the docs, "it doesn't trigger the InsertLeave event", which this plugin relies on.
That also means that my auto command above doesn't work lol.
So it's the same as https://github.com/zbirenbaum/copilot.lua/issues/179#issuecomment-1586132731... In that case, it's an expected behavior.
That's fair. I'll close this then.
It rarely happens, but sometimes Copilot will still display the last suggestion when leaving insert mode. I fixed it with a simple autocommand for
InsertLeave
, but I think there's a missing logic for that here.