70 lines
1.7 KiB
Nix
70 lines
1.7 KiB
Nix
{ config, lib, pkgs, nix2lua, ... }:
|
|
|
|
let
|
|
inherit (builtins) filter attrValues;
|
|
|
|
cfg = config.build.neovim;
|
|
in
|
|
{
|
|
options.build.neovim = with lib; with types; {
|
|
luaConfig = mkOption {
|
|
type = lines;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = ''
|
|
Neovim editor lua configuration.
|
|
'';
|
|
};
|
|
plugins = mkOption {
|
|
type = listOf package;
|
|
readOnly = true;
|
|
internal = true;
|
|
};
|
|
package = mkOption {
|
|
type = types.package;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = ''
|
|
Neovim editor derivation with plugins and configurations.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config.build.neovim = {
|
|
luaConfig = with nix2lua; toLua (spaceBetween (lib.flatten [
|
|
# Global Opts
|
|
(lib.flip lib.mapAttrsToList config.vim.g (k: set "vim.g.${k}"))
|
|
# Opts
|
|
(lib.flip lib.mapAttrsToList config.vim.opt (k: set "vim.opt.${k}"))
|
|
# Keymaps
|
|
(lib.flip map config.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
|
call "vim.keymap.set" [ mode lhs rhs (removeAttrs vars [ "mode" "lhs" "rhs" ]) ]
|
|
))
|
|
# Plugins
|
|
(map (v: v.genConfig) (filter (v: !v.isDependency) (attrValues config.plugin)))
|
|
# Cmd
|
|
(lib.optional (config.vim.cmd != "") (call "vim.cmd" config.vim.cmd))
|
|
]));
|
|
|
|
plugins = lib.mapAttrsToList (k: v: v.package) config.plugin;
|
|
|
|
package = pkgs.wrapNeovim pkgs.neovim-unwrapped {
|
|
viAlias = false;
|
|
vimAlias = false;
|
|
|
|
withPython3 = false;
|
|
withNodeJs = false;
|
|
withRuby = false;
|
|
|
|
configure = {
|
|
customRC = ''
|
|
lua << EOF
|
|
${cfg.luaConfig}
|
|
EOF
|
|
'';
|
|
|
|
packages.myVimPackages = { start = cfg.plugins; };
|
|
};
|
|
};
|
|
};
|
|
}
|