neovim: copilot in cmp
This commit is contained in:
@@ -14,7 +14,19 @@ neovim.override {
|
|||||||
configure = {
|
configure = {
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
viAlias = 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 ${./shared.vim}
|
||||||
source ${./init.vim}
|
source ${./init.vim}
|
||||||
let g:snippet_directory = '${vimPlugins.friendly-snippets}'
|
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 = [
|
opt = [
|
||||||
csv
|
csv
|
||||||
dhall-vim
|
dhall-vim
|
||||||
|
|||||||
@@ -19,17 +19,23 @@ cmp.setup({
|
|||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
completion = {
|
||||||
|
autocomplete = { require("cmp.types").cmp.TriggerEvent.TextChanged },
|
||||||
|
},
|
||||||
mapping = {
|
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)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
fallback()
|
cmp.complete()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
@@ -41,8 +47,11 @@ cmp.setup({
|
|||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "nvim_lsp" },
|
{ name = "copilot", priority = 1000 },
|
||||||
{ name = "luasnip" },
|
{ name = "nvim_lsp", priority = 800 },
|
||||||
|
{ name = "luasnip", priority = 700 },
|
||||||
|
{ name = "path", priority = 500 },
|
||||||
|
{ name = "buffer", priority = 300 },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user