"bytes"
"crypto/md5"
"errors"
+ "fmt"
"io"
"io/ioutil"
"os"
BTRaw = BufType{4, false, true, false}
// BTInfo is a buffer for inputting information
BTInfo = BufType{5, false, true, false}
+ // BTStdout is a buffer that only writes to stdout
+ // when closed
+ BTStdout = BufType{6, false, true, true}
// ErrFileTooLarge is returned when the file is too large to hash
// (fastdirty is automatically enabled)
// Name of the buffer on the status line
name string
+ toStdout bool
+
// Settings customized by the user
Settings map[string]interface{}
b.Serialize()
}
b.RemoveBackup()
+
+ if b.Type == BTStdout {
+ fmt.Fprint(util.Stdout, string(b.Bytes()))
+ }
}
// GetName returns the name that should be displayed in the statusline
return
}
syntaxFile := ""
+ foundDef := false
var header *highlight.Header
+ // search for the syntax file in the user's custom syntax files
+ for _, f := range config.ListRealRuntimeFiles(config.RTSyntax) {
+ data, err := f.Data()
+ if err != nil {
+ screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
+ continue
+ }
+
+ header, err = highlight.MakeHeaderYaml(data)
+ file, err := highlight.ParseFile(data)
+ if err != nil {
+ screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
+ continue
+ }
+
+ if ((ft == "unknown" || ft == "") && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
+ syndef, err := highlight.ParseDef(file, header)
+ if err != nil {
+ screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
+ continue
+ }
+ b.SyntaxDef = syndef
+ syntaxFile = f.Name()
+ foundDef = true
+ break
+ }
+ }
+
+ // search in the default syntax files
for _, f := range config.ListRuntimeFiles(config.RTSyntaxHeader) {
data, err := f.Data()
if err != nil {
}
}
- if syntaxFile == "" {
- // search for the syntax file in the user's custom syntax files
- for _, f := range config.ListRealRuntimeFiles(config.RTSyntax) {
- data, err := f.Data()
- if err != nil {
- screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
- continue
- }
-
- header, err = highlight.MakeHeaderYaml(data)
- file, err := highlight.ParseFile(data)
- if err != nil {
- screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
- continue
- }
-
- if ((ft == "unknown" || ft == "") && highlight.MatchFiletype(header.FtDetect, b.Path, b.lines[0].data)) || header.FileType == ft {
- syndef, err := highlight.ParseDef(file, header)
- if err != nil {
- screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
- continue
- }
- b.SyntaxDef = syndef
- break
- }
- }
- } else {
+ if syntaxFile != "" && !foundDef {
+ // we found a syntax file using a syntax header file
for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
if f.Name() == syntaxFile {
data, err := f.Data()