Skip to content

Commit 9bd2a06

Browse files
committed
feat(apps.carapace): add carapace for shell completion
1 parent a52b791 commit 9bd2a06

File tree

5 files changed

+51
-38
lines changed

5 files changed

+51
-38
lines changed

conf.d/zsh/completion.zsh

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,46 @@ zstyle ':completion:*:approximate:*' max-errors 2 numeric
1212
zstyle ':completion:*:descriptions' format '[%d]'
1313
# set list-colors to enable filename colorizing
1414
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
15-
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
16-
zstyle ':completion:*' menu no
17-
# To make fzf-tab follow FZF_DEFAULT_OPTS.
18-
# NOTE: This may lead to unexpected behavior since some flags break this plugin. See Aloxaf/fzf-tab#455.
19-
zstyle ':fzf-tab:*' use-fzf-default-opts no
20-
zstyle ':fzf-tab:*' fzf-flags --height 60% --reverse --margin=3% --style=full \
21-
--border=rounded --border-label=' fzf-tab ' \
22-
--prompt='$ > ' --input-border --input-label=' Input ' \
23-
--list-border --highlight-line --gap --pointer='>' \
24-
--preview-border --preview-label=' Previewing ' \
25-
--color 'border:#ca9ee6,label:#cba6f7' \
26-
--color 'input-border:#ea999c,input-label:#eba0ac' \
27-
--color 'list-border:#81c8be,list-label:#94e2d5' \
28-
--color 'preview-border:#f2d5cf,preview-label:#f5e0dc' \
29-
--color 'info:#cba6f7,pointer:#f5e0dc,spinner:#f5e0dc,hl:#f38ba8' \
30-
--color 'marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8' \
31-
--color 'selected-bg:#45475a'
32-
33-
# zstyle ':fzf-tab:*' fzf-preview 'pistol ${(Q)realpath}'
34-
# switch group using `<` and `>`
35-
zstyle ':fzf-tab:*' switch-group '<' '>'
36-
# zstyle ':fzf-tab:*' accept-line enter # don't trigger enter after selected
37-
38-
# show systemd unit status
39-
zstyle ':fzf-tab:complete:systemctl-*:*' fzf-preview 'SYSTEMD_COLORS=1 systemctl status $word'
40-
41-
# show environment variable
42-
zstyle ':fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*' \
43-
fzf-preview 'echo ${(P)word}'
44-
45-
# show alias
46-
zstyle ':fzf-tab:complete:alias:*' fzf-preview 'alias $word'
47-
48-
# man or help
49-
zstyle ':fzf-tab:complete:(\\|)run-help:*' fzf-preview 'run-help $word'
50-
zstyle ':fzf-tab:complete:(\\|*/|)man:*' fzf-preview 'man $word'
15+
## force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
16+
# zstyle ':completion:*' menu no
17+
# # To make fzf-tab follow FZF_DEFAULT_OPTS.
18+
# # NOTE: This may lead to unexpected behavior since some flags break this plugin. See Aloxaf/fzf-tab#455.
19+
# zstyle ':fzf-tab:*' use-fzf-default-opts no
20+
# zstyle ':fzf-tab:*' fzf-flags --height 60% --reverse --margin=3% --style=full \
21+
# --border=rounded --border-label=' fzf-tab ' \
22+
# --prompt='$ > ' --input-border --input-label=' Input ' \
23+
# --list-border --highlight-line --gap --pointer='>' \
24+
# --preview-border --preview-label=' Previewing ' \
25+
# --color 'border:#ca9ee6,label:#cba6f7' \
26+
# --color 'input-border:#ea999c,input-label:#eba0ac' \
27+
# --color 'list-border:#81c8be,list-label:#94e2d5' \
28+
# --color 'preview-border:#f2d5cf,preview-label:#f5e0dc' \
29+
# --color 'info:#cba6f7,pointer:#f5e0dc,spinner:#f5e0dc,hl:#f38ba8' \
30+
# --color 'marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8' \
31+
# --color 'selected-bg:#45475a'
32+
33+
# # zstyle ':fzf-tab:*' fzf-preview 'pistol ${(Q)realpath}'
34+
# # switch group using `<` and `>`
35+
# zstyle ':fzf-tab:*' switch-group '<' '>'
36+
# # zstyle ':fzf-tab:*' accept-line enter # don't trigger enter after selected
37+
38+
# # show systemd unit status
39+
# zstyle ':fzf-tab:complete:systemctl-*:*' fzf-preview 'SYSTEMD_COLORS=1 systemctl status $word'
40+
41+
# # show environment variable
42+
# zstyle ':fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*' \
43+
# fzf-preview 'echo ${(P)word}'
44+
45+
# # show alias
46+
# zstyle ':fzf-tab:complete:alias:*' fzf-preview 'alias $word'
47+
48+
# # man or help
49+
# zstyle ':fzf-tab:complete:(\\|)run-help:*' fzf-preview 'run-help $word'
50+
# zstyle ':fzf-tab:complete:(\\|*/|)man:*' fzf-preview 'man $word'
51+
52+
# carapace config
53+
zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m'
54+
zstyle ':completion:*:git:*' group-order 'main commands' 'alias commands' 'external commands'
5155

5256
# disable sort when completing `git checkout`
5357
zstyle ':completion:*:git-checkout:*' sort false

modules/apps/carapace.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
carapace = {
3+
enable = true;
4+
enableZshIntegration = true;
5+
};
6+
}

modules/apps/starship.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
format = lib.concatStrings [
1717
"$username"
18+
"$hostname"
1819
"$directory"
1920
"$git_branch"
2021
"$git_metrics"
@@ -122,6 +123,7 @@
122123
character = {
123124
success_symbol = "[❯](green)";
124125
error_symbol = "[❯](red)";
126+
vimcmd_symbol = "[❮](green)";
125127
};
126128

127129
# Shows an icon that should be included by zshrc script based on the distribution or os

modules/apps/zsh.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
zprof.enable = false;
1212
enableCompletion = false;
1313
enableVteIntegration = if pkgs.stdenv.isDarwin then false else true;
14-
# defaultKeymap = "vicmd";
14+
defaultKeymap = "viins";
1515
antidote = {
1616
enable = true;
1717
useFriendlyNames = true;
@@ -24,7 +24,7 @@
2424
"QuarticCat/zsh-smartcache" # better mroth/evalcache
2525
"zsh-users/zsh-completions kind:fpath"
2626
"belak/zsh-utils path:completion"
27-
"Aloxaf/fzf-tab kind:defer" # needs to load after `compinit`, but before wrap widgets, such as `zsh-autosuggestions` or `fast-syntax-highlighting`
27+
# "Aloxaf/fzf-tab kind:defer" # needs to load after `compinit`, but before wrap widgets, such as `zsh-autosuggestions` or `fast-syntax-highlighting`
2828
"zsh-users/zsh-autosuggestions kind:defer"
2929
"zdharma-continuum/fast-syntax-highlighting kind:defer" # add before zsh-history-substring-search to prevent breaking
3030
"zpm-zsh/colorize kind:defer" # Colorize the output of various programs

modules/core.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ in
8686
inherit (import "${src}/modules/apps/home-manager.nix") home-manager;
8787
inherit (import "${src}/modules/apps/bat.nix" { inherit pkgs; }) bat;
8888
inherit (import "${src}/modules/apps/btop.nix") btop;
89+
inherit (import "${src}/modules/apps/carapace.nix") carapace;
8990
inherit (import "${src}/modules/apps/fd.nix") fd;
9091
inherit (import "${src}/modules/apps/fzf.nix") fzf;
9192
inherit (import "${src}/modules/apps/gh-dash.nix") gh-dash;

0 commit comments

Comments
 (0)