diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index 8dacde2..d9c3b29 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -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({ diff --git a/neovim/lua/plugins/completion.lua b/neovim/lua/plugins/completion.lua index 40ddc1c..464f398 100644 --- a/neovim/lua/plugins/completion.lua +++ b/neovim/lua/plugins/completion.lua @@ -23,8 +23,8 @@ function M.config_cmp() }, mapping = cmp.mapping.preset.insert({ -- Scroll docs with readline back - forward - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), -- Expand snippets with Tab [""] = cmp.mapping(function(fallback) if luasnip.expand_or_jumpable() then diff --git a/neovim/lua/plugins/copilot.lua b/neovim/lua/plugins/copilot.lua new file mode 100644 index 0000000..f056225 --- /dev/null +++ b/neovim/lua/plugins/copilot.lua @@ -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"]("\\") + else + return utils.t("") + end +end + +M.setup = function() + vim.g.copilot_no_tab_map = false + utils.keymap_set("i", "", M.copilot_accept, { expr = true, replace_keycodes = false, noremap = true }) + utils.keymap_set("i", "", M.copilot_accept, { expr = true, replace_keycodes = false, noremap = true }) +end + +M.setup() + +return M