2023-03-31 16:42:05 +02:00
|
|
|
# Home Manager module
|
2023-04-01 14:19:46 +02:00
|
|
|
packages: inputs: {
|
2023-03-31 17:17:06 +02:00
|
|
|
config,
|
2024-04-07 16:16:08 +02:00
|
|
|
pkgs,
|
2023-03-31 17:17:06 +02:00
|
|
|
lib ? pkgs.lib,
|
|
|
|
...
|
2024-04-07 16:16:08 +02:00
|
|
|
}: let
|
|
|
|
inherit (lib) maintainers;
|
2024-05-04 12:27:50 +02:00
|
|
|
inherit (lib.modules) mkIf mkAliasOptionModule;
|
2024-04-20 23:10:00 +02:00
|
|
|
inherit (lib.lists) optional;
|
2024-04-07 16:16:08 +02:00
|
|
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
2024-04-20 18:00:58 +02:00
|
|
|
inherit (lib.types) attrsOf anything bool;
|
2024-04-07 16:16:08 +02:00
|
|
|
|
2024-05-04 12:27:50 +02:00
|
|
|
cfg = config.programs.nvf;
|
2023-07-11 23:15:23 +02:00
|
|
|
inherit (import ../../configuration.nix inputs) neovimConfiguration;
|
2024-04-07 16:16:08 +02:00
|
|
|
|
2024-04-14 16:13:57 +02:00
|
|
|
neovimConfigured = neovimConfiguration {
|
2023-04-01 14:19:46 +02:00
|
|
|
inherit pkgs;
|
|
|
|
modules = [cfg.settings];
|
|
|
|
};
|
2023-03-31 17:17:06 +02:00
|
|
|
in {
|
2024-05-04 12:27:50 +02:00
|
|
|
imports = [
|
|
|
|
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
|
|
|
|
];
|
|
|
|
|
2023-07-11 23:15:23 +02:00
|
|
|
meta.maintainers = with maintainers; [NotAShelf];
|
2023-03-31 16:42:05 +02:00
|
|
|
|
2024-05-04 12:27:50 +02:00
|
|
|
options.programs.nvf = {
|
|
|
|
enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
|
2024-04-20 18:00:58 +02:00
|
|
|
|
|
|
|
enableManpages = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
2024-05-04 12:27:50 +02:00
|
|
|
description = "Whether to enable manpages for nvf.";
|
2024-04-20 18:00:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2024-05-04 12:27:50 +02:00
|
|
|
Whether to set `nvf` as the default editor.
|
2024-04-20 18:00:58 +02:00
|
|
|
|
|
|
|
This will set the `EDITOR` environment variable as `nvim`
|
|
|
|
if set to true.
|
|
|
|
'';
|
|
|
|
};
|
2024-04-14 16:02:39 +02:00
|
|
|
|
2024-04-14 16:13:57 +02:00
|
|
|
finalPackage = mkOption {
|
2024-04-14 16:02:39 +02:00
|
|
|
type = anything;
|
2024-04-14 16:13:57 +02:00
|
|
|
visible = false;
|
|
|
|
readOnly = true;
|
2024-04-14 16:02:39 +02:00
|
|
|
description = ''
|
2024-05-04 12:27:50 +02:00
|
|
|
The built nvf package, wrapped with the user's configuration.
|
2024-04-14 16:02:39 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-03-31 17:17:06 +02:00
|
|
|
settings = mkOption {
|
2024-04-07 16:16:08 +02:00
|
|
|
type = attrsOf anything;
|
2023-03-31 17:17:06 +02:00
|
|
|
default = {};
|
2024-05-04 12:27:50 +02:00
|
|
|
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;
|
|
|
|
nvimCodeActionMenu.enable = true;
|
|
|
|
trouble.enable = true;
|
|
|
|
lspSignature.enable = true;
|
|
|
|
rust.enable = false;
|
|
|
|
nix = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2023-03-31 16:42:05 +02:00
|
|
|
};
|
2023-03-31 17:17:06 +02:00
|
|
|
};
|
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-04 12:27:50 +02:00
|
|
|
programs.nvf.finalPackage = neovimConfigured.neovim;
|
2024-04-14 16:13:57 +02:00
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
home = {
|
2024-04-20 22:48:15 +02:00
|
|
|
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
2024-04-20 22:42:48 +02:00
|
|
|
packages =
|
|
|
|
[cfg.finalPackage]
|
2024-04-20 23:10:00 +02:00
|
|
|
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
2024-04-20 22:42:48 +02:00
|
|
|
};
|
|
|
|
};
|
2023-03-31 17:05:28 +02:00
|
|
|
}
|