codeium.vim
codeium.vim copied to clipboard
Can't accept suggestion
I am trying to use the right arrow to accept a codeium suggestion:
{
'Exafunction/codeium.vim',
config = function ()
vim.keymap.set('i', '<Right>', function () return vim.fn['codeium#Accept']() end, { expr = true })
end
},
It accepts the suggestion ok, but when I am in the middle of a word and press <Right> it inserts a <Tab>.
Edit: fix formatting in last line
I think there is a conflict with nvim-cmp. I am using LazyVim
I disabled nvim-cmp and cmp-nvim-lsp, but the issue persists.
Similar issue here. It works with:
vim.keymap.set('i', '<a-a>', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true, desc = "Codeium accept"})
but doesn't work with another binding:
local cmp_mappings = {
['<Tab>'] = cmp.mapping(
function(fallback)
return vim.fn['codeium#Accept']()
end, {"i","s"}),
}
cmp.setup({
mapping = cmp_mappings
})
The function is executed in second case but the text is not inserted.
Similar issue here. Keybinding to codeium#Accept does not work whereas codeium#CycleCompletions(1) works. I tried swapping the keybinds of the two commands anticipating the Accept function would start working and the CycleCompletions would break but no. CycleCompletions worked with the new keybinding and codeium#Accept still did not work.
I am using NVChad base configuration
Keybindings:
["<C-a>"] = { -- Does not work
function()
return vim.fn['codeium#Accept']()
end,
"Codeium Accept",
expr = true
},
["<C-s>"] = {
function()
return vim.fn['codeium#CycleCompletions'](1)
end,
"Codeium Accept",
expr = true
},
I'm experiencing probably the same problem, I have this in my config: vim.keymap.set('i', '<M-p>', function () return vim.fn['codeium#Accept']() end, { expr = true }) and when I inspect the mapping with vim.api.nvim_get_keymap("i") after the plugin is loaded I see that the rhs of the mapping is nil. When, however, I run the vim.keymap.set command manually, the mapping is created correctly and <M-p> accepts suggestions.
I'm experiencing probably the same problem, I have this in my config:
vim.keymap.set('i', '<M-p>', function () return vim.fn['codeium#Accept']() end, { expr = true })and when I inspect the mapping withvim.api.nvim_get_keymap("i")after the plugin is loaded I see that therhsof the mapping isnil. When, however, I run thevim.keymap.setcommand manually, the mapping is created correctly and<M-p>accepts suggestions.
So apparently, rhs being nil is normal for keymaps created with {expr = true}. I've created a minimal init.lua with just lazy.nvim and codeium.vim and with it <M-p> mapping for codeium#Accept works as expected. So there probably is some interaction with some other plugin or setting that I have. I'll probably try bisecting my config to figure out what is causing the issue.
This is an issue for me too. In the meantime, there's a hacky workaround using feedkeys (replace vim.fn[...]() with it):
vim.fn.feedkeys(vim.api.nvim_replace_termcodes(vim.fn["codeium#Accept"](), true, true, true), "")
In my case the problem was that the <M-p> mapping was overridden by the vim-rsi plugin. I've replaced it with a different readline plugin that suits my needs even better and now I can use <M-p> for accepting completions without any problems.
Any update of a possible fix for this apart from the workarounds?
I have alot of plugins and little time to disable each one to find which one is messing with the codeium#Accept mapping.
So far, @eerii's fix works for me, but i'd like the completion to be abit more seemless/natural(for lack of a better word) because there's a bit of a flash using the vim.fn.feedkeys method
I am having a similar issue. In insert mode if i hit <Tab> it just inserts tabs and does not accept the suggestion, I am using LazyVim. None of the work-arounds above worked for me, I guess it is back to copilot in the meantime as that just works :/
Same here with this config:
{
'Exafunction/codeium.vim',
keys = {
{ '<C-a>', '<Cmd>call codeium#CycleCompletions(1)<CR>', { noremap = true, silent = true, expr = true }, mode = "i" },
{ '<C-A>', '<Cmd>call codeium#CycleCompletions(-1)<CR>', { noremap = true, silent = true, expr = true }, mode = "i" },
{ '<C-l>', '<Cmd>call codeium#Accept()<CR>', { noremap = true, silent = true, expr = true }, mode = "i" },
{ '<leader>c', '<Cmd>call codeium#Chat()<CR>', { noremap = true, silent = true }, mode = "n", desc = " Chat with Codeium" },
},
config = function()
vim.g.codeium_disable_bindings = true
vim.g.codeium_no_map_tab = true
vim.g.codeium_enabled = true
end
}
Also, I dont want the .nvim version, since I use coc.nvim as a completor engine, and I want the bot to be separeted from pyright suggestions and so.
This is now working :rocket:
local M = {
'Exafunction/codeium.vim',
config = function()
-- Change '<C-g>' here to any keycode you like.
vim.keymap.set('i', '<C-l>', function() return vim.fn['codeium#Accept']() end, { expr = true, silent = true })
vim.keymap.set('i', '<c-a>', function() return vim.fn['codeium#CycleCompletions'](1) end,
{ expr = true, silent = true })
vim.keymap.set('i', '<c-z>', function() return vim.fn['codeium#CycleCompletions'](-1) end,
{ expr = true, silent = true })
vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true })
end
}