nixos/pkgsets/nvim/cmp.nix

56 lines
1.4 KiB
Nix
Raw Normal View History

{
lib,
config,
...
}:
lib.mkIf (lib.elem "nvim::cmp" config.machine.pkgs) {
programs.nvim-lazy.lazyPlugins = [
# Autocompletion
{
dir = vPlug: vPlug.nvim-cmp;
event = [ "InsertEnter" ];
dependencies = (
vPlug: with vPlug; [
luasnip
]
);
config = # lua
''
function()
${
lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua
''
local lsp_zero = require('lsp-zero')
lsp_zero.extend_cmp()
''
}
local cmp = require('cmp')
local cmp_action = lsp_zero.cmp_action()
cmp.setup({
${
lib.optionalString (lib.elem "nvim::lsp" config.machine.pkgs) # lua
''formatting = lsp_zero.cmp_format(),''
}
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
})
})
end
'';
}
{
dir = vPlug: vPlug.luasnip;
lazy = true;
}
];
}