neovim: copilot in cmp

This commit is contained in:
2026-02-13 16:57:11 +01:00
parent 4637065e94
commit a39f1f7967
2 changed files with 55 additions and 31 deletions

View File

@@ -14,28 +14,40 @@ neovim.override {
configure = {
vimAlias = true;
viAlias = true;
customRC = ''
source ${./shared.vim}
source ${./init.vim}
let g:snippet_directory = '${vimPlugins.friendly-snippets}'
luafile ${./init.lua}
''
+ lib.optionalString (stylixColors != null) (
with stylixColors.withHashtag;
''
luafile ${writeText "colors.lua" ''
require('base16-colorscheme').setup({
base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}',
base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}',
base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}',
base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}'
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}'
luafile ${./init.lua}
''
)
+ lib.optionalString (colorscheme != null) ''
colorscheme ${colorscheme}
'';
+ lib.optionalString (stylixColors != null) (
with stylixColors.withHashtag;
''
luafile ${writeText "colors.lua" ''
require('base16-colorscheme').setup({
base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}',
base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}',
base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}',
base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}'
})
''}
''
)
+ lib.optionalString (colorscheme != null) ''
colorscheme ${colorscheme}
'';
packages.nvim = with vimPlugins; {
start = [
base16-nvim
@@ -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

View File

@@ -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 },
}),
})
@@ -92,8 +101,8 @@ local language_servers = {
pyright = {}, -- pyright
-- tsserver = {}, -- typescript-language-server
cssls = {},
elmls = {}, -- elm-language-server
gopls = {}, -- gopls
elmls = {}, -- elm-language-server
gopls = {}, -- gopls
denols = {}, -- deno built in
bashls = {}, -- bash-language-server
lua_ls = {
@@ -112,9 +121,9 @@ local language_servers = {
},
},
},
hls = {}, -- haskell-language-server
html = {}, -- vscode-langservers-extracted
jsonls = {}, -- vscode-langservers-extracted
hls = {}, -- haskell-language-server
html = {}, -- vscode-langservers-extracted
jsonls = {}, -- vscode-langservers-extracted
lemminx = {}, -- lemminx (for xml)
nil_ls = {
["nil"] = {
@@ -122,10 +131,10 @@ local language_servers = {
command = { "nixfmt" },
},
},
}, -- github:oxalica/nil
}, -- github:oxalica/nil
dhall_lsp_server = {}, -- dhall-lsp-server
-- rnix = {}, -- rnix-lsp
jqls = {}, -- jq-lsp
jqls = {}, -- jq-lsp
rust_analyzer = { ["rust-analyzer"] = {} },
-- eslint = {},
-- volar? vls?