Skip to content

Commit

Permalink
elvish: register .exe completion on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 24, 2024
1 parent 5a5298e commit 47a87c8
Showing 1 changed file with 8 additions and 2 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)
}

0 comments on commit 47a87c8

Please sign in to comment.