Skip to content

Commit

Permalink
Use ctrl+f for copilot complete
Browse files Browse the repository at this point in the history
Similar to fish
  • Loading branch information
ViViDboarder committed Jun 12, 2024
1 parent 46baaf7 commit 4a04235
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions neovim/lua/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ use({
use({
"https://github.com/github/copilot.vim",
disable = not vim.g.install_copilot,
config = function()
require("plugins.copilot")
end,
after = "vim-rsi",
})

use({
Expand Down
4 changes: 2 additions & 2 deletions neovim/lua/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function M.config_cmp()
},
mapping = cmp.mapping.preset.insert({
-- Scroll docs with readline back - forward
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-U>"] = cmp.mapping.scroll_docs(-4),
["<C-D>"] = cmp.mapping.scroll_docs(4),
-- Expand snippets with Tab
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
Expand Down
22 changes: 22 additions & 0 deletions neovim/lua/plugins/copilot.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4a04235

Please sign in to comment.