neovim-flake/flake/modules/home-manager.nix

92 lines
2.3 KiB
Nix
Raw Permalink Normal View History

# Home Manager module
packages: lib: {
2023-03-31 17:17:06 +02:00
config,
pkgs,
2023-03-31 17:17:06 +02:00
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf;
neovimConfigured = neovimConfiguration {
inherit pkgs;
modules = [cfg.settings];
};
2023-03-31 17:17:06 +02:00
in {
imports = [
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
];
meta.maintainers = with maintainers; [NotAShelf];
options.programs.nvf = {
enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
enableManpages = mkOption {
type = bool;
default = false;
description = "Whether to enable manpages for nvf.";
};
defaultEditor = mkOption {
type = bool;
default = false;
description = ''
Whether to set `nvf` as the default editor.
This will set the `EDITOR` environment variable as `nvim`
if set to true.
'';
};
finalPackage = mkOption {
type = anything;
visible = false;
readOnly = true;
description = ''
The built nvf package, wrapped with the user's configuration.
'';
};
2023-03-31 17:17:06 +02:00
settings = mkOption {
type = attrsOf anythingConcatLists;
2023-03-31 17:17:06 +02:00
default = {};
description = "Attribute set of nvf preferences.";
2023-03-31 17:17:06 +02:00
example = literalExpression ''
{
vim.viAlias = false;
vim.vimAlias = true;
vim.lsp = {
enable = true;
formatOnSave = true;
lightbulb.enable = true;
lspsaga.enable = false;
trouble.enable = true;
lspSignature.enable = true;
rust.enable = false;
nix = true;
};
}
'';
};
2023-03-31 17:17:06 +02:00
};
config = mkIf cfg.enable {
programs.nvf.finalPackage = neovimConfigured.neovim;
home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
packages =
[cfg.finalPackage]
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
};
_file = ./home-manager.nix;
2023-03-31 17:05:28 +02:00
}