Closed gpncarl closed 2 years ago
I get this as well
@gpncarl It was in on-attach, but moving it to the end of on-init means that it sends once to the rpc (as it should) after the initial attach. If it is in on-attach, every time a new buffer is opened and copilot attaches to it, the request is resent.
I believe I fixed this as a response to another issue yesterday. Please packer sync and let me know if you can reproduce it.
@zbirenbaum I still call reproduce it
vim.lsp.buf_request_sync
in function send_editor_info
need buffer attached first
but on_attach
is called later than on_init
Yes, on_init is called before on_attach, but we don't need to send it every on_attach. Take a look at the code for on_init:
on_init = function(client, _)
vim.lsp.buf_attach_client(0, client.id)
if vim.fn.has("nvim-0.7") then
vim.api.nvim_create_autocmd({ "BufEnter" }, {
callback = function()
util.attach_copilot()
end,
once = false,
})
else
vim.cmd("au BufEnter * lua require('copilot.util').attach_copilot()")
end
send_editor_info()
end,
vim.lsp.buf_attach_client(0, client.id)
is the very first thing called. At this point, on_attach
will be called. on_attach
will also be called every time the autocmd subsequently triggers. send_editor_info()
is called only once, at the end of on init, which is well after vim.lsp.buf_attach_client(0, client.id)
is called. I can't reproduce this behavior at all, and I am very confused as to why it is doing it for you.
If you have a moment, I would like to try doing a vim.schedule
on it and see if that fixes your issue.
Ya know what, it seems to function without sending editor info, and considering it is hardcoded, I'm just going to remove the call to it for now. Scheduling should fix the issue but it's not worth the effort for something that is probably only there for Micro$oft's telemetry....
It's gone now. Hopefully this doesn't cause any other issues but I doubt it will honestly.
https://github.com/zbirenbaum/copilot.lua/blob/b16f659a55f68a53b407dbc34e52456c4ec41f26/lua/copilot/copilot_handler.lua#L53
why not send_editor_info on_attach?