diff --git a/examples/go.mod b/examples/go.mod index 2cd13bb..6e55a4f 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -8,6 +8,7 @@ require ( ) require ( + github.com/jessp01/highlight v0.0.0-20230716160321-8969d1f05a45 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.17 // indirect golang.org/x/sys v0.6.0 // indirect diff --git a/examples/go.sum b/examples/go.sum index 22bff5e..a8532f4 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -1,5 +1,7 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/jessp01/highlight v0.0.0-20230716160321-8969d1f05a45 h1:XKfU3AV4wfMbzX0jlqSRXYdsPueivQhHgSqlyUjf28g= +github.com/jessp01/highlight v0.0.0-20230716160321-8969d1f05a45/go.mod h1:Kgvk5uZPhFlZvcS8u0zOB38emtWGrUgnfOvjINkvhyM= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= diff --git a/examples/syncat.go b/examples/syncat.go index 78ba538..47f1e50 100644 --- a/examples/syncat.go +++ b/examples/syncat.go @@ -6,9 +6,10 @@ import ( "io/ioutil" "os" "strings" + "log" "github.com/fatih/color" - "github.com/zyedidia/highlight" + "github.com/jessp01/highlight" ) func main() { @@ -17,24 +18,19 @@ func main() { return } - var defs []*highlight.Def gopath := os.Getenv("GOPATH") - files, lerr := ioutil.ReadDir(gopath + "/src/github.com/zyedidia/highlight/syntax_files") - if lerr != nil { - fmt.Println(lerr) - return + + var syn_dir string + if gopath == "" { + syn_dir = "/etc/highlight" + }else{ + syn_dir = gopath + "/src/github.com/jessp01/highlight/syntax_files" } - for _, f := range files { - if strings.HasSuffix(f.Name(), ".yaml") { - input, _ := ioutil.ReadFile(gopath + "/src/github.com/zyedidia/highlight/syntax_files/" + f.Name()) - d, err := highlight.ParseDef(input) - if err != nil { - fmt.Println(err) - continue - } - defs = append(defs, d) - } + var defs []*highlight.Def + err := highlight.ParseSyntaxFiles (syn_dir, &defs) + if err != nil { + log.Fatal(err) } highlight.ResolveIncludes(defs)