Skip to content

Commit

Permalink
Merge pull request #2064 from rsteube/mv-lazyinit
Browse files Browse the repository at this point in the history
move lazyinit
  • Loading branch information
rsteube authored Dec 10, 2023
2 parents 3a4efa7 + 8e785ef commit fb92392
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 281 deletions.
271 changes: 0 additions & 271 deletions cmd/carapace/cmd/lazyInit.go

This file was deleted.

30 changes: 30 additions & 0 deletions cmd/carapace/cmd/lazyinit/bash.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package lazyinit

import (
"fmt"
"strings"
)

func Bash(completers []string) string {
snippet := `%v%v
_carapace_lazy() {
source <(carapace $1 bash)
$"_$1_completion"
}
complete -F _carapace_lazy %v
`
return fmt.Sprintf(snippet, pathSnippet("bash"), envSnippet("bash"), strings.Join(completers, " "))
}

func BashBle(completers []string) string {
snippet := `%v
_carapace_lazy() {
source <(carapace $1 bash-ble)
$"_$1_completion_ble"
}
complete -F _carapace_lazy %v
`
return fmt.Sprintf(snippet, pathSnippet("bash-ble"), strings.Join(completers, " "))
}
20 changes: 20 additions & 0 deletions cmd/carapace/cmd/lazyinit/elvish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package lazyinit

import (
"fmt"
"strings"
)

func Elvish(completers []string) string {
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
}
}
`
return fmt.Sprintf(snippet, pathSnippet("elvish"), strings.Join(completers, " "))
}
23 changes: 23 additions & 0 deletions cmd/carapace/cmd/lazyinit/fish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package lazyinit

import (
"fmt"
"strings"
)

func Fish(completers []string) string {
snippet := `%v%v
function _carapace_lazy
complete -c $argv[1] -e
carapace $argv[1] fish | source
complete --do-complete=(commandline -cp)
end
%v
`
complete := make([]string, len(completers))
for index, completer := range completers {
complete[index] = fmt.Sprintf(`complete -c '%v' -f -a '(_carapace_lazy %v)'`, completer, completer)
}
return fmt.Sprintf(snippet, pathSnippet("fish"), envSnippet("fish"), strings.Join(complete, "\n"))
}
Loading

0 comments on commit fb92392

Please sign in to comment.