Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions cookbook/external_completers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>|
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

Expand All @@ -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<string>|
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
Expand Down Expand Up @@ -137,6 +127,8 @@ let external_completer = {|spans|
} | do $in $spans
}

$env.CARAPACE_LENIENT = 1 # Ignore unknown shorthand flag errors

$env.config = {
# ...
completions: {
Expand Down