Draft: modules #1

Draft
pleshevskiy wants to merge 15 commits from modules into main
3 changed files with 46 additions and 0 deletions
Showing only changes of commit d888dcb9ba - Show all commits

View file

@ -256,10 +256,12 @@
neoformat = { }; neoformat = { };
hop-nvim = { }; hop-nvim = { };
telescope-nvim = { }; telescope-nvim = { };
nvim-cmp = { };
}; };
plugins = with prev.nix2lua.lib; { plugins = with prev.nix2lua.lib; {
editorconfig-nvim = true; editorconfig-nvim = true;
lualine-lsp-progress = true;
lualine-nvim = pipe1 lualine-nvim = pipe1
(require "lualine") (require "lualine")
(call "setup" { (call "setup" {

View file

@ -3,6 +3,9 @@
with nix2lua.lib; with nix2lua.lib;
{ {
g = varName: expr: set "vim.g.${varName}" expr; 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); fn.isdirectory = file: call1 "vim.fn.isdirectory" (var file);
cmd' = expr: call1 "vim.cmd" expr; cmd' = expr: call1 "vim.cmd" expr;

41
modules/nvim-cmp.nix Normal file
View 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;
})
)
];
}