From fcd72e548ef9416c01756c04014a15ebe6a108b4 Mon Sep 17 00:00:00 2001 From: sibber5 Date: Fri, 12 Jun 2026 16:44:06 +0300 Subject: [PATCH 1/3] Fix outdated Nushell completion script --- .../shells/NuShellShellProvider.cs | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs index 211da99723e8..e4b1486507e7 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 - } - } + # If you are using other completers, add the dotnet completer. Otherwise, just set external.completer to $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 + # your other completers... + } | do $in $spans } + + $env.config.completions.external.enable = true + $env.config.completions.external.completer = $multiple_completers """; public string GenerateCompletions(System.CommandLine.Command command) => _dynamicCompletionScript; From 37dc4d51c35f64dd351a979b19f3740da7f4fc4c Mon Sep 17 00:00:00 2001 From: sibber5 Date: Fri, 12 Jun 2026 17:00:20 +0300 Subject: [PATCH 2/3] Update Nushell completion script --- .../shells/NuShellShellProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs index e4b1486507e7..07856abd22a1 100644 --- a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs +++ b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs @@ -24,13 +24,13 @@ public class NushellShellProvider : IShellProvider dotnet complete ($spans | str join " ") | lines } - # If you are using other completers, add the dotnet completer. Otherwise, just set external.completer to $dotnet_completer. + # 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 - # your other completers... + _ => { [] } # Fallback to empty list, or a completer such as $carapace_completer from the example in the nushell docs. } | do $in $spans } From 0aa073c918368d0ff8c8862582604e1185395fb7 Mon Sep 17 00:00:00 2001 From: sibber5 Date: Mon, 15 Jun 2026 22:06:16 +0300 Subject: [PATCH 3/3] Switch to nushell native custom completions --- .../shells/NuShellShellProvider.cs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs index 07856abd22a1..88cf27542591 100644 --- a/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs +++ b/src/System.CommandLine.StaticCompletions/shells/NuShellShellProvider.cs @@ -18,24 +18,13 @@ public class NushellShellProvider : IShellProvider private static readonly string _dynamicCompletionScript = """ - # Add the following content to your config.nu file: - - let dotnet_completer = {|spans| - dotnet complete ($spans | str join " ") | lines - } - - # 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 + def "nu-complete dotnet" [context: string] { + ^dotnet complete $"($context)" | lines } - $env.config.completions.external.enable = true - $env.config.completions.external.completer = $multiple_completers + export extern "dotnet" [ + ...command: string@"nu-complete dotnet" + ] """; public string GenerateCompletions(System.CommandLine.Command command) => _dynamicCompletionScript;