Open jjohnston-aims opened 1 year ago
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 therhs
of the mapping isnil
. When, however, I run thevim.keymap.set
command 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), "")
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
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
}
-- The configuration below provides a robust setup with custom keybindings that work perfectly with Codeium
-- Codeium: AI-powered code completion and suggestions
return {
"Exafunction/codeium.nvim",
event = "BufEnter",
dependencies = {
"nvim-lua/plenary.nvim",
"hrsh7th/nvim-cmp",
-- "lspkind.nvim", -- Added missing dependency
},
config = function()
-- Disable default bindings
vim.g.codeium_disable_bindings = 1
-- Custom keymaps table
local keymaps = {
accept = {
mode = "i",
lhs = "<M-a>",
rhs = function()
return vim.fn["codeium#Accept"]()
end,
opts = { silent = true, expr = true },
},
next = {
mode = "i",
lhs = "<M-]>",
rhs = function()
return vim.fn["codeium#CycleCompletions"](1)
end,
opts = { expr = true },
},
prev = {
mode = "i",
lhs = "<M-[>",
rhs = function()
return vim.fn["codeium#CycleCompletions"](-1)
end,
opts = { expr = true },
},
clear = {
mode = "i",
lhs = "<Esc>",
rhs = function()
return vim.fn["codeium#Clear"]()
end,
opts = { expr = true },
},
}
-- Apply keymaps
for _, mapping in pairs(keymaps) do
vim.keymap.set(mapping.mode, mapping.lhs, mapping.rhs, mapping.opts)
end
require("codeium").setup({
})
end,
}
Hate to say "Same Issue here", but even after a year only @eerii workaround works for me without trying to locate what other plugin collides and causes this issue. I know that without the workaround, "Accept" works, but only with minimal plugins loaded. (NeoVim / LazyVim)
I am trying to use the right arrow to accept a codeium suggestion:
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