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
1 changed files with 93 additions and 54 deletions
147
init.lua
147
init.lua
|
@ -9,15 +9,15 @@
|
|||
local config = {
|
||||
-- Configure AstroNvim updates
|
||||
updater = {
|
||||
remote = "origin", -- remote to use
|
||||
channel = "nightly", -- "stable" or "nightly"
|
||||
version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
|
||||
branch = "nightly", -- branch name (NIGHTLY ONLY)
|
||||
commit = nil, -- commit hash (NIGHTLY ONLY)
|
||||
pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only)
|
||||
skip_prompts = false, -- skip prompts about breaking changes
|
||||
remote = "origin", -- remote to use
|
||||
channel = "nightly", -- "stable" or "nightly"
|
||||
version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
|
||||
branch = "nightly", -- branch name (NIGHTLY ONLY)
|
||||
commit = nil, -- commit hash (NIGHTLY ONLY)
|
||||
pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only)
|
||||
skip_prompts = false, -- skip prompts about breaking changes
|
||||
show_changelog = true, -- show the changelog after performing an update
|
||||
auto_quit = false, -- automatically quit the current session after a successful update
|
||||
auto_quit = false, -- automatically quit the current session after a successful update
|
||||
-- remotes = { -- easily add new remotes to track
|
||||
-- ["remote_name"] = "https://remote_url.come/repo.git", -- full remote url
|
||||
-- ["remote2"] = "github_user/repo", -- GitHub user/repo shortcut,
|
||||
|
@ -41,23 +41,19 @@ local config = {
|
|||
opt = {
|
||||
-- set to true or false etc.
|
||||
relativenumber = true, -- sets vim.opt.relativenumber
|
||||
number = true, -- sets vim.opt.number
|
||||
spell = false, -- sets vim.opt.spell
|
||||
signcolumn = "auto", -- sets vim.opt.signcolumn to auto
|
||||
wrap = false, -- sets vim.opt.wrap
|
||||
number = true, -- sets vim.opt.number
|
||||
spell = false, -- sets vim.opt.spell
|
||||
signcolumn = "auto", -- sets vim.opt.signcolumn to auto
|
||||
wrap = false, -- sets vim.opt.wrap
|
||||
},
|
||||
g = {
|
||||
mapleader = " ", -- sets vim.g.mapleader
|
||||
autoformat_enabled = true, -- enable or disable auto formatting at start (lsp.formatting.format_on_save must be enabled)
|
||||
cmp_enabled = true, -- enable completion at start
|
||||
autopairs_enabled = true, -- enable autopairs at start
|
||||
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)
|
||||
mapleader = " ", -- sets vim.g.mapleader
|
||||
autoformat_enabled = true, -- enable or disable auto formatting at start (lsp.formatting.format_on_save must be enabled)
|
||||
cmp_enabled = true, -- enable completion at start
|
||||
autopairs_enabled = true, -- enable autopairs at start
|
||||
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,
|
||||
|
@ -91,7 +87,7 @@ local config = {
|
|||
formatting = {
|
||||
-- control auto formatting on save
|
||||
format_on_save = {
|
||||
enabled = false, -- enable or disable format on save globally
|
||||
enabled = false, -- enable or disable format on save globally
|
||||
allow_filetypes = { -- enable format on save for specified filetypes only
|
||||
-- "go",
|
||||
},
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -430,8 +459,8 @@ local config = {
|
|||
-- keywords recognized as todo comments
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = " ", -- icon used for the sign, and in search results
|
||||
color = "error", -- can be a hex color, or a named color (see below)
|
||||
icon = " ", -- icon used for the sign, and in search results
|
||||
color = "error", -- can be a hex color, or a named color (see below)
|
||||
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
|
@ -443,8 +472,8 @@ local config = {
|
|||
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
|
||||
},
|
||||
gui_style = {
|
||||
fg = "NONE", -- The gui style to use for the fg highlight group.
|
||||
bg = "BOLD", -- The gui style to use for the bg highlight group.
|
||||
fg = "NONE", -- The gui style to use for the fg highlight group.
|
||||
bg = "BOLD", -- The gui style to use for the bg highlight group.
|
||||
},
|
||||
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
|
||||
-- highlighting of the line containing the todo comment
|
||||
|
@ -452,16 +481,16 @@ local config = {
|
|||
-- * keyword: highlights of the keyword
|
||||
-- * after: highlights after the keyword (todo text)
|
||||
highlight = {
|
||||
multiline = true, -- enable multine todo comments
|
||||
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
|
||||
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
|
||||
before = "", -- "fg" or "bg" or empty
|
||||
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
|
||||
after = "fg", -- "fg" or "bg" or empty
|
||||
multiline = true, -- enable multine todo comments
|
||||
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
|
||||
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
|
||||
before = "", -- "fg" or "bg" or empty
|
||||
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
|
||||
after = "fg", -- "fg" or "bg" or empty
|
||||
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
|
||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
||||
max_line_len = 400, -- ignore lines longer than this
|
||||
exclude = {}, -- list of file types to exclude highlighting
|
||||
comments_only = true, -- uses treesitter to match keywords in comments only
|
||||
max_line_len = 400, -- ignore lines longer than this
|
||||
exclude = {}, -- list of file types to exclude highlighting
|
||||
},
|
||||
-- list of named colors where we try to extract the guifg from the
|
||||
-- list of highlight groups or use the hex color if hl not found as a fallback
|
||||
|
@ -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" },
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue