Closed deathbeam closed 3 months ago
Any hints regarding where require("CopilotChat.integrations.cmp").setup()
should be called? As part of cmp
setup? Or as part of CopilotChat
setup?
Any hints regarding where
require("CopilotChat.integrations.cmp").setup()
should be called? As part ofcmp
setup? Or as part ofCopilotChat
setup?
As part of copilot chat setup ideally but it doesnt rly matter when you call it as long as both plugins will get loaded at some point as all this does is registers the source and filetype to nvim-cmp so it do not requires calling setup on either copilot chat or nvim cmp beforehand.
Got it. I added it as a part of CopilotChat
setup with lazy
and it works, like so:
config = function(_, opts)
require('CopilotChat').setup(opts)
require('CopilotChat.integrations.cmp').setup()
end,
@deathbeam with the new nvim-cmp integration when you select/accept an item from the cmp list it lists / unhides the buffer.
You should be able to add something like the following... but keep in mind it still will flash as listed for a split second and then unlist again. So maybe you can find a better way 🤷♂️
---Executed after the item was selected.
---@param completion_item lsp.CompletionItem
---@param callback fun(completion_item: lsp.CompletionItem|nil)
function Source:execute(completion_item, callback)
callback(completion_item)
-- reset the buffer listed to false
vim.api.nvim_set_option_value('buflisted', false, { buf = 0 })
end
You should be able to add something like the following... but keep in mind it still will flash as listed for a split second and then unlist again. So maybe you can find a better way 🤷♂️
---Executed after the item was selected. ---@param completion_item lsp.CompletionItem ---@param callback fun(completion_item: lsp.CompletionItem|nil) function Source:execute(completion_item, callback) callback(completion_item) -- reset the buffer listed to false vim.api.nvim_set_option_value('buflisted', false, { buf = 0 }) end
Hmm thats pretty annoying. But split second is probably fine, better than it staying there. Not sure if its worth trying to find the root cause as it sounds like nvim-cmp bug, so your workaround should be good enough for now. Do you want to PR it?
I will submit a PR.
Also I have some notes that said I researched it a bit and it is an upstream thing from nvim-cmp that is outside of our control... FYI.
@deathbeam PR submitted: #346