Skip to content

Commit

Permalink
fix(codeium-vim): port mappings to astrocore and fix lazy loading e…
Browse files Browse the repository at this point in the history
…vent (#1077)

* refactor(codeium-vim): port mappings to `astrocore`

* feat(codeium-vim): add `cmd` and change `event` of the spec

* feat(codeium-vim): use the `CodiumToggle` command to toggle the mapping
  • Loading branch information
manuuurino authored Jul 2, 2024
1 parent 3cbe80a commit 5a7a7fa
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions lua/astrocommunity/completion/codeium-vim/init.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
return {
"Exafunction/codeium.vim",
event = "User AstroFile",
config = function()
vim.keymap.set("i", "<C-g>", function() return vim.fn["codeium#Accept"]() end, { expr = true })
vim.keymap.set("i", "<c-;>", function() return vim.fn["codeium#CycleCompletions"](1) end, { expr = true })
vim.keymap.set("i", "<c-,>", function() return vim.fn["codeium#CycleCompletions"](-1) end, { expr = true })
vim.keymap.set("i", "<c-x>", function() return vim.fn["codeium#Clear"]() end, { expr = true })
vim.keymap.set("n", "<Leader>;", function()
if vim.g.codeium_enabled == true then
vim.cmd "CodeiumDisable"
else
vim.cmd "CodeiumEnable"
end
end, { noremap = true, desc = "Toggle Codeium active" })
end,
cmd = {
"Codeium",
"CodeiumEnable",
"CodeiumDisable",
"CodeiumToggle",
"CodeiumAuto",
"CodeiumManual",
},
event = "BufEnter",
dependencies = {
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
mappings = {
n = {
["<Leader>;"] = {
"<Cmd>CodeiumToggle<CR>",
noremap = true,
desc = "Toggle Codeium active",
},
},
i = {
["<C-g>"] = {
function() return vim.fn["codeium#Accept"]() end,
expr = true,
},
["<C-;>"] = {
function() return vim.fn["codeium#CycleCompletions"](1) end,
expr = true,
},
["<C-,>"] = {
function() return vim.fn["codeium#CycleCompletions"](-1) end,
expr = true,
},
["<C-x>"] = {
function() return vim.fn["codeium#Clear"]() end,
expr = true,
},
},
},
},
},
}

0 comments on commit 5a7a7fa

Please sign in to comment.