feat(copilot)!: move from copilot.vim to copilot.lua and copilot-cmp

Breaking change: Tab completion no longer does anything - it just adds a
tab as it should
- To use completion use CTRL + J and CTRL + K
This commit is contained in:
Jiří Štefka 2023-09-22 21:53:13 +02:00
parent 730d24f51d
commit fb861daa38
Signed by: jiriks74
GPG key ID: 1D5E30D3DB2264DE

View file

@ -54,10 +54,6 @@ local config = {
diagnostics_mode = 3, -- set the visibility of diagnostics in the UI (0=off, 1=only show in status line, 2=virtual text off, 3=all on)
icons_enabled = true, -- disable icons in the UI (disable if no nerd font is available, requires :PackerSync after changing)
ui_notifications_enabled = true, -- disable notifications when toggling UI elements
-- Copilot
copilot_no_tab_map = true,
copilot_assume_mapped = true,
copilot_tab_fallback = "",
-- Taglist
Tlist_Use_Right_Window = 1,
Tlist_GainFocus_On_ToggleOpen = 1,
@ -184,7 +180,7 @@ local config = {
["<leader>dl"] = { name = "Load launch.json" },
["<leader>L"] = {
"<cmd>LiveServer<cr>",
desc = " Live server"
desc = " Live server",
},
-- Config loading
["<leader>dlc"] = {
@ -346,6 +342,10 @@ local config = {
{
-- override nvim-cmp plugin
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-emoji", -- add cmp source as dependency of cmp
"zbirenbaum/copilot.lua",
},
-- override the options table that is used in the `require("cmp").setup()` call
opts = function(_, opts)
-- opts parameter is the default options table
@ -353,29 +353,58 @@ local config = {
local cmp = require "cmp"
local luasnip = require "luasnip"
-- modify the mapping part of the table
-- Disable tab completion, use CTRL + J or CTRL + K instead
opts.mapping["<CR>"] = cmp.mapping.confirm { select = false }
opts.mapping["<Tab>"] = cmp.mapping(
function(fallback)
vim.api.nvim_feedkeys(
vim.fn["copilot#Accept"](vim.api.nvim_replace_termcodes("<Tab>", true, true, true)),
"n",
true
)
end
)
opts.mapping["<TAB>"] = cmp.mapping.confirm { select = false }
if luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
fallback()
end
opts.experimental = {
ghost_text = false, -- this feature conflict with copilot.vim's preview.
opts.sources = cmp.config.sources {
-- Copilot Source
{ name = "copilot", group_index = 2 },
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750 },
{ name = "buffer", priority = 500 },
{ name = "path", priority = 250 },
{ name = "emoji", priority = 700 }, -- add new source
}
-- return the new table to be used
return opts
end,
},
{
"onsails/lspkind.nvim",
opts = {
mode = "symbol",
symbol_map = {
-- Copilot icon
Copilot = "",
Array = "󰅪",
Boolean = "",
Class = "󰌗",
Constructor = "",
Key = "󰌆",
Namespace = "󰅪",
Null = "NULL",
Number = "#",
Object = "󰀚",
Package = "󰏗",
Property = "",
Reference = "",
Snippet = "",
String = "󰀬",
TypeParameter = "󰊄",
Unit = "",
},
menu = {},
},
enabled = vim.g.icons_enabled,
config = require "plugins.configs.lspkind",
},
-- Editorconfig
{
@ -471,7 +500,7 @@ local config = {
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
test = { "Identifier", "#FF00FF" },
},
search = {
command = "rg",
@ -503,7 +532,19 @@ local config = {
-- Code completion
{
"github/copilot.vim",
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "User AstroFile",
config = function()
require("copilot").setup {
suggestion = { enabled = false },
panel = { enabled = false },
}
end,
},
{
"zbirenbaum/copilot-cmp",
config = function() require("copilot_cmp").setup() end,
event = "User AstroFile",
},
@ -517,9 +558,7 @@ local config = {
-- Live server
{
"aurum77/live-server.nvim",
run = function()
require"live_server.util".install()
end,
run = function() require("live_server.util").install() end,
cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" },
},