Add zsh-autocomplete
This commit is contained in:
parent
d24816b15d
commit
6099745727
|
|
@ -9,6 +9,7 @@
|
|||
}:
|
||||
let
|
||||
shellCfg = config.modules.shell;
|
||||
zshCfg = config.modules.zsh;
|
||||
in
|
||||
{
|
||||
imports = [ inputs.home-manager.nixosModules.home-manager ];
|
||||
|
|
@ -52,5 +53,10 @@ in
|
|||
# Set /etc/shells so GDM will show our user when ZSH is selected
|
||||
environment.shells = [ pkgs.${shellCfg.defaultShell} ];
|
||||
|
||||
# Needed to get completion for system packages (e.g. systemd)
|
||||
environment.pathsToLink =
|
||||
[ ]
|
||||
++ (if zshCfg.enable then [ "/share/zsh" ] else [ ]);
|
||||
|
||||
nix.settings.allowed-users = [ "${username}" ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = osConfig.modules.zsh;
|
||||
xdgCfg = config.xdg;
|
||||
in
|
||||
{
|
||||
config = mkIf cfg.enable {
|
||||
home.file."${xdgCfg.configHome}/zsh/completion.zsh" = {
|
||||
source = ./completion.zsh;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Work with hidden files
|
||||
_comp_options+=(globdots)
|
||||
|
||||
# Autocomplete cache options
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache"
|
||||
|
||||
# Colors
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
# Menu options
|
||||
zstyle ':completion:*' menu select
|
||||
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
|
||||
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
|
||||
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
|
||||
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
|
||||
# Group results
|
||||
zstyle ':completion:*' group-name ''
|
||||
|
||||
# Autocomplete options
|
||||
zstyle ':completion:*' completer _extensions _complete _approximate
|
||||
|
|
@ -12,6 +12,7 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
./completion.nix
|
||||
./p10k.nix
|
||||
];
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ in
|
|||
enable = cfg.enable;
|
||||
dotDir = "${xdgCfg.configHome}/zsh";
|
||||
autosuggestion.enable = false;
|
||||
enableCompletion = true;
|
||||
enableCompletion = false;
|
||||
syntaxHighlighting = {
|
||||
enable = true;
|
||||
highlighters = [
|
||||
|
|
@ -53,14 +54,19 @@ in
|
|||
source "${xdgCfg.configHome}/zsh/p10k.zsh";
|
||||
'';
|
||||
zshConfig = mkOrder 1000 ''
|
||||
# Autocompletion and menu styling
|
||||
zmodload zsh/complist
|
||||
autoload -Uz compinit && compinit
|
||||
source "${xdgCfg.configHome}/zsh/completion.zsh";
|
||||
|
||||
# vi keybindings for menu select
|
||||
#bindkey -M menuselect 'h' vi-backward-char
|
||||
#bindkey -M menuselect 'k' vi-up-line-or-history
|
||||
#bindkey -M menuselect 'j' vi-down-line-or-history
|
||||
#bindkey -M menuselect 'l' vi-forward-char
|
||||
bindkey -M menuselect 'h' vi-backward-char
|
||||
bindkey -M menuselect 'k' vi-up-line-or-history
|
||||
bindkey -M menuselect 'j' vi-down-line-or-history
|
||||
bindkey -M menuselect 'l' vi-forward-char
|
||||
|
||||
# Tab to accept current selection
|
||||
#bindkey -M menuselect '^I' accept-and-infer-next-history
|
||||
bindkey -M menuselect '^I' accept-and-infer-next-history
|
||||
|
||||
# Control arrow keys
|
||||
bindkey '^[[1;5C' forward-word
|
||||
|
|
@ -85,6 +91,11 @@ in
|
|||
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/";
|
||||
file = "powerlevel10k.zsh-theme";
|
||||
}
|
||||
{
|
||||
name = "zsh-autocomplete";
|
||||
src = "${pkgs.zsh-autocomplete}/share/zsh-autocomplete/";
|
||||
file = "zsh-autocomplete.zsh";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue