diff --git a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs index 211da99723e8..07856abd22a1 100644 --- a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs +++ b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs @@ -20,29 +20,22 @@ public class NushellShellProvider : IShellProvider """ # Add the following content to your config.nu file: - let external_completer = { |spans| - { - dotnet: { || - dotnet complete ( - $spans | skip 1 | str join " " - ) | lines - } - } | get $spans.0 | each { || do $in } + let dotnet_completer = {|spans| + dotnet complete ($spans | str join " ") | lines } - # And then in the config record, find the completions section and add the - # external_completer that was defined earlier to external: - - let-env config = { - # your options here - completions: { - # your options here - external: { - # your options here - completer: $external_completer # add it here - } - } + # Add the dotnet completer. + # (see https://nushell.sh/cookbook/external_completers.html#multiple-completer for more info) + let multiple_completers = {|spans| + match $spans.0 { + # Add the dotnet completer + "dotnet" => $dotnet_completer + _ => { [] } # Fallback to empty list, or a completer such as $carapace_completer from the example in the nushell docs. + } | do $in $spans } + + $env.config.completions.external.enable = true + $env.config.completions.external.completer = $multiple_completers """; public string GenerateCompletions(System.CommandLine.Command command) => _dynamicCompletionScript;