Add copilot plugins
Finally accepting our new robot overlords.
This commit is contained in:
parent
8ab75d7465
commit
2aceafcd67
@ -325,6 +325,20 @@ return require('packer').startup(function(use)
|
||||
require('plugins.typescript-nvim')
|
||||
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 {
|
||||
'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 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({
|
||||
experimental = { ghost_text = true },
|
||||
snippet = {
|
||||
@ -23,8 +29,8 @@ cmp.setup({
|
||||
['<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.
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
if cmp.visible() and has_words_before() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
@ -48,6 +54,7 @@ cmp.setup({
|
||||
priority = 100,
|
||||
group_index = 1,
|
||||
},
|
||||
{ name = "copilot", group_index = 2 },
|
||||
{
|
||||
name = 'buffer',
|
||||
priority = 80,
|
||||
@ -64,8 +71,21 @@ cmp.setup({
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}),
|
||||
sorting = {
|
||||
priority_weight = 2,
|
||||
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 = {
|
||||
@ -73,6 +93,7 @@ cmp.setup({
|
||||
mode = 'symbol_text',
|
||||
maxwidth = 50,
|
||||
ellipsis_char = '…',
|
||||
symbol_map = { Copilot = '🤖' },
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user