mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-19 07:15:34 -04:00
infocomplete: Complete filetypes (#3090)
This commit is contained in:
parent
422305af99
commit
e5a9b906f3
@ -77,6 +77,24 @@ func colorschemeComplete(input string) (string, []string) {
|
|||||||
return chosen, suggestions
|
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 {
|
func contains(s []string, e string) bool {
|
||||||
for _, a := range s {
|
for _, a := range s {
|
||||||
if a == e {
|
if a == e {
|
||||||
@ -172,6 +190,8 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
|
|||||||
switch inputOpt {
|
switch inputOpt {
|
||||||
case "colorscheme":
|
case "colorscheme":
|
||||||
_, suggestions = colorschemeComplete(input)
|
_, suggestions = colorschemeComplete(input)
|
||||||
|
case "filetype":
|
||||||
|
_, suggestions = filetypeComplete(input)
|
||||||
case "fileformat":
|
case "fileformat":
|
||||||
if strings.HasPrefix("unix", input) {
|
if strings.HasPrefix("unix", input) {
|
||||||
suggestions = append(suggestions, "unix")
|
suggestions = append(suggestions, "unix")
|
||||||
|
Loading…
Reference in New Issue
Block a user