Draft: modules #1
3 changed files with 46 additions and 0 deletions
|
@ -256,10 +256,12 @@
|
|||
neoformat = { };
|
||||
hop-nvim = { };
|
||||
telescope-nvim = { };
|
||||
nvim-cmp = { };
|
||||
};
|
||||
|
||||
plugins = with prev.nix2lua.lib; {
|
||||
editorconfig-nvim = true;
|
||||
lualine-lsp-progress = true;
|
||||
lualine-nvim = pipe1
|
||||
(require "lualine")
|
||||
(call "setup" {
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
with nix2lua.lib;
|
||||
{
|
||||
g = varName: expr: set "vim.g.${varName}" expr;
|
||||
opt = varName: expr: set "vim.opt.${varName}" expr;
|
||||
|
||||
fn' = fnName: args: call "vim.fn[\"${fnName}\"]" args;
|
||||
fn.isdirectory = file: call1 "vim.fn.isdirectory" (var file);
|
||||
|
||||
cmd' = expr: call1 "vim.cmd" expr;
|
||||
|
|
41
modules/nvim-cmp.nix
Normal file
41
modules/nvim-cmp.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{ 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;
|
||||
})
|
||||
)
|
||||
];
|
||||
}
|
Reference in a new issue