diff options
Diffstat (limited to 'nixos/modules/programs/vim.nix')
-rw-r--r-- | nixos/modules/programs/vim.nix | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/nixos/modules/programs/vim.nix b/nixos/modules/programs/vim.nix index 8232340ddebbf..c84f966eb3a7e 100644 --- a/nixos/modules/programs/vim.nix +++ b/nixos/modules/programs/vim.nix @@ -1,25 +1,31 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.programs.vim; -in { +in +{ options.programs.vim = { - defaultEditor = lib.mkOption { - type = lib.types.bool; - default = false; - description = '' - When enabled, installs vim and configures vim to be the default editor - using the EDITOR environment variable. - ''; - }; + enable = lib.mkEnableOption "Vi IMproved, an advanced text"; - package = lib.mkPackageOption pkgs "vim" { - example = "vim-full"; - }; + defaultEditor = lib.mkEnableOption "vim as the default editor"; + + package = lib.mkPackageOption pkgs "vim" { example = "vim-full"; }; }; - config = lib.mkIf cfg.defaultEditor { - environment.systemPackages = [ cfg.package ]; - environment.variables = { EDITOR = lib.mkOverride 900 "vim"; }; + # TODO: convert it into assert after 24.11 release + config = lib.mkIf (cfg.enable || cfg.defaultEditor) { + warnings = lib.mkIf (cfg.defaultEditor && !cfg.enable) [ + "programs.vim.defaultEditor will only work if programs.vim.enable is enabled, which will be enforced after the 24.11 release" + ]; + environment = { + systemPackages = [ cfg.package ]; + variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "vim"); + pathsToLink = [ "/share/vim-plugins" ]; + }; }; } |