From b61348b4130862252e6837ebbaa8f8a9230dc279 Mon Sep 17 00:00:00 2001 From: Noah765 <99338019+Noah765@users.noreply.github.com> Date: Tue, 30 Dec 2025 08:43:49 +0100 Subject: [PATCH] Update carapace example to use $env.CARAPACE_LENIENT Unlike the current suggested solution, which is rather hacky, this configuration method is intended. --- cookbook/external_completers.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cookbook/external_completers.md b/cookbook/external_completers.md index ffcaf3bceb7..59563906922 100644 --- a/cookbook/external_completers.md +++ b/cookbook/external_completers.md @@ -89,15 +89,7 @@ Carapace will return this error when a non-supported flag is provided. For examp | -1ERR | unknown shorthand flag: "1" in -1 | | -1\_ | | -The solution to this involves manually checking the value to filter it out: - -```nu -let carapace_completer = {|spans: list| - carapace $spans.0 nushell ...$spans - | from json - | if ($in | default [] | any {|| $in.display | str starts-with "ERR"}) { null } else { $in } -} -``` +The solution to this is to set `$env.CARAPACE_LENIENT = 1`, see [the carapace documentation](https://carapace-sh.github.io/carapace-bin/setup/environment.html#carapace_lenient). ## Putting it all together @@ -107,9 +99,7 @@ This is an example of how an external completer definition might look like: let fish_completer = ... let carapace_completer = {|spans: list| - carapace $spans.0 nushell ...$spans - | from json - | if ($in | default [] | any {|| $in.display | str starts-with "ERR"}) { null } else { $in } + carapace $spans.0 nushell ...$span | from json } # This completer will use carapace by default @@ -137,6 +127,8 @@ let external_completer = {|spans| } | do $in $spans } +$env.CARAPACE_LENIENT = 1 # Ignore unknown shorthand flag errors + $env.config = { # ... completions: {