X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cmd%2Fmicro%2Fhighlighter.go;h=c71870e50f4ae7da7e653e3ddf1f100d21d399ef;hb=3ecdd96931ac75039105b5a4ac2fdd3b5526dbf6;hp=413372d64e71b3eb0837166532ed6322d8cb0b71;hpb=efe1ab5db62fe89b9bbd2096ce68492a788fc8c7;p=micro.git diff --git a/cmd/micro/highlighter.go b/cmd/micro/highlighter.go index 413372d6..c71870e5 100644 --- a/cmd/micro/highlighter.go +++ b/cmd/micro/highlighter.go @@ -259,13 +259,16 @@ func LoadRulesFromFile(text, filename string) []SyntaxRule { // FindFileType finds the filetype for the given buffer func FindFileType(buf *Buffer) string { + for r := range syntaxFiles { + if r[1] != nil && r[1].MatchString(buf.Line(0)) { + // The header statement matches the first line + return syntaxFiles[r].filetype + } + } for r := range syntaxFiles { if r[0] != nil && r[0].MatchString(buf.Path) { // The syntax statement matches the extension return syntaxFiles[r].filetype - } else if r[1] != nil && r[1].MatchString(buf.Line(0)) { - // The header statement matches the first line - return syntaxFiles[r].filetype } } return "Unknown"