neovim: copilot in cmp
This commit is contained in:
@@ -14,7 +14,19 @@ neovim.override {
|
||||
configure = {
|
||||
vimAlias = true;
|
||||
viAlias = true;
|
||||
customRC = ''
|
||||
customRC =
|
||||
|
||||
lib.optionalString withCopilot (''
|
||||
luafile ${writeText "copilot.lua" ''
|
||||
require("copilot").setup({
|
||||
suggestion = { enabled = false },
|
||||
panel = { enabled = false }
|
||||
})
|
||||
|
||||
require("copilot_cmp").setup()
|
||||
''}
|
||||
'')
|
||||
+ ''
|
||||
source ${./shared.vim}
|
||||
source ${./init.vim}
|
||||
let g:snippet_directory = '${vimPlugins.friendly-snippets}'
|
||||
@@ -81,7 +93,10 @@ neovim.override {
|
||||
}
|
||||
)
|
||||
]
|
||||
++ lib.optional withCopilot vimPlugins.copilot-vim;
|
||||
++ lib.optionals withCopilot [
|
||||
vimPlugins.copilot-lua
|
||||
vimPlugins.copilot-cmp
|
||||
];
|
||||
opt = [
|
||||
csv
|
||||
dhall-vim
|
||||
|
||||
@@ -19,17 +19,23 @@ cmp.setup({
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
completion = {
|
||||
autocomplete = { require("cmp.types").cmp.TriggerEvent.TextChanged },
|
||||
},
|
||||
mapping = {
|
||||
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#super-tab-like-mapping
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
cmp.complete()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
@@ -41,8 +47,11 @@ cmp.setup({
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "copilot", priority = 1000 },
|
||||
{ name = "nvim_lsp", priority = 800 },
|
||||
{ name = "luasnip", priority = 700 },
|
||||
{ name = "path", priority = 500 },
|
||||
{ name = "buffer", priority = 300 },
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user