reprogram zsh configs
This commit is contained in:
parent
2aff37c689
commit
0068a4aee6
2 changed files with 18 additions and 30 deletions
|
|
@ -15,36 +15,6 @@
|
||||||
enableVimMode = true;
|
enableVimMode = true;
|
||||||
powerlevel10kConfigFile = ./shell/p10k.zsh;
|
powerlevel10kConfigFile = ./shell/p10k.zsh;
|
||||||
aliases = { ll = "ls -alF"; };
|
aliases = { ll = "ls -alF"; };
|
||||||
extraAfter = ''
|
|
||||||
function rsydn-accept-autosuggest-or-complete() {
|
|
||||||
local original_buffer=$BUFFER
|
|
||||||
local original_cursor=$CURSOR
|
|
||||||
zle autosuggest-accept 2>/dev/null
|
|
||||||
if [[ $BUFFER == "$original_buffer" && $CURSOR -eq $original_cursor ]]; then
|
|
||||||
zle expand-or-complete
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
zle -N rsydn-accept-autosuggest-or-complete
|
|
||||||
function rsydn-bind-tab-autosuggest() {
|
|
||||||
bindkey '^I' rsydn-accept-autosuggest-or-complete 2>/dev/null || true
|
|
||||||
bindkey -M viins '^I' rsydn-accept-autosuggest-or-complete 2>/dev/null || true
|
|
||||||
}
|
|
||||||
function rsydn-ensure-tab-autosuggest() {
|
|
||||||
local default_binding
|
|
||||||
default_binding=$(bindkey '^I' 2>/dev/null || true)
|
|
||||||
if [[ $default_binding != *rsydn-accept-autosuggest-or-complete* ]]; then
|
|
||||||
rsydn-bind-tab-autosuggest
|
|
||||||
fi
|
|
||||||
local viins_binding
|
|
||||||
viins_binding=$(bindkey -M viins '^I' 2>/dev/null || true)
|
|
||||||
if [[ $viins_binding != *rsydn-accept-autosuggest-or-complete* ]]; then
|
|
||||||
bindkey -M viins '^I' rsydn-accept-autosuggest-or-complete 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
add-zsh-hook precmd rsydn-ensure-tab-autosuggest
|
|
||||||
rsydn-ensure-tab-autosuggest
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.git.enable = true;
|
programs.git.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,21 @@ in {
|
||||||
description = "Enable zsh-autosuggestions.";
|
description = "Enable zsh-autosuggestions.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
autosuggestAcceptWidgets = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [
|
||||||
|
"forward-char"
|
||||||
|
"end-of-line"
|
||||||
|
"vi-forward-char"
|
||||||
|
"vi-end-of-line"
|
||||||
|
"vi-add-eol"
|
||||||
|
"expand-or-complete"
|
||||||
|
"complete-word"
|
||||||
|
"fzf-completion"
|
||||||
|
];
|
||||||
|
description = "Widgets that should accept autosuggestions before running (ZSH_AUTOSUGGEST_ACCEPT_WIDGETS).";
|
||||||
|
};
|
||||||
|
|
||||||
enableSyntaxHighlighting = mkOption {
|
enableSyntaxHighlighting = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
@ -79,6 +94,9 @@ in {
|
||||||
syntaxHighlighting.enable = cfg.enableSyntaxHighlighting;
|
syntaxHighlighting.enable = cfg.enableSyntaxHighlighting;
|
||||||
shellAliases = cfg.aliases;
|
shellAliases = cfg.aliases;
|
||||||
initContent = lib.mkAfter cfg.extraAfter;
|
initContent = lib.mkAfter cfg.extraAfter;
|
||||||
|
localVariables = lib.mkIf cfg.enableAutoSuggestion {
|
||||||
|
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS = cfg.autosuggestAcceptWidgets;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{ programs.zsh.initContent = lib.mkOrder 550 cfg.extraBeforeCompInit; }
|
{ programs.zsh.initContent = lib.mkOrder 550 cfg.extraBeforeCompInit; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue