Skip to content

Commit

Permalink
Merge pull request #2661 from carapace-sh/elvish-exe-completion
Browse files Browse the repository at this point in the history
elvish: register `.exe` completion on windows
  • Loading branch information
rsteube authored Dec 24, 2024
2 parents 5a5298e + 9f74bde commit a738ad1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions cmd/carapace/cmd/lazyinit/elvish.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ package lazyinit

import (
"fmt"
"runtime"
"strings"
)

func Elvish(completers []string) string {
windowsSnippet := ""
if runtime.GOOS == "windows" {
windowsSnippet = "\n set edit:completion:arg-completer[$c.exe] = $edit:completion:arg-completer[$c]\n"
}

snippet := `%v
put %v | each {|c|
set edit:completion:arg-completer[$c] = {|@arg|
set edit:completion:arg-completer[$c] = {|@arg| }
eval (carapace $c elvish | slurp)
$edit:completion:arg-completer[$c] $@arg
}
}%v
}
`
return fmt.Sprintf(snippet, pathSnippet("elvish"), strings.Join(completers, " "))
return fmt.Sprintf(snippet, pathSnippet("elvish"), strings.Join(completers, " "), windowsSnippet)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/carapace-sh/carapace-bin
go 1.23.1

require (
github.com/carapace-sh/carapace v1.5.0
github.com/carapace-sh/carapace v1.5.1
github.com/carapace-sh/carapace-bridge v1.2.2
github.com/carapace-sh/carapace-selfupdate v0.0.8
github.com/carapace-sh/carapace-shlex v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/carapace-sh/carapace v1.5.0 h1:rjNMTo5sY3YybMKbzEuaM19HEG6JXhvCTOrioV0QUHY=
github.com/carapace-sh/carapace v1.5.0/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
github.com/carapace-sh/carapace v1.5.1 h1:GEh7da7nQhxca4+RvjtLh63F/E1eyoEyz5iNS7xZHgY=
github.com/carapace-sh/carapace v1.5.1/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
github.com/carapace-sh/carapace-bridge v1.2.2 h1:Zlzw7BajF4iHAFBClCYcptEG+7+F324dFyiGzGiU/kw=
github.com/carapace-sh/carapace-bridge v1.2.2/go.mod h1:HpN3iEdCmQtAD1pd/qHEnWmAF719CeNyJrY8FJ5/E4o=
github.com/carapace-sh/carapace-pflag v1.0.0 h1:uJMhl+vwEM/Eb0UdxZUuv4jo4rUAyPijkRGP5gfCuCE=
Expand Down

0 comments on commit a738ad1

Please sign in to comment.