Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim,neovim: add defaultEditor #3496

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/programs/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ in {
description = "Resulting customized neovim package.";
};

defaultEditor = mkOption {
type = types.bool;
default = false;
description = ''
Whether to configure <command>nvim</command> as the default
editor using the <envar>EDITOR</envar> environment variable.
'';
};

extraConfig = mkOption {
type = types.lines;
default = "";
Expand Down Expand Up @@ -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 (
Expand Down
18 changes: 15 additions & 3 deletions modules/programs/vim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 <command>vim</command> as the default
editor using the <envar>EDITOR</envar> environment variable.
'';
};
};
};
Expand Down Expand Up @@ -170,6 +180,8 @@ in {

home.packages = [ cfg.package ];

home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "vim"; };

programs.vim = {
package = vim;
plugins = defaultPlugins;
Expand Down