2024-04-26 02:08:23 +03:00
|
|
|
{ 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}"))
|
|
|
|
# Plugins
|
|
|
|
(map (v: v.genConfig) (filter (v: !v.isDependency) (attrValues config.plugin)))
|
|
|
|
# Cmd
|
|
|
|
(lib.optional (config.vim.cmd != "") (call "vim.cmd" config.vim.cmd))
|
2024-04-26 10:35:27 +03:00
|
|
|
# Keymaps
|
|
|
|
(lib.flip map config.vim.keymap.set ({ mode, lhs, rhs, ... } @ vars:
|
|
|
|
call "vim.keymap.set" [ mode lhs rhs (removeAttrs vars [ "mode" "lhs" "rhs" ]) ]
|
|
|
|
))
|
2024-04-26 02:08:23 +03:00
|
|
|
]));
|
|
|
|
|
|
|
|
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; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|