From 693e9e106189b6cd1399776b95997d33591e3ac8 Mon Sep 17 00:00:00 2001 From: ttyS3 Date: Mon, 6 Jun 2022 18:17:48 +0800 Subject: [PATCH] feat(completion): add github copilot cmp source --- lua/config/nvim-cmp.lua | 21 +++++++++++++-------- lua/plugins.lua | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua index 3a4ec36..da51eed 100644 --- a/lua/config/nvim-cmp.lua +++ b/lua/config/nvim-cmp.lua @@ -76,26 +76,30 @@ cmp.setup { }), }, sources = { - { name = "nvim_lsp" }, + -- https://github.com/hrsh7th/cmp-copilot + -- https://github.com/zbirenbaum/copilot-cmp + { name = "copilot", group_index = 1 }, + + { name = "cmp_tabnine", group_index = 2 }, + + { name = "nvim_lsp", group_index = 3 }, -- For vsnip user. -- { name = "vsnip" }, -- For luasnip user. - { name = "luasnip" }, + { name = "luasnip", group_index = 4 }, + + { name = "nvim_lua", group_index = 4 }, -- For ultisnips user. -- { name = "ultisnips" }, - { name = "crates" }, - - { name = "cmp_tabnine" }, - - { name = "nvim_lua" }, + { name = "crates", group_index = 4 }, -- { name = "omni" }, - { name = "buffer" }, + { name = "buffer", group_index = 9 }, }, formatting = { format = require("lsp").cmp_format { @@ -109,6 +113,7 @@ cmp.setup { crates = "[Crates]", cmp_tabnine = "[TabNine]", latex_symbols = "[Latex]", + copilot = "[Copilot]", }, }, }, diff --git a/lua/plugins.lua b/lua/plugins.lua index ff158e2..c200941 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -261,6 +261,20 @@ return require("packer").startup { -- use "hrsh7th/cmp-omni" use "hrsh7th/cmp-buffer" use "hrsh7th/cmp-path" + use { + "zbirenbaum/copilot.lua", + event = { "VimEnter" }, + requires = "github/copilot.vim", + config = function() + vim.defer_fn(function() + require("copilot").setup() + end, 100) + end, + } + use { + "zbirenbaum/copilot-cmp", + after = { "copilot.lua", "nvim-cmp" }, + } use { "tzachar/cmp-tabnine", run = "./install.sh",