From 8212a04d0f31dfd8778d4035ea36585efb0faf5e Mon Sep 17 00:00:00 2001 From: rsteube Date: Sun, 15 Oct 2023 19:37:00 +0200 Subject: [PATCH] nushell: fix snippet --- example/cmd/_test/nushell.nu | 16 ++-------------- internal/shell/nushell/snippet.go | 16 ++-------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/example/cmd/_test/nushell.nu b/example/cmd/_test/nushell.nu index 0c0e5b8c5..fa236bce3 100644 --- a/example/cmd/_test/nushell.nu +++ b/example/cmd/_test/nushell.nu @@ -1,15 +1,3 @@ -let external_completer = {|spans| - { - $spans.0: { } # default - example: { example _carapace nushell $spans | from json } - } | get $spans.0 | each {|it| do $it} -} - -let-env config = { - completions: { - external: { - enable: true - completer: $external_completer - } - } +let example_completer = {|spans| + example _carapace nushell $spans | from json } diff --git a/internal/shell/nushell/snippet.go b/internal/shell/nushell/snippet.go index 72357e41b..a37f69815 100644 --- a/internal/shell/nushell/snippet.go +++ b/internal/shell/nushell/snippet.go @@ -10,19 +10,7 @@ import ( // Snippet creates the nushell completion script. func Snippet(cmd *cobra.Command) string { - return fmt.Sprintf(`let external_completer = {|spans| - { - $spans.0: { } # default - %v: { %v _carapace nushell $spans | from json } - } | get $spans.0 | each {|it| do $it} -} - -let-env config = { - completions: { - external: { - enable: true - completer: $external_completer - } - } + return fmt.Sprintf(`let %v_completer = {|spans| + %v _carapace nushell $spans | from json }`, cmd.Name(), uid.Executable()) }