From 952a358d916a3c76d69ff5de3320398de8442cbc Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Tue, 12 Aug 2025 15:27:58 +0200 Subject: [PATCH] nu: Fix completer for nu 0.106 --- tree/.config/nushell/config.nu.tpl | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tree/.config/nushell/config.nu.tpl b/tree/.config/nushell/config.nu.tpl index eeef2c5..d4256aa 100644 --- a/tree/.config/nushell/config.nu.tpl +++ b/tree/.config/nushell/config.nu.tpl @@ -7,22 +7,18 @@ # And here is the theme collection # https://github.com/nushell/nu_scripts/tree/main/themes - -# Use fish for external completion let fish_completer = {|spans| - # if the current command is an alias, get it's expansion - let expanded_alias = (scope aliases | where name == $spans.0 | get -i 0 | get -i expansion) - - # overwrite - let spans = (if $expanded_alias != null { - # put the first word of the expanded alias first in the span - $spans | skip 1 | prepend ($expanded_alias | split row " " | take 1) - } else { $spans }) - - - fish --command $'complete "--do-complete=($spans | str join " ")"' - | $"value(char tab)description(char newline)" + $in - | from tsv --flexible --no-infer + fish --command $"complete '--do-complete=($spans | str replace --all "'" "\\'" | str join ' ')'" + | from tsv --flexible --noheaders --no-infer + | rename value description + | update value {|row| + let value = $row.value + let need_quote = ['\' ',' '[' ']' '(' ')' ' ' '\t' "'" '"' "`"] | any {$in in $value} + if ($need_quote and ($value | path exists)) { + let expanded_path = if ($value starts-with ~) {$value | path expand --no-symlink} else {$value} + $'"($expanded_path | str replace --all "\"" "\\\"")"' + } else {$value} + } } source theme.nu