diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index e86f6a4..0d253c5 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -260,9 +260,20 @@ return require("packer").startup(function() -- copilot use({ - "github/copilot.vim", + "zbirenbaum/copilot.lua", + event = "VimEnter", config = function() - require("plugins/copilot") + vim.defer_fn(function() + require("plugins/copilot") + end, 100) + end, + }) + + use({ + "zbirenbaum/copilot-cmp", + after = { "copilot.lua" }, + config = function() + require("copilot_cmp").setup() end, }) end) diff --git a/.config/nvim/lua/plugins/copilot.lua b/.config/nvim/lua/plugins/copilot.lua index 7192bd0..21f3e63 100644 --- a/.config/nvim/lua/plugins/copilot.lua +++ b/.config/nvim/lua/plugins/copilot.lua @@ -1,15 +1,39 @@ -local map = function(type, key, value, opts) - local options = { noremap = true } - if opts then - options = vim.tbl_extend("force", options, opts) - end - vim.api.nvim_set_keymap(type, key, value, options) -end +local copilot = require("copilot") -map("i", "", [[copilot#Accept("")]], { noremap = true, silent = true, expr = true }) - -vim.g.copilot_no_tab_map = true -vim.g.copilot_assume_mapped = true -vim.g.copilot_tab_fallback = "" - -vim.g.copilot_no_tab_map = true +copilot.setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "", + }, + }, + suggestion = { + enabled = true, + auto_trigger = false, + debounce = 75, + keymap = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + }, + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + svn = false, + cvs = false, + ["."] = false, + }, + copilot_node_command = "node", -- Node version must be < 18 + server_opts_overrides = {}, +}) diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua index a9b5855..6113c62 100644 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -43,6 +43,10 @@ cmp.setup({ [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), [""] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), @@ -73,14 +77,9 @@ cmp.setup({ }, sources = cmp.config.sources({ - { - name = "buffer", - priority = 1, - }, - { - name = "luasnip", - priority = 4, - }, + { name = "buffer", priority = 1 }, + { name = "luasnip", priority = 4 }, + { name = "copilot", group_index = 5 }, { name = "tmux", priority = 2, @@ -89,13 +88,7 @@ cmp.setup({ trigger_characters = {}, }, }, - { - name = "nvim_lsp", - priority = 3, - }, - { - name = "nvim_lsp_signature_help", - priority = 4, - }, + { name = "nvim_lsp", priority = 3 }, + { name = "nvim_lsp_signature_help", priority = 4 }, }), })