zsh: update zsh plugins

This commit is contained in:
Tigor Hutasuhut 2024-07-07 17:24:15 +07:00
parent fcf0bc8f4a
commit 95915cb1cf
2 changed files with 40 additions and 27 deletions

View file

@ -1,9 +1,10 @@
{ config, lib, unstable, ... }: { config, lib, unstable, pkgs, ... }:
let let
cfg = config.profile.go; cfg = config.profile.go;
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.zsh.initExtra = ''zsh-defer source<(cat ${pkgs.zsh-completions}/share/zsh/site-functions/_golang)'';
programs.go = { programs.go = {
enable = true; enable = true;
goPrivate = [ goPrivate = [

View file

@ -1,6 +1,6 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
let let
inherit (lib.lists) optional; inherit (lib.strings) optionalString concatStrings;
in in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
@ -47,6 +47,7 @@ in
syntaxHighlighting.enable = true; syntaxHighlighting.enable = true;
initExtraFirst = /*bash*/ '' initExtraFirst = /*bash*/ ''
export ZSH_CACHE_DIR=$HOME/.cache/zsh export ZSH_CACHE_DIR=$HOME/.cache/zsh
mkdir -p $ZSH_CACHE_DIR/completions
if [ -f $HOME/.config/zsh/.p10k.zsh ]; then if [ -f $HOME/.config/zsh/.p10k.zsh ]; then
source $HOME/.config/zsh/.p10k.zsh source $HOME/.config/zsh/.p10k.zsh
@ -57,33 +58,39 @@ in
(cat "$_ZSH_COLOR_SCHEME_FILE" &) (cat "$_ZSH_COLOR_SCHEME_FILE" &)
fi fi
''; '';
initExtra = /*bash*/ '' initExtra = concatStrings [
packfiles() { /*bash*/
find $(nix build "nixpkgs#$1" --no-link --print-out-paths) ''
} packfiles() {
find $(nix build "nixpkgs#$1" --no-link --print-out-paths)
}
# Completion settings # Completion settings
## Case insensitive completion ## Case insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
# FZF Tab configurations # FZF Tab configurations
# #
# disable sort when completing `git checkout` # disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support # set descriptions format to enable group support
# NOTE: don't use escape sequences here, fzf-tab will ignore them # NOTE: don't use escape sequences here, fzf-tab will ignore them
zstyle ':completion:*:descriptions' format '[%d]' zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing # set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS}
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix # force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
zstyle ':completion:*' menu no zstyle ':completion:*' menu no
# preview directory's content with eza when completing cd # preview directory's content with eza when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# switch group using `<` and `>` # switch group using `<` and `>`
zstyle ':fzf-tab:*' switch-group '<' '>' zstyle ':fzf-tab:*' switch-group '<' '>'
# Preview fzf # Preview fzf
zstyle ':fzf-tab:*' fzf-preview 'eza -1 --color=always $realpath' zstyle ':fzf-tab:*' fzf-preview 'eza -1 --color=always $realpath'
''; ''
(optionalString config.profile.podman.enable /*bash*/ ''
zsh-defer source <(podman completion zsh)
'')
];
plugins = [ plugins = [
{ {
@ -111,6 +118,11 @@ in
src = pkgs.zsh-history-substring-search; src = pkgs.zsh-history-substring-search;
file = "share/zsh-history-substring-search/zsh-history-substring-search.zsh"; file = "share/zsh-history-substring-search/zsh-history-substring-search.zsh";
} }
{
name = "zsh-defer";
src = pkgs.zsh-defer;
file = "share/zsh-defer/zsh-defer.plugin.zsh";
}
]; ];
}; };
} }