]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/highlighter.go
Add cd and pwd commands to change the working dir
[micro.git] / cmd / micro / highlighter.go
index c66385fb0df24d926bfdad48dee52e8e0184f566..c71870e50f4ae7da7e653e3ddf1f100d21d399ef 100644 (file)
@@ -32,7 +32,7 @@ var syntaxFiles map[[2]*regexp.Regexp]FileTypeRules
 func LoadSyntaxFiles() {
        InitColorscheme()
        syntaxFiles = make(map[[2]*regexp.Regexp]FileTypeRules)
-       for _, f := range ListRuntimeFiles(FILE_Syntax) {
+       for _, f := range ListRuntimeFiles(RTSyntax) {
                data, err := f.Data()
                if err != nil {
                        TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
@@ -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"