|
11 | 11 | # perSystem.cardano-parts.shell.<global|<id>>.defaultHooks |
12 | 12 | # perSystem.cardano-parts.shell.<global|<id>>.defaultLintPkg |
13 | 13 | # perSystem.cardano-parts.shell.<global|<id>>.defaultVars |
| 14 | +# perSystem.cardano-parts.shell.<global|<id>>.defaultZshCompFpathLoading |
14 | 15 | # perSystem.cardano-parts.shell.<global|<id>>.enableFormatter |
15 | 16 | # perSystem.cardano-parts.shell.<global|<id>>.enableHooks |
16 | 17 | # perSystem.cardano-parts.shell.<global|<id>>.enableLint |
17 | 18 | # perSystem.cardano-parts.shell.<global|<id>>.enableVars |
| 19 | +# perSystem.cardano-parts.shell.<global|<id>>.enableZshCompFpathLoading |
18 | 20 | # perSystem.cardano-parts.shell.<global|<id>>.extraPkgs |
19 | 21 | # perSystem.cardano-parts.shell.<global|<id>>.pkgs |
20 | 22 | # |
|
152 | 154 | }; |
153 | 155 | }; |
154 | 156 |
|
| 157 | + defaultZshCompFpathLoading = mkOption { |
| 158 | + description = mdDoc "The cardano-parts default zsh completion fpath loading hook."; |
| 159 | + default = globalDefault isGlobal (packages: '' |
| 160 | + export ZDOTDIR=$PWD/.direnv-zsh |
| 161 | + mkdir -p "$ZDOTDIR" |
| 162 | + rm -f "$ZDOTDIR/.zcompdump"* |
| 163 | +
|
| 164 | + cat > "$ZDOTDIR/completions.zsh" <<'EOF' |
| 165 | + for p in ${concatStringsSep " " (map (p: "${p}") packages)}; do |
| 166 | + if [ -d "$p/share/zsh/site-functions" ]; then |
| 167 | + fpath=("$p/share/zsh/site-functions" $fpath) |
| 168 | + fi |
| 169 | + done |
| 170 | + autoload -U compinit |
| 171 | + compinit |
| 172 | + EOF |
| 173 | +
|
| 174 | + cat > "$ZDOTDIR/.zshrc" <<'EOF' |
| 175 | + if [ -f "$HOME/.zshrc" ]; then |
| 176 | + source "$HOME/.zshrc" |
| 177 | + fi |
| 178 | +
|
| 179 | + source "$ZDOTDIR/completions.zsh" |
| 180 | + autoload -U compinit |
| 181 | + compinit -C |
| 182 | +
|
| 183 | + alias zsh-base='unset ZDOTDIR; exec zsh -l' |
| 184 | + echo |
| 185 | + echo "To return to your normal zsh without devShell fpath modifications, run \"zsh-base\" before leaving the repo directory," |
| 186 | + echo "otherwise, close and open a new zsh shell to avoid lingering devShell command completions." |
| 187 | + echo |
| 188 | + EOF |
| 189 | + ''); |
| 190 | + }; |
| 191 | + |
155 | 192 | enableFormatter = mkOption { |
156 | 193 | type = globalType isGlobal bool; |
157 | 194 | description = mdDoc "Enable default cardano-parts formatter in the devShells."; |
|
176 | 213 | default = globalDefault isGlobal true; |
177 | 214 | }; |
178 | 215 |
|
| 216 | + enableZshCompFpathLoading = mkOption { |
| 217 | + type = globalType isGlobal bool; |
| 218 | + description = mdDoc "Enable default cardano-parts zsh completion loading into fpath in zsh devShells."; |
| 219 | + default = globalDefault isGlobal true; |
| 220 | + }; |
| 221 | + |
179 | 222 | extraPkgs = mkOption { |
180 | 223 | type = listOf package; |
181 | 224 | description = mdDoc "Extra packages."; |
|
427 | 470 |
|
428 | 471 | devShells = let |
429 | 472 | mkShell = id: |
430 | | - pkgs.mkShell ({ |
| 473 | + pkgs.mkShell (rec { |
431 | 474 | packages = allPkgs id; |
432 | 475 | shellHook = |
433 | 476 | # Add optional git/shell and formatter hooks |
434 | 477 | selectScope id optionalString "enableHooks" "defaultHooks" |
435 | 478 | + selectScope id optionalAttrs "enableFormatter" "defaultFormatterHook" |
| 479 | + + (selectScope id (cond: as: |
| 480 | + if cond |
| 481 | + then as |
| 482 | + else _: "") "enableZshCompFpathLoading" "defaultZshCompFpathLoading") |
| 483 | + packages |
436 | 484 | + '' |
437 | 485 | [ -z "$NOMENU" ] && menu |
438 | 486 | ''; |
|
0 commit comments