From 9a473b693ac6dd3249d2ff0d130c7decfca8ed96 Mon Sep 17 00:00:00 2001
From: James Ottaway <jamesottaway@users.noreply.github.com>
Date: Sat, 15 Aug 2020 06:36:23 +1000
Subject: [PATCH] zsh: add `cdpath` option (#1418)

---
 modules/programs/zsh.nix | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix
index 5199e51e9..ed65d5fe4 100644
--- a/modules/programs/zsh.nix
+++ b/modules/programs/zsh.nix
@@ -185,6 +185,14 @@ in
         type = types.nullOr types.bool;
       };
 
+      cdpath = mkOption {
+        default = [];
+        description = ''
+          List of paths to autocomplete calls to `cd`.
+        '';
+        type = types.listOf types.str;
+      };
+
       dotDir = mkOption {
         default = null;
         example = ".config/zsh";
@@ -392,6 +400,10 @@ in
       home.file."${relToDotDir ".zshrc"}".text = ''
         typeset -U path cdpath fpath manpath
 
+        ${optionalString (cfg.cdpath != []) ''
+          cdpath+=(${concatStringsSep " " cfg.cdpath})
+        ''}
+
         for profile in ''${(z)NIX_PROFILES}; do
           fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
         done