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 = { configure = {
vimAlias = true; vimAlias = true;
viAlias = true; viAlias = true;
customRC = '' customRC =
source ${./shared.vim}
source ${./init.vim} lib.optionalString withCopilot (''
let g:snippet_directory = '${vimPlugins.friendly-snippets}' luafile ${writeText "copilot.lua" ''
luafile ${./init.lua} require("copilot").setup({
'' suggestion = { enabled = false },
+ lib.optionalString (stylixColors != null) ( panel = { enabled = false }
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}'
}) })
require("copilot_cmp").setup()
''} ''}
'')
+ ''
source ${./shared.vim}
source ${./init.vim}
let g:snippet_directory = '${vimPlugins.friendly-snippets}'
luafile ${./init.lua}
'' ''
) + lib.optionalString (stylixColors != null) (
+ lib.optionalString (colorscheme != null) '' with stylixColors.withHashtag;
colorscheme ${colorscheme} ''
''; 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; { packages.nvim = with vimPlugins; {
start = [ start = [
base16-nvim base16-nvim
@@ -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

View File

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