Merge branch 'helper-method-to-parse-syntax-files'

This commit is contained in:
Jesse Portnoy
2023-07-16 17:31:59 +01:00
3 changed files with 15 additions and 16 deletions
+1
View File
@@ -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
+2
View File
@@ -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=
+12 -16
View File
@@ -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)