41 lines
898 B
Nix
41 lines
898 B
Nix
{ nix2lua, vim, ... }:
|
|
|
|
with nix2lua.lib;
|
|
|
|
let
|
|
defaultCmpKeymaps = {
|
|
"<C-b>" = call "cmp.mapping.scroll_docs" (- 4);
|
|
"<C-d>" = call "cmp.mapping.scroll_docs" 4;
|
|
"<C-Space>" = call0 "cmp.mapping.complete";
|
|
"<C-e>" = call0 "cmp.mapping.abort";
|
|
"<CR>" = call "cmp.mapping.confirm" { select = true; };
|
|
};
|
|
in
|
|
|
|
{ cmpKeymaps ? defaultCmpKeymaps
|
|
, extraCmpKeymaps ? { }
|
|
, cmpSources ? { }
|
|
}:
|
|
|
|
{
|
|
luasnip = true;
|
|
cmp-luasnip = true;
|
|
|
|
nvim-cmp = [
|
|
(vim.opt "completeopt" [ "menu" "menuone" "noselect" ])
|
|
|
|
(local (set "cmp" (require "cmp")))
|
|
|
|
(pipe1
|
|
(var "cmp")
|
|
(call "setup" {
|
|
snippet.exand = lambda [ "args" ]
|
|
(pipe1 (require "luasnip") (call "lsp_expand" (var "args")));
|
|
|
|
mapping = call "cmp.mapping.preset.insert" (cmpKeymaps // extraCmpKeymaps);
|
|
|
|
sources = call "cmp.config.sources" cmpSources;
|
|
})
|
|
)
|
|
];
|
|
}
|