Skip to content

Commit

Permalink
infocomplete: Complete filetypes (#3090)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKar authored Jan 17, 2024
1 parent 422305a commit e5a9b90
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/action/infocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ func colorschemeComplete(input string) (string, []string) {
return chosen, suggestions
}

// filetypeComplete autocompletes filetype
func filetypeComplete(input string) (string, []string) {
var suggestions []string

for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
if strings.HasPrefix(f.Name(), input) {
suggestions = append(suggestions, f.Name())
}
}

var chosen string
if len(suggestions) == 1 {
chosen = suggestions[0]
}

return chosen, suggestions
}

func contains(s []string, e string) bool {
for _, a := range s {
if a == e {
Expand Down Expand Up @@ -172,6 +190,8 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
switch inputOpt {
case "colorscheme":
_, suggestions = colorschemeComplete(input)
case "filetype":
_, suggestions = filetypeComplete(input)
case "fileformat":
if strings.HasPrefix("unix", input) {
suggestions = append(suggestions, "unix")
Expand Down

0 comments on commit e5a9b90

Please sign in to comment.