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:
parent
730d24f51d
commit
fb861daa38
83
init.lua
83
init.lua
@ -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)
|
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)
|
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
|
ui_notifications_enabled = true, -- disable notifications when toggling UI elements
|
||||||
-- Copilot
|
|
||||||
copilot_no_tab_map = true,
|
|
||||||
copilot_assume_mapped = true,
|
|
||||||
copilot_tab_fallback = "",
|
|
||||||
-- Taglist
|
-- Taglist
|
||||||
Tlist_Use_Right_Window = 1,
|
Tlist_Use_Right_Window = 1,
|
||||||
Tlist_GainFocus_On_ToggleOpen = 1,
|
Tlist_GainFocus_On_ToggleOpen = 1,
|
||||||
@ -184,7 +180,7 @@ local config = {
|
|||||||
["<leader>dl"] = { name = "Load launch.json" },
|
["<leader>dl"] = { name = "Load launch.json" },
|
||||||
["<leader>L"] = {
|
["<leader>L"] = {
|
||||||
"<cmd>LiveServer<cr>",
|
"<cmd>LiveServer<cr>",
|
||||||
desc = " Live server"
|
desc = " Live server",
|
||||||
},
|
},
|
||||||
-- Config loading
|
-- Config loading
|
||||||
["<leader>dlc"] = {
|
["<leader>dlc"] = {
|
||||||
@ -346,6 +342,10 @@ local config = {
|
|||||||
{
|
{
|
||||||
-- override nvim-cmp plugin
|
-- override nvim-cmp plugin
|
||||||
"hrsh7th/nvim-cmp",
|
"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
|
-- override the options table that is used in the `require("cmp").setup()` call
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
-- opts parameter is the default options table
|
-- opts parameter is the default options table
|
||||||
@ -353,29 +353,58 @@ local config = {
|
|||||||
local cmp = require "cmp"
|
local cmp = require "cmp"
|
||||||
local luasnip = require "luasnip"
|
local luasnip = require "luasnip"
|
||||||
-- modify the mapping part of the table
|
-- 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["<CR>"] = cmp.mapping.confirm { select = false }
|
||||||
opts.mapping["<Tab>"] = cmp.mapping(
|
opts.mapping["<TAB>"] = cmp.mapping.confirm { select = false }
|
||||||
function(fallback)
|
|
||||||
vim.api.nvim_feedkeys(
|
|
||||||
vim.fn["copilot#Accept"](vim.api.nvim_replace_termcodes("<Tab>", true, true, true)),
|
|
||||||
"n",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
end
|
|
||||||
)
|
|
||||||
if luasnip.expandable() then
|
if luasnip.expandable() then
|
||||||
luasnip.expand()
|
luasnip.expand()
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
opts.experimental = {
|
opts.sources = cmp.config.sources {
|
||||||
ghost_text = false, -- this feature conflict with copilot.vim's preview.
|
-- 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
|
return opts
|
||||||
end,
|
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
|
-- Editorconfig
|
||||||
{
|
{
|
||||||
@ -471,7 +500,7 @@ local config = {
|
|||||||
info = { "DiagnosticInfo", "#2563EB" },
|
info = { "DiagnosticInfo", "#2563EB" },
|
||||||
hint = { "DiagnosticHint", "#10B981" },
|
hint = { "DiagnosticHint", "#10B981" },
|
||||||
default = { "Identifier", "#7C3AED" },
|
default = { "Identifier", "#7C3AED" },
|
||||||
test = { "Identifier", "#FF00FF" }
|
test = { "Identifier", "#FF00FF" },
|
||||||
},
|
},
|
||||||
search = {
|
search = {
|
||||||
command = "rg",
|
command = "rg",
|
||||||
@ -503,7 +532,19 @@ local config = {
|
|||||||
|
|
||||||
-- Code completion
|
-- 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",
|
event = "User AstroFile",
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -517,9 +558,7 @@ local config = {
|
|||||||
-- Live server
|
-- Live server
|
||||||
{
|
{
|
||||||
"aurum77/live-server.nvim",
|
"aurum77/live-server.nvim",
|
||||||
run = function()
|
run = function() require("live_server.util").install() end,
|
||||||
require"live_server.util".install()
|
|
||||||
end,
|
|
||||||
cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" },
|
cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user