1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

vim,neovim: set EDITOR to full binary path when defaultEditor is used

Prior to this change the `EDITOR` variable was set only to the name of the
program that should be looked up in `PATH` to use as the editor, but this will
only work for user-level stuff, for stuff like `sudo -e` it won't work as the
`PATH` will not contain the location of such programs. This makes it so that
when the `defaultEditor` variable is set to `true` then `EDITOR` will point to
the full binary location of the `vim` and `nvim` packages accordingly.

This is similar to how we set `defaultEditor` in the Emacs module.

This change is also made for `vim`.
This commit is contained in:
Julio César 2024-03-03 14:06:58 -06:00
parent d579633ff9
commit 6346c61b0c
No known key found for this signature in database
GPG key ID: 847411A045D48405
2 changed files with 8 additions and 2 deletions

View file

@ -390,7 +390,10 @@ in {
home.packages = [ cfg.finalPackage ];
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
home.sessionVariables = mkIf cfg.defaultEditor {
EDITOR = getBin
(pkgs.writeShellScript "editor" "exec ${getBin cfg.package}/bin/nvim");
};
xdg.configFile =
let hasLuaConfig = hasAttr "lua" config.programs.neovim.generatedConfigs;

View file

@ -174,7 +174,10 @@ in {
home.packages = [ cfg.package ];
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "vim"; };
home.sessionVariables = mkIf cfg.defaultEditor {
EDITOR = getBin
(pkgs.writeShellScript "editor" "exec ${getBin cfg.package}/bin/vim");
};
programs.vim = {
package = vim;