]> git.lizzy.rs Git - micro.git/blob - cmd/micro/highlight/ftdetect.go
Use bytes for highlight groups
[micro.git] / cmd / micro / highlight / ftdetect.go
1 package highlight
2
3 func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
4         for _, d := range defs {
5                 if d.ftdetect[0].Match([]byte(filename)) {
6                         return d
7                 }
8                 if len(d.ftdetect) > 1 {
9                         if d.ftdetect[1].Match(firstLine) {
10                                 return d
11                         }
12                 }
13         }
14
15         emptyDef := new(Def)
16         emptyDef.FileType = "Unknown"
17         emptyDef.rules = new(Rules)
18         return emptyDef
19 }