diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix
index 4560c930d511..58e54b2725a7 100644
--- a/modules/programs/neovim.nix
+++ b/modules/programs/neovim.nix
@@ -229,6 +229,15 @@ in {
description = "Resulting customized neovim package.";
};
+ defaultEditor = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to configure nvim as the default
+ editor using the EDITOR environment variable.
+ '';
+ };
+
extraConfig = mkOption {
type = types.lines;
default = "";
@@ -360,6 +369,8 @@ in {
home.packages = [ cfg.finalPackage ];
+ home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
+
xdg.configFile =
let hasLuaConfig = hasAttr "lua" config.programs.neovim.generatedConfigs;
in mkMerge (
diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix
index 46e5f95db103..e4d993a61912 100644
--- a/modules/programs/vim.nix
+++ b/modules/programs/vim.nix
@@ -127,9 +127,19 @@ in {
packageConfigurable = mkOption {
type = types.package;
- description = "Configurable vim package";
- default = pkgs.vim_configurable;
- defaultText = "pkgs.vim_configurable";
+ description = "Vim package to customize";
+ default = pkgs.vim-full or pkgs.vim_configurable;
+ defaultText = literalExpression "pkgs.vim-full";
+ example = literalExpression "pkgs.vim";
+ };
+
+ defaultEditor = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to configure vim as the default
+ editor using the EDITOR environment variable.
+ '';
};
};
};
@@ -170,6 +180,8 @@ in {
home.packages = [ cfg.package ];
+ home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "vim"; };
+
programs.vim = {
package = vim;
plugins = defaultPlugins;