diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 41b81c633..c8edd2257 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -241,6 +241,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 = ""; @@ -372,6 +381,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 46e5f95db..e4d993a61 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;