This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
neovim/modules/nvim-cmp.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;
})
)
];
}