Use ctrl+f for copilot complete

Similar to fish
This commit is contained in:
ViViDboarder 2024-06-12 12:36:30 -07:00
parent 46baaf7c1e
commit 4a042358f6
3 changed files with 28 additions and 2 deletions

View File

@ -622,6 +622,10 @@ use({
use({ use({
"https://github.com/github/copilot.vim", "https://github.com/github/copilot.vim",
disable = not vim.g.install_copilot, disable = not vim.g.install_copilot,
config = function()
require("plugins.copilot")
end,
after = "vim-rsi",
}) })
use({ use({

View File

@ -23,8 +23,8 @@ function M.config_cmp()
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
-- Scroll docs with readline back - forward -- Scroll docs with readline back - forward
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-U>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-D>"] = cmp.mapping.scroll_docs(4),
-- Expand snippets with Tab -- Expand snippets with Tab
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then if luasnip.expand_or_jumpable() then

View File

@ -0,0 +1,22 @@
local utils = require("utils")
local M = {}
function M.copilot_accept()
local suggest = vim.fn["copilot#GetDisplayedSuggestion"]()
if next(suggest.item) ~= nil then
print("accept cp")
return vim.fn["copilot#Accept"]("\\<CR>")
else
return utils.t("<Right>")
end
end
M.setup = function()
vim.g.copilot_no_tab_map = false
utils.keymap_set("i", "<C-F>", M.copilot_accept, { expr = true, replace_keycodes = false, noremap = true })
utils.keymap_set("i", "<Right>", M.copilot_accept, { expr = true, replace_keycodes = false, noremap = true })
end
M.setup()
return M