Skip to content

Commit

Permalink
Bring copilot back
Browse files Browse the repository at this point in the history
  • Loading branch information
JafarAbdi committed Jul 15, 2024
1 parent 9d841ac commit 9071569
Show file tree
Hide file tree
Showing 4 changed files with 654 additions and 491 deletions.
35 changes: 28 additions & 7 deletions neovim/.config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ end
require("lazy").setup({
{ "mfussenegger/nvim-qwahl" },
{ "mfussenegger/nvim-fzy" },
{ "Exafunction/codeium.vim", event = "VeryLazy" },
{ "github/copilot.vim", event = "VeryLazy" },
{
"mfussenegger/nvim-dap",
event = "VeryLazy",
Expand Down Expand Up @@ -1176,8 +1176,13 @@ end
vim.g.mapleader = " "
vim.g.maplocalleader = " "

vim.g.codeium_disable_bindings = 1
vim.g.codeium_filetypes = {
vim.g.copilot_node_command = vim.env.HOME .. "/myconfigs/.pixi/envs/nodejs/bin/node"
vim.g.copilot_no_tab_map = true
vim.g.copilot_no_maps = true
vim.g.copilot_assume_mapped = true
vim.g.copilot_tab_fallback = ""
vim.g.copilot_filetypes = {
["*"] = true,
gitcommit = false,
["dap-repl"] = false,
}
Expand Down Expand Up @@ -1236,19 +1241,35 @@ end, { expr = true })
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })

vim.keymap.set("i", "<M-e>", function()
return vim.api.nvim_feedkeys(vim.fn["codeium#Accept"](), "n", true)
return vim.api.nvim_feedkeys(
vim.fn["copilot#Accept"](vim.api.nvim_replace_termcodes("<Tab>", true, true, true)),
"n",
true
)
end, { expr = true })
vim.keymap.set("i", "<c-;>", function()
return vim.fn["codeium#CycleCompletions"](1)
return vim.fn["copilot#Next"]()
end, { expr = true })
vim.keymap.set("i", "<c-,>", function()
return vim.fn["codeium#CycleCompletions"](-1)
return vim.fn["copilot#Previous"]()
end, { expr = true })
vim.keymap.set("i", "<c-c>", function()
-- Leave insert mode and cancel completion
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<ESC>", true, true, true), "n", true)
return vim.fn["codeium#Clear"]()
return vim.fn["copilot#Dismiss"]()
end, { expr = true })
local function accept_word()
vim.fn["copilot#Accept"]("")
local bar = vim.fn["copilot#TextQueuedForInsertion"]()
return vim.fn.split(bar, [[[ .]\zs]])[1]
end
local function accept_line()
vim.fn["copilot#Accept"]("")
local bar = vim.fn["copilot#TextQueuedForInsertion"]()
return vim.fn.split(bar, [[[\n]\zs]])[1]
end
vim.keymap.set("i", "<C-M-l>", accept_line, { expr = true, remap = false })
vim.keymap.set("i", "<C-M-e>", accept_word, { expr = true, remap = false })

vim.keymap.set("n", "gs", function()
q.try(q.lsp_tags, q.buf_tags)
Expand Down
6 changes: 3 additions & 3 deletions neovim/.config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"branch": "main",
"commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d"
},
"codeium.vim": {
"branch": "main",
"commit": "decfb541c9fd176f467991dcde8923c7db362e02"
"copilot.vim": {
"branch": "release",
"commit": "25f73977033c597d530c7ab0e211d99b60927d2d"
},
"lazy.nvim": {
"branch": "main",
Expand Down
Loading

0 comments on commit 9071569

Please sign in to comment.