Skip to content

Commit d14ba1d

Browse files
authored
Update Nushell instructions for dynamic completions
1 parent 8436293 commit d14ba1d

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

docs/core/tools/enable-tab-autocomplete.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dotnet completions script fish | source
9191

9292
#### Nushell
9393

94-
Run `dotnet completions script nushell` and add the snippet it provides to your `config.nu` file.
94+
Run `dotnet completions script nushell` and follow the instructions it provides in your `config.nu` file.
9595
e.g., if you were not using any external completers, add the following to the end of the file:
9696
```nu
9797
let dotnet_completer = {|spans|
@@ -197,33 +197,22 @@ complete -f -c dotnet -a "(dotnet complete (commandline -cp))"
197197

198198
### nushell
199199

200-
To add tab completion to your **nushell** for .NET CLI, add the following to the beginning of your `config.nu` file:
201-
200+
To add tab completion to your **nushell** for .NET CLI, run `dotnet completions script nushell` and follow the instructions it provides in your `config.nu` file.
201+
e.g., if you were not using any external completers, add the following to the end of the file:
202202
```nu
203-
let external_completer = { |spans|
204-
{
205-
dotnet: { ||
206-
dotnet complete (
207-
$spans | skip 1 | str join " "
208-
) | lines
209-
}
210-
} | get $spans.0 | each { || do $in }
203+
let dotnet_completer = {|spans|
204+
dotnet complete ($spans | str join " ") | lines
211205
}
212-
```
213-
214-
And then in the `config` record, find the `completions` section and add the `external_completer` that was defined earlier to `external`:
215206
216-
```nu
217-
let-env config = {
218-
# your options here
219-
completions: {
220-
# your options here
221-
external: {
222-
# your options here
223-
completer: $external_completer # add it here
224-
}
225-
}
207+
let multiple_completers = {|spans|
208+
match $spans.0 {
209+
"dotnet" => $dotnet_completer
210+
_ => { [] } # Fallback to empty list
211+
} | do $in $spans
226212
}
213+
214+
$env.config.completions.external.enable = true
215+
$env.config.completions.external.completer = $multiple_completers
227216
```
228217

229218
## Completion examples

0 commit comments

Comments
 (0)