Add copilot plugins
Finally accepting our new robot overlords.
This commit is contained in:
parent
eb1b2e5e8c
commit
61298ee2f0
@ -325,6 +325,20 @@ return require('packer').startup(function(use)
|
|||||||
require('plugins.typescript-nvim')
|
require('plugins.typescript-nvim')
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
use {
|
||||||
|
'zbirenbaum/copilot.lua',
|
||||||
|
cmd = 'Copilot',
|
||||||
|
event = 'InsertEnter',
|
||||||
|
config = function()
|
||||||
|
require('plugins.copilot')
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
use {
|
||||||
|
'zbirenbaum/copilot-cmp',
|
||||||
|
config = function ()
|
||||||
|
require('copilot_cmp').setup()
|
||||||
|
end
|
||||||
|
}
|
||||||
use 'ziglang/zig.vim'
|
use 'ziglang/zig.vim'
|
||||||
use {
|
use {
|
||||||
'akinsho/bufferline.nvim',
|
'akinsho/bufferline.nvim',
|
||||||
|
4
lua/plugins/copilot.lua
Normal file
4
lua/plugins/copilot.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
require('copilot').setup({
|
||||||
|
suggestion = { enabled = false },
|
||||||
|
panel = { enabled = false },
|
||||||
|
});
|
@ -1,6 +1,12 @@
|
|||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local lspkind = require('lspkind')
|
local lspkind = require('lspkind')
|
||||||
|
|
||||||
|
local has_words_before = function()
|
||||||
|
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil
|
||||||
|
end
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
experimental = { ghost_text = true },
|
experimental = { ghost_text = true },
|
||||||
snippet = {
|
snippet = {
|
||||||
@ -23,8 +29,8 @@ cmp.setup({
|
|||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() and has_words_before() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
@ -48,6 +54,7 @@ cmp.setup({
|
|||||||
priority = 100,
|
priority = 100,
|
||||||
group_index = 1,
|
group_index = 1,
|
||||||
},
|
},
|
||||||
|
{ name = "copilot", group_index = 2 },
|
||||||
{
|
{
|
||||||
name = 'buffer',
|
name = 'buffer',
|
||||||
priority = 80,
|
priority = 80,
|
||||||
@ -64,8 +71,21 @@ cmp.setup({
|
|||||||
-- { name = 'snippy' }, -- For snippy users.
|
-- { name = 'snippy' }, -- For snippy users.
|
||||||
}),
|
}),
|
||||||
sorting = {
|
sorting = {
|
||||||
|
priority_weight = 2,
|
||||||
comparators = {
|
comparators = {
|
||||||
function(...) return require('cmp_buffer'):compare_locality(...) end,
|
require("copilot_cmp.comparators").prioritize,
|
||||||
|
require("copilot_cmp.comparators").score,
|
||||||
|
-- Below is the default comparitor list and order for nvim-cmp
|
||||||
|
cmp.config.compare.offset,
|
||||||
|
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
|
||||||
|
cmp.config.compare.exact,
|
||||||
|
cmp.config.compare.score,
|
||||||
|
cmp.config.compare.recently_used,
|
||||||
|
cmp.config.compare.locality,
|
||||||
|
cmp.config.compare.kind,
|
||||||
|
cmp.config.compare.sort_text,
|
||||||
|
cmp.config.compare.length,
|
||||||
|
cmp.config.compare.order,function(...) return require('cmp_buffer'):compare_locality(...) end,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
@ -73,6 +93,7 @@ cmp.setup({
|
|||||||
mode = 'symbol_text',
|
mode = 'symbol_text',
|
||||||
maxwidth = 50,
|
maxwidth = 50,
|
||||||
ellipsis_char = '…',
|
ellipsis_char = '…',
|
||||||
|
symbol_map = { Copilot = '🤖' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user