File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
8098func 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" )
You can’t perform that action at this time.
0 commit comments