-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package lazyinit | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func CmdClink(completers []string) string { | ||
// TODO pathSnippet | ||
snippet := `local function carapace_completion(command) | ||
return function(word, word_index, line_state, match_builder) | ||
local compline = string.sub(line_state:getline(), 1, line_state:getcursor()) | ||
local prog = string.format("env CARAPACE_COMPLINE=%%s carapace %%s cmd-clink '' ''", string.format("%%q", compline), command) | ||
local output = io.popen(prog):read("*a") | ||
for line in string.gmatch(output, '[^\r\n]+') do | ||
match_builder:addmatch(string.gsub(line, '\t.*', "")) | ||
end | ||
return true | ||
end | ||
end | ||
%v | ||
` | ||
argmatchers := make([]string, 0, len(completers)) | ||
for _, completer := range completers { | ||
argmatchers = append(argmatchers, | ||
fmt.Sprintf(`clink.argmatcher("%v"):addarg({carapace_completion("%v")}):loop(1)`, completer, completer), | ||
fmt.Sprintf(`clink.argmatcher("%v.exe"):addarg({carapace_completion("%v")}):loop(1)`, completer, completer), | ||
) | ||
} | ||
return fmt.Sprintf(snippet, strings.Join(argmatchers, "\n")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters