Skip to content

Commit a4e0607

Browse files
committed
feat(home/cli/nushell): add fish completer
1 parent 2ec0c19 commit a4e0607

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

home/gabriel/features/cli/nushell.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@
4747
$env.PROMPT_INDICATOR_VI_NORMAL = {|| "| " }
4848
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }
4949
50+
let fish_completer = {|spans|
51+
fish --command $"complete '--do-complete=($spans | str replace --all "'" "\\'" | str join ' ')'"
52+
| from tsv --flexible --noheaders --no-infer
53+
| rename value description
54+
| update value {|row|
55+
let value = $row.value
56+
let need_quote = ['\' ',' '[' ']' '(' ')' ' ' '\t' "'" '"' "`"] | any {$in in $value}
57+
if ($need_quote and ($value | path exists)) {
58+
let expanded_path = if ($value starts-with ~) {$value | path expand --no-symlink} else {$value}
59+
$'"($expanded_path | str replace --all "\"" "\\\"")"'
60+
} else {$value}
61+
}
62+
}
63+
5064
$env.config = {
5165
edit_mode: vi,
5266
show_banner: false,
@@ -61,6 +75,10 @@
6175
},
6276
completions: {
6377
algorithm: "fuzzy",
78+
external: {
79+
enable: true,
80+
completer: $fish_completer,
81+
},
6482
},
6583
history: {
6684
sync_on_enter: true,

0 commit comments

Comments
 (0)