feat: add more zsh features (theme, keybinding)

This commit is contained in:
Yorick Barbanneau 2024-05-15 02:09:26 +02:00
parent 5b19a98437
commit 4200b44e62

View file

@ -26,20 +26,61 @@ in
}; };
syntaxHighlighting = { syntaxHighlighting = {
enable = true; enable = true;
highlighters = [ "brackets" "main" ]; highlighters = [ "brackets" "main" "pattern" ];
styles = { styles = {
single-hyphen-option = "fg=blue"; builtin = "fg=#7cafc2,bold";
double-hyphen-option = "fg=blue"; single-hyphen-option = "fg=#86c1b9";
double-hyphen-option = "fg=#86c1b9";
back-quoted-argument-delimiter = "fg=ba8baf,bold";
single-quoted-argument = "fg=f7ca88";
function = "fg=blue"; function = "fg=blue";
reserved-word = "fg=magenta,bold"; reserved-word = "fg=#ba8baf,bold";
assign = "fg=red"; assign = "fg=#a1b56c";
bracket-level-1 = "fg=blue"; bracket-level-1 = "fg=7cafc2";
bracket-level-2 = "fg=magenta"; bracket-level-2 = "fg=ba8baf";
bracket-level-3 = "fg=green"; bracket-level-3 = "fg=#a1b56c";
bracket-error = "fg=red,bold"; bracket-error = "fg=#ab4642,bold";
cursor-matchingbracket = "fg=magenta,bold"; cursor-matchingbracket = "fg=ba8baf,bold";
redirection = "fg=#f7ca88,bold";
back-double-quoted-argument = "fg=#7cafc2";
dollar-double-quoted-argument = "fg=#86c1b9";
};
patterns = {
"\\|" = "fg=#f7ca88,bold";
" \\|\\| " = "fg=ba8baf,bold";
" \\&\\& " = "fg=ba8baf,bold";
"\\n" = "fg=#7cafc2";
}; };
}; };
initExtra = ''
# Ctrl + backspace: delete word
bindkey -v "^H" backward-kill-word
bindkey -v "^b" backward-word
bindkey -v "^e" forward-word
bindkey -v "^u" backward-kill-line
bindkey -v "^[^u" kill-line
bindkey -v "^w" backward-kill-word
bindkey -v "^[^w" kill-word
## Edit command line with nvim
autoload -z edit-command-line
zle -N edit-command-line
bindkey -a v edit-command-line
# change cursor like vim does
zle-keymap-select () {
if [[ ''$KEYMAP == vicmd ]]; then
# the command mode for vi
echo -ne "\e[2 q"
else
# the insert mode for vi
echo -ne "\e[5 q"
fi
}
precmd_functions+=(zle-keymap-select)
zle -N zle-keymap-select
'';
completionInit = '' completionInit = ''
autoload -Uz compinit autoload -Uz compinit
for dump in ''${ZDOTDIR}/.zcompdump(N.mh+24); do for dump in ''${ZDOTDIR}/.zcompdump(N.mh+24); do
@ -77,6 +118,8 @@ in
}]; }];
localVariables = { localVariables = {
BASE16_THEME = "$HOME/.config/zsh/plugins/base16"; BASE16_THEME = "$HOME/.config/zsh/plugins/base16";
# Make ESC key more reactive to go to normal mode
KEYTIMEOUT = 1;
}; };
}; };
}; };