zsh fix tab completion

This commit is contained in:
Rasyidan Akbar F. 2025-09-27 21:15:28 +07:00
commit 51f26be68b
2 changed files with 8 additions and 5 deletions

View file

@ -17,14 +17,17 @@
aliases = { ll = "ls -alF"; }; aliases = { ll = "ls -alF"; };
extraAfter = '' extraAfter = ''
function rsydn-accept-autosuggest-or-complete() { function rsydn-accept-autosuggest-or-complete() {
if [[ -n "''${POSTDISPLAY:-}" ]]; then local original_buffer=$BUFFER
zle autosuggest-accept local original_cursor=$CURSOR
else zle autosuggest-accept 2>/dev/null
if [[ $BUFFER == "$original_buffer" && $CURSOR -eq $original_cursor ]]; then
zle expand-or-complete zle expand-or-complete
fi fi
} }
zle -N rsydn-accept-autosuggest-or-complete zle -N rsydn-accept-autosuggest-or-complete
bindkey '^I' rsydn-accept-autosuggest-or-complete for keymap in main viins; do
bindkey -M "$keymap" '^I' rsydn-accept-autosuggest-or-complete || true
done
''; '';
}; };

View file

@ -78,7 +78,7 @@ in {
autosuggestion.enable = cfg.enableAutoSuggestion; autosuggestion.enable = cfg.enableAutoSuggestion;
syntaxHighlighting.enable = cfg.enableSyntaxHighlighting; syntaxHighlighting.enable = cfg.enableSyntaxHighlighting;
shellAliases = cfg.aliases; shellAliases = cfg.aliases;
initExtra = cfg.extraAfter; initContent = lib.mkAfter cfg.extraAfter;
}; };
} }
{ programs.zsh.initContent = lib.mkOrder 550 cfg.extraBeforeCompInit; } { programs.zsh.initContent = lib.mkOrder 550 cfg.extraBeforeCompInit; }