From dd99675ee81fef051809bc87d67eb07f5ba022e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Thu, 29 Dec 2022 22:36:05 +0100 Subject: [PATCH] vim,neovim: add `defaultEditor` (#3496) Also rename `vim_configurable` to `vim-full` per https://github.com/NixOS/nixpkgs/pull/204438 --- modules/programs/neovim.nix | 11 +++++++++++ modules/programs/vim.nix | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) 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;