Skip to content

Commit e5a9b90

Browse files
authored
infocomplete: Complete filetypes (zyedidia#3090)
1 parent 422305a commit e5a9b90

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/action/infocomplete.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ func colorschemeComplete(input string) (string, []string) {
7777
return chosen, suggestions
7878
}
7979

80+
// filetypeComplete autocompletes filetype
81+
func filetypeComplete(input string) (string, []string) {
82+
var suggestions []string
83+
84+
for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
85+
if strings.HasPrefix(f.Name(), input) {
86+
suggestions = append(suggestions, f.Name())
87+
}
88+
}
89+
90+
var chosen string
91+
if len(suggestions) == 1 {
92+
chosen = suggestions[0]
93+
}
94+
95+
return chosen, suggestions
96+
}
97+
8098
func contains(s []string, e string) bool {
8199
for _, a := range s {
82100
if a == e {
@@ -172,6 +190,8 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
172190
switch inputOpt {
173191
case "colorscheme":
174192
_, suggestions = colorschemeComplete(input)
193+
case "filetype":
194+
_, suggestions = filetypeComplete(input)
175195
case "fileformat":
176196
if strings.HasPrefix("unix", input) {
177197
suggestions = append(suggestions, "unix")

0 commit comments

Comments
 (0)