mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
3bc1bc4012
Add $HOME to pin .zsh_plugin path, prevents antidote from creating empty .zsh_plugins.txt in pwd while new zsh process starting.
53 lines
1.5 KiB
Nix
53 lines
1.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.programs.zsh.antidote;
|
|
|
|
relToDotDir = file:
|
|
(optionalString (config.programs.zsh.dotDir != null)
|
|
(config.programs.zsh.dotDir + "/")) + file;
|
|
|
|
zPluginStr = with lib;
|
|
(pluginNames:
|
|
optionalString (pluginNames != [ ]) "${concatStrings (map (name: ''
|
|
${name}
|
|
'') pluginNames)}");
|
|
in {
|
|
meta.maintainers = [ maintainers.hitsmaxft ];
|
|
|
|
options.programs.zsh.antidote = {
|
|
enable = mkEnableOption "antidote - a zsh plugin manager";
|
|
|
|
plugins = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "zsh-users/zsh-autosuggestions" ];
|
|
description = "List of antidote plugins.";
|
|
};
|
|
|
|
useFriendlyNames = mkEnableOption "friendly names";
|
|
|
|
package = mkPackageOption pkgs "antidote" { };
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ cfg.package ];
|
|
|
|
home.file."${relToDotDir ".zsh_plugins.txt"}".text = zPluginStr cfg.plugins;
|
|
|
|
### move zsh_plugins.txt
|
|
programs.zsh.initExtraBeforeCompInit = ''
|
|
## home-manager/antidote begin :
|
|
source ${cfg.package}/share/antidote/antidote.zsh
|
|
${optionalString cfg.useFriendlyNames
|
|
"zstyle ':antidote:bundle' use-friendly-names 'yes'"}
|
|
bundlefile=$HOME/${relToDotDir ".zsh_plugins.txt"}
|
|
zstyle ':antidote:bundle' file $bundlefile
|
|
staticfile=$HOME/${relToDotDir ".zsh_plugins.zsh"}
|
|
zstyle ':antidote:static' file $staticfile
|
|
antidote load $bundlefile $staticfile
|
|
## home-manager/antidote end
|
|
'';
|
|
};
|
|
}
|