Skip to content

Commit

Permalink
buffer: Prefer user defined over built-in file types
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKar committed Sep 8, 2023
1 parent 18dbed8 commit cf90602
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions internal/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,27 +733,29 @@ func (b *Buffer) UpdateRules() {
}
}

// search in the default syntax files
for _, f := range config.ListRuntimeFiles(config.RTSyntaxHeader) {
data, err := f.Data()
if err != nil {
screen.TermMessage("Error loading syntax header file " + f.Name() + ": " + err.Error())
continue
}
if !foundDef {
// search in the default syntax files
for _, f := range config.ListRuntimeFiles(config.RTSyntaxHeader) {
data, err := f.Data()
if err != nil {
screen.TermMessage("Error loading syntax header file " + f.Name() + ": " + err.Error())
continue
}

header, err = highlight.MakeHeader(data)
if err != nil {
screen.TermMessage("Error reading syntax header file", f.Name(), err)
continue
}
header, err = highlight.MakeHeader(data)
if err != nil {
screen.TermMessage("Error reading syntax header file", f.Name(), err)
continue
}

if ft == "unknown" || ft == "" {
if highlight.MatchFileName(header, b.Path) {
syntaxFiles = append(syntaxFiles, SyntaxFileBuffer{header, f.Name(), nil})
if ft == "unknown" || ft == "" {
if highlight.MatchFileName(header, b.Path) {
syntaxFiles = append(syntaxFiles, SyntaxFileBuffer{header, f.Name(), nil})
}
} else if header.FileType == ft {
syntaxFile = f.Name()
break
}
} else if header.FileType == ft {
syntaxFile = f.Name()
break
}
}

Expand Down

0 comments on commit cf90602

Please sign in to comment.