diff --git a/syntax_files_todo/asm.yaml b/syntax/stxAsm.go similarity index 98% rename from syntax_files_todo/asm.yaml rename to syntax/stxAsm.go index f8f4c12..27ae9a7 100644 --- a/syntax_files_todo/asm.yaml +++ b/syntax/stxAsm.go @@ -1,4 +1,10 @@ -filetype: asm +//go:build stxAsm || stxAll + +package syntax + +func init() { + syntaxMap["asm"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: asm detect: filename: "\\.(S|s|asm)$" @@ -106,5 +112,6 @@ rules: start: ";" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax/stxBash.go b/syntax/stxBash.go new file mode 100644 index 0000000..7ac0033 --- /dev/null +++ b/syntax/stxBash.go @@ -0,0 +1,52 @@ +//go:build stxBash || stxAll + +package syntax + +func init() { + syntaxMap["bash"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: shell + +detect: + filename: "(\\.sh$|\\.bash|\\.bashrc|bashrc|\\.bash_aliases|bash_aliases|\\.bash_functions|bash_functions|\\.bash_profile|bash_profile|Pkgfile|pkgmk.conf|profile|rc.conf|PKGBUILD|.ebuild\\$|APKBUILD)" + header: "^#!.*/(env +)?(ba)?sh( |$)" + +rules: + # Numbers + - constant.number: "\\b[0-9]+\\b" + # Conditionals and control flow + - statement: "\\b(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\\b" + # Shell commands + - type: "\\b(cd|echo|export|let|set|umask|unset)\\b" + # Common linux commands + - type: "\\b((g|ig)?awk|bash|dash|find|\\w{0,4}grep|kill|killall|\\w{0,4}less|make|pkill|sed|sh|tar|ping|traceroute|service|dpkg|apt|apt-get|apt-cache|aptitude|dpkg-buildpackage|yum)\\b" + # Coreutils commands + - type: "\\b(which|sudo|base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|(l)?dd|df|dir|dircolors|dirname|du|env|expand|expr|factor|false|fmt|fold|head|hostid|id|install|join|link|ln|logname|ls|md5sum|mkdir|mkfifo|mknod|mktemp|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|pr|printenv|printf|ptx|pwd|readlink|realpath|rm|rmdir|runcon|seq|(sha1|sha224|sha256|sha384|sha512)sum|shred|shuf|sleep|sort|split|stat|stdbuf|stty|sum|sync|tac|tail|tee|test|time|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|users|vdir|wc|who|whoami|yes)\\b" + - identifier.var: "(^([[:space:]]+)?[A-Za-z0-9_]+)" + - special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|` + "`" + `|\\\\|\\$|<|>|!|=|&|\\|)" + # Conditional flags + - statement: "--[a-z-]+" + - statement: "\\ -[a-z]+" + + - identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" + - identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" + - symbol.brackets: "(\\[|\\]|\\{|\\}|[()])" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'" + end: "'" + rules: [] + + - comment: + start: "#" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/c.yaml b/syntax/stxC.go similarity index 86% rename from syntax_files_todo/c.yaml rename to syntax/stxC.go index 2c3bb90..1913237 100644 --- a/syntax_files_todo/c.yaml +++ b/syntax/stxC.go @@ -1,11 +1,17 @@ -filetype: c +//go:build stxC || stxAll + +package syntax + +func init() { + syntaxMap["c"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: c detect: filename: "(\\.(c|C)$|\\.(h|H)$|\\.ii?$|\\.(def)$)" header: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)" rules: - - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" + - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - statement: "([a-zA-Z][a-zA-Z0-9_]*)[[:space:]]*\\(" - type: "\\b(float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b" - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" @@ -22,7 +28,7 @@ rules: - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)" - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" # Operator Color - - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" + - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" - symbol.brackets: "[(){}]|\\[|\\]" - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)" - constant.number: "NULL" @@ -52,5 +58,6 @@ rules: start: "/\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/caddyfile.yaml b/syntax/stxCaddyfile.go similarity index 69% rename from syntax_files_todo/caddyfile.yaml rename to syntax/stxCaddyfile.go index cb21821..c3f36ff 100644 --- a/syntax_files_todo/caddyfile.yaml +++ b/syntax/stxCaddyfile.go @@ -1,4 +1,10 @@ -filetype: caddyfile +//go:build stxCaddyfile || stxAll + +package syntax + +func init() { + syntaxMap["caddyfile"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: caddyfile detect: filename: "Caddyfile" @@ -19,5 +25,6 @@ rules: - comment: start: "#" end: "$" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/cmake.yaml b/syntax/stxCmake.go similarity index 85% rename from syntax_files_todo/cmake.yaml rename to syntax/stxCmake.go index d23e613..4b2fafe 100644 --- a/syntax_files_todo/cmake.yaml +++ b/syntax/stxCmake.go @@ -1,4 +1,10 @@ -filetype: cmake +//go:build stxCmake || stxAll + +package syntax + +func init() { + syntaxMap["cmake"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: cmake detect: filename: "(CMakeLists\\.txt|\\.cmake)$" @@ -38,5 +44,6 @@ rules: start: "#" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/cpp.yaml b/syntax/stxCpp.go similarity index 85% rename from syntax_files_todo/cpp.yaml rename to syntax/stxCpp.go index d1ffaeb..ff17f29 100644 --- a/syntax_files_todo/cpp.yaml +++ b/syntax/stxCpp.go @@ -1,11 +1,17 @@ -filetype: c++ +//go:build stxCpp || stxAll + +package syntax + +func init() { + syntaxMap["cpp"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: c++ detect: filename: "(\\.c(c|pp|xx)$|\\.h(h|pp|xx)$|\\.ii?$|\\.(def)$)" rules: - - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" + - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - type: "\\b(auto|float|double|bool|char|int|short|long|sizeof|enum|void|static|const|constexpr|struct|union|typedef|extern|(un)?signed|inline)\\b" - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" - statement: "\\b(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\\b" @@ -19,7 +25,7 @@ rules: - statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)" # Operator Color - - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" + - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" # Parenthetical Color - symbol.brackets: "[(){}]|\\[|\\]" @@ -51,5 +57,6 @@ rules: start: "/\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/csharp.yaml b/syntax/stxCsharp.go similarity index 90% rename from syntax_files_todo/csharp.yaml rename to syntax/stxCsharp.go index 028b661..9a4be4f 100644 --- a/syntax_files_todo/csharp.yaml +++ b/syntax/stxCsharp.go @@ -1,4 +1,10 @@ -filetype: csharp +//go:build stxCsharp || stxAll + +package syntax + +func init() { + syntaxMap["csharp"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: csharp detect: filename: "\\.cs$" @@ -47,5 +53,6 @@ rules: start: "/\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/css.yaml b/syntax/stxCss.go similarity index 97% rename from syntax_files_todo/css.yaml rename to syntax/stxCss.go index 9d2ce41..abc1017 100644 --- a/syntax_files_todo/css.yaml +++ b/syntax/stxCss.go @@ -1,4 +1,10 @@ -filetype: css +//go:build stxCss || stxAll + +package syntax + +func init() { + syntaxMap["css"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: css detect: filename: "\\.(css|scss)$" @@ -40,5 +46,6 @@ rules: start: "\\/\\*" end: "\\*\\/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/d.yaml b/syntax/stxD.go similarity index 93% rename from syntax_files_todo/d.yaml rename to syntax/stxD.go index 10f69ca..5970f66 100644 --- a/syntax_files_todo/d.yaml +++ b/syntax/stxD.go @@ -1,4 +1,10 @@ -filetype: d +//go:build stxD || stxAll + +package syntax + +func init() { + syntaxMap["d"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: d detect: filename: "\\.(d(i|d)?)$" @@ -50,11 +56,11 @@ rules: - constant: "\\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\\b" # String literals # DoubleQuotedString - - constant.string: + - constant.string: start: "\"" end: "\"" skip: "\\\\." - rules: + rules: - constant.specialChar: "\\\\." # WysiwygString - constant.string: @@ -63,8 +69,8 @@ rules: rules: - constant.specialChar: "\\\\." - constant.string: - start: "`" - end: "`" + start: "` + "`" + `" + end: "` + "`" + `" rules: - constant.specialChar: "\\\\." # HexString @@ -92,7 +98,7 @@ rules: - constant.string: start: "q\"<" end: "q\">" - rules: + rules: - constant.specialChar: "\\\\." - constant.string: start: "q\"[^({[<\"][^\"]*$" @@ -105,7 +111,7 @@ rules: rules: - constant.specialChar: "\\\\." # Comments - - comment: + - comment: start: "//" end: "$" rules: [] @@ -116,5 +122,6 @@ rules: - comment: start: "/\\+" end: "\\+/" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/dart.yaml b/syntax/stxDart.go similarity index 87% rename from syntax_files_todo/dart.yaml rename to syntax/stxDart.go index 5409d05..a06df7f 100644 --- a/syntax_files_todo/dart.yaml +++ b/syntax/stxDart.go @@ -1,4 +1,10 @@ -filetype: dart +//go:build stxDart || stxAll + +package syntax + +func init() { + syntaxMap["dart"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: dart detect: filename: "\\.dart$" @@ -42,5 +48,6 @@ rules: end: "'" skip: "\\\\." rules: - - constant.specialChar: "\\\\." - + - constant.specialChar: "\\\\."`) + }} +} diff --git a/syntax_files_todo/diff.yaml b/syntax/stxDiff.go similarity index 50% rename from syntax_files_todo/diff.yaml rename to syntax/stxDiff.go index 9c286f5..d65b728 100644 --- a/syntax_files_todo/diff.yaml +++ b/syntax/stxDiff.go @@ -1,6 +1,12 @@ -filetype: diff +//go:build stxDiff || stxAll -detect: +package syntax + +func init() { + syntaxMap["diff"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: diff + +detect: filename: "\\.diff$" header: "^((---.*)|(\\+\\+\\+.*))" @@ -9,4 +15,6 @@ rules: - statement: "(^---.*)" - type: "(^@@.*)" - constant.number: "(^\\+.*)" - - preproc: "(^-.*)" + - preproc: "(^-.*)"`) + }} +} diff --git a/syntax_files_todo/dockerfile.yaml b/syntax/stxDockerfile.go similarity index 77% rename from syntax_files_todo/dockerfile.yaml rename to syntax/stxDockerfile.go index 4d3577e..1498f39 100644 --- a/syntax_files_todo/dockerfile.yaml +++ b/syntax/stxDockerfile.go @@ -1,4 +1,10 @@ -filetype: dockerfile +//go:build stxDockerfile || stxAll + +package syntax + +func init() { + syntaxMap["dockerfile"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: dockerfile detect: filename: "(Dockerfile[^/]*$|\\.dockerfile$)" @@ -32,5 +38,6 @@ rules: end: "'" skip: "\\\\." rules: - - constant.specialChar: "\\\\." - + - constant.specialChar: "\\\\."`) + }} +} diff --git a/syntax_files_todo/fish.yaml b/syntax/stxFish.go similarity index 87% rename from syntax_files_todo/fish.yaml rename to syntax/stxFish.go index 88798a0..a7848d6 100644 --- a/syntax_files_todo/fish.yaml +++ b/syntax/stxFish.go @@ -1,4 +1,10 @@ -filetype: fish +//go:build stxFish || stxAll + +package syntax + +func init() { + syntaxMap["fish"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: fish detect: filename: "\\.fish$" @@ -10,7 +16,7 @@ rules: # Conditionals and control flow - statement: "\\b(and|begin|break|case|continue|else|end|for|function|if|in|not|or|return|select|shift|switch|while)\\b" - - special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|^|!|=|&|\\|)" + - special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|` + "`" + `|\\\\|\\$|<|>|^|!|=|&|\\|)" # Fish commands - type: "\\b(bg|bind|block|breakpoint|builtin|cd|count|command|commandline|complete|dirh|dirs|echo|emit|eval|exec|exit|fg|fish|fish_config|fish_ident|fish_pager|fish_prompt|fish_right_prompt|fish_update_completions|fishd|funced|funcsave|functions|help|history|jobs|math|mimedb|nextd|open|popd|prevd|psub|pushd|pwd|random|read|set|set_color|source|status|string|trap|type|ulimit|umask|vared)\\b" @@ -44,5 +50,6 @@ rules: start: "#" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/fortran.yaml b/syntax/stxFortran.go similarity index 85% rename from syntax_files_todo/fortran.yaml rename to syntax/stxFortran.go index b30e544..06454a9 100644 --- a/syntax_files_todo/fortran.yaml +++ b/syntax/stxFortran.go @@ -1,4 +1,10 @@ -filetype: fortran +//go:build stxFortran || stxAll + +package syntax + +func init() { + syntaxMap["fortran"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: fortran detect: filename: "\\.([Ff]|[Ff]90|[Ff]95|[Ff][Oo][Rr])$" @@ -14,16 +20,16 @@ rules: - type: "(?i)\\b(program|public|real|recl|recursive|selected_int_kind)\\b" - type: "(?i)\\b(selected_real_kind|subroutine|status)\\b" - - constant: "(?i)\\b(abs|achar|adjustl|adjustr|allocate|bit_size|call|char)\\b" - - constant: "(?i)\\b(close|contains|count|cpu_time|cshift|date_and_time)\\b" - - constant: "(?i)\\b(deallocate|digits|dot_product|eor|eoshift|function|iachar)\\b" - - constant: "(?i)\\b(iand|ibclr|ibits|ibset|ichar|ieor|iolength|ior|ishft|ishftc)\\b" - - constant: "(?i)\\b(lbound|len|len_trim|matmul|maxexponent|maxloc|maxval|merge)\\b" - - constant: "(?i)\\b(minexponent|minloc|minval|mvbits|namelist|nearest|nullify)\\b" - - constant: "(?i)\\b(open|pad|present|print|product|pure|quote|radix)\\b" - - constant: "(?i)\\b(random_number|random_seed|range|read|readwrite|replace)\\b" - - constant: "(?i)\\b(reshape|rewind|save|scan|sequence|shape|sign|size|spacing)\\b" - - constant: "(?i)\\b(spread|sum|system_clock|target|transfer|transpose|trim)\\b" + - constant: "(?i)\\b(abs|achar|adjustl|adjustr|allocate|bit_size|call|char)\\b" + - constant: "(?i)\\b(close|contains|count|cpu_time|cshift|date_and_time)\\b" + - constant: "(?i)\\b(deallocate|digits|dot_product|eor|eoshift|function|iachar)\\b" + - constant: "(?i)\\b(iand|ibclr|ibits|ibset|ichar|ieor|iolength|ior|ishft|ishftc)\\b" + - constant: "(?i)\\b(lbound|len|len_trim|matmul|maxexponent|maxloc|maxval|merge)\\b" + - constant: "(?i)\\b(minexponent|minloc|minval|mvbits|namelist|nearest|nullify)\\b" + - constant: "(?i)\\b(open|pad|present|print|product|pure|quote|radix)\\b" + - constant: "(?i)\\b(random_number|random_seed|range|read|readwrite|replace)\\b" + - constant: "(?i)\\b(reshape|rewind|save|scan|sequence|shape|sign|size|spacing)\\b" + - constant: "(?i)\\b(spread|sum|system_clock|target|transfer|transpose|trim)\\b" - constant: "(?i)\\b(ubound|unpack|verify|write|tiny|type|use|yes)\\b" - statement: "(?i)\\b(.and.|case|do|else|else?if|else?where|end|end?do|end?if)\\b" @@ -59,5 +65,6 @@ rules: start: "!" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/gdscript.yaml b/syntax/stxGdscript.go similarity index 85% rename from syntax_files_todo/gdscript.yaml rename to syntax/stxGdscript.go index e323c15..f82f579 100644 --- a/syntax_files_todo/gdscript.yaml +++ b/syntax/stxGdscript.go @@ -1,4 +1,10 @@ -filetype: gdscript +//go:build stxGdscript || stxAll + +package syntax + +func init() { + syntaxMap["gdscript"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: gdscript detect: filename: "\\.gd$" @@ -15,9 +21,9 @@ rules: # types - type: "\\b(Vector2|Vector3)\\b" # definitions - - identifier: "func [a-zA-Z_0-9]+" + - identifier: "func [a-zA-Z_0-9]+" # keywords - - statement: "\\b(and|as|assert|break|breakpoint|class|const|continue|elif|else|export|extends|for|func|if|in|map|not|onready|or|pass|return|signal|var|while|yield)\\b" + - statement: "\\b(and|as|assert|break|breakpoint|class|const|continue|elif|else|export|extends|for|func|if|in|map|not|onready|or|pass|return|signal|var|while|yield)\\b" # decorators - special: "@.*[(]" @@ -59,13 +65,14 @@ rules: - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" - constant.string: - start: "`" - end: "`" + start: "` + "`" + `" + end: "` + "`" + `" rules: [] - comment: start: "#" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax/stxGo.go b/syntax/stxGo.go index b1b73a7..4a2b127 100644 --- a/syntax/stxGo.go +++ b/syntax/stxGo.go @@ -68,7 +68,6 @@ rules: start: "/\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" -`) + - todo: "(TODO|XXX|FIXME):?"`) }} } diff --git a/syntax_files_todo/haskell.yaml b/syntax/stxHaskell.go similarity index 88% rename from syntax_files_todo/haskell.yaml rename to syntax/stxHaskell.go index af406ab..15ea38d 100644 --- a/syntax_files_todo/haskell.yaml +++ b/syntax/stxHaskell.go @@ -1,4 +1,10 @@ -filetype: haskell +//go:build stxHaskell || stxAll + +package syntax + +func init() { + syntaxMap["haskell"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: haskell detect: filename: "\\.hs$" @@ -47,4 +53,6 @@ rules: rules: - todo: "(TODO|XXX|FIXME):?" - - identifier.micro: "undefined" + - identifier.micro: "undefined"`) + }} +} diff --git a/syntax_files_todo/html.yaml b/syntax/stxHtml.go similarity index 89% rename from syntax_files_todo/html.yaml rename to syntax/stxHtml.go index d858096..95c6b35 100644 --- a/syntax_files_todo/html.yaml +++ b/syntax/stxHtml.go @@ -1,6 +1,12 @@ -filetype: html +//go:build stxHtml || stxAll -detect: +package syntax + +func init() { + syntaxMap["html"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: html + +detect: filename: "\\.htm[l]?$" rules: @@ -40,5 +46,6 @@ rules: end: "" limit-group: symbol.tag rules: - - include: "css" - + - include: "css"`) + }} +} diff --git a/syntax_files_todo/html5.yaml b/syntax/stxHtml5.go similarity index 86% rename from syntax_files_todo/html5.yaml rename to syntax/stxHtml5.go index bce0ae8..2e17dc1 100644 --- a/syntax_files_todo/html5.yaml +++ b/syntax/stxHtml5.go @@ -1,6 +1,12 @@ -filetype: html5 +//go:build stxHtml5 || stxAll -detect: +package syntax + +func init() { + syntaxMap["html5"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: html5 + +detect: filename: "\\.htm[l]?5$" header: "" @@ -22,4 +28,6 @@ rules: - symbol.tag: "<|>" - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" - comment: "" - - preproc: "" + - preproc: ""`) + }} +} diff --git a/syntax/stxIni.go b/syntax/stxIni.go index d3b8ec0..1c92962 100644 --- a/syntax/stxIni.go +++ b/syntax/stxIni.go @@ -17,7 +17,6 @@ rules: - special: "^[[:space:]]*\\[.*\\]$" - statement: "[=;]" - comment: "(^|[[:space:]])#([^{].*)?$" - - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" -`) + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'"`) }} } diff --git a/syntax_files_todo/arduino.yaml b/syntax/stxIno.go similarity index 89% rename from syntax_files_todo/arduino.yaml rename to syntax/stxIno.go index 59ba451..fb33bac 100644 --- a/syntax_files_todo/arduino.yaml +++ b/syntax/stxIno.go @@ -1,12 +1,18 @@ -filetype: ino +//go:build stxIno || stxAll + +package syntax + +func init() { + syntaxMap["ino"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: ino detect: filename: "\\.?ino$" rules: - - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" + - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - ## + ## - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" ## Constants @@ -33,7 +39,7 @@ rules: - type: "\\b(boolean|byte|char|float|int|long|word)\\b" ## Control Structions - - statement: "\\b(case|class|default|do|double|else|false|for|if|new|null|private|protected|public|short|signed|static|String|switch|this|throw|try|true|unsigned|void|while)\\b" + - statement: "\\b(case|class|default|do|double|else|false|for|if|new|null|private|protected|public|short|signed|static|String|switch|this|throw|try|true|unsigned|void|while)\\b" - statement: "\\b(goto|continue|break|return)\\b" ## Math @@ -66,7 +72,7 @@ rules: ## Structure - identifier: "\\b(setup|loop)\\b" - ## + ## - statement: "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" ## GCC builtins @@ -97,5 +103,6 @@ rules: start: "/\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/java.yaml b/syntax/stxJava.go similarity index 84% rename from syntax_files_todo/java.yaml rename to syntax/stxJava.go index c045a0c..fcbf8cc 100644 --- a/syntax_files_todo/java.yaml +++ b/syntax/stxJava.go @@ -1,4 +1,10 @@ -filetype: java +//go:build stxJava || stxAll + +package syntax + +func init() { + syntaxMap["java"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: java detect: filename: "\\.java$" @@ -33,5 +39,6 @@ rules: - comment: start: "/\\*" end: "\\*/" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/js.yaml b/syntax/stxJs.go similarity index 90% rename from syntax_files_todo/js.yaml rename to syntax/stxJs.go index 33628ea..ed576c9 100644 --- a/syntax_files_todo/js.yaml +++ b/syntax/stxJs.go @@ -1,4 +1,10 @@ -filetype: javascript +//go:build stxJs || stxAll + +package syntax + +func init() { + syntaxMap["js"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: javascript detect: filename: "\\.js$" @@ -45,5 +51,6 @@ rules: - comment: start: "/\\*" end: "\\*/" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/json.yaml b/syntax/stxJson.go similarity index 75% rename from syntax_files_todo/json.yaml rename to syntax/stxJson.go index c590bd3..db34d3a 100644 --- a/syntax_files_todo/json.yaml +++ b/syntax/stxJson.go @@ -1,4 +1,10 @@ -filetype: json +//go:build stxJson || stxAll + +package syntax + +func init() { + syntaxMap["json"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: json detect: filename: "\\.json$" @@ -10,7 +16,7 @@ rules: - constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" - constant: "\\b(null)\\b" - constant: "\\b(true|false)\\b" - - constant.string: + - constant.string: start: "\"" end: "\"" skip: "\\\\." @@ -24,4 +30,6 @@ rules: - constant.specialChar: "\\\\." - statement: "\\\"(\\\\\"|[^\"])*\\\"[[:space:]]*:\" \"'(\\'|[^'])*'[[:space:]]*:" - - constant: "\\\\u[0-9a-fA-F]{4}|\\\\[bfnrt'\"/\\\\]" + - constant: "\\\\u[0-9a-fA-F]{4}|\\\\[bfnrt'\"/\\\\]"`) + }} +} diff --git a/syntax_files_todo/lisp.yaml b/syntax/stxLisp.go similarity index 69% rename from syntax_files_todo/lisp.yaml rename to syntax/stxLisp.go index ac75ab9..73387cd 100644 --- a/syntax_files_todo/lisp.yaml +++ b/syntax/stxLisp.go @@ -1,6 +1,12 @@ -filetype: lisp +//go:build stxLisp || stxAll -detect: +package syntax + +func init() { + syntaxMap["lisp"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: lisp + +detect: filename: "(emacs|zile)$|\\.(el|li?sp|scm|ss)$" rules: @@ -14,4 +20,6 @@ rules: - constant.specialChar: "\\\\.?" - comment: "(^|[[:space:]]);.*" - indent-char.whitespace: "[[:space:]]+$" - - indent-char: " + +| + +" + - indent-char: " + +| + +"`) + }} +} diff --git a/syntax_files_todo/lua.yaml b/syntax/stxLua.go similarity index 93% rename from syntax_files_todo/lua.yaml rename to syntax/stxLua.go index b05093c..9e958dd 100644 --- a/syntax_files_todo/lua.yaml +++ b/syntax/stxLua.go @@ -1,4 +1,10 @@ -filetype: lua +//go:build stxLua || stxAll + +package syntax + +func init() { + syntaxMap["lua"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: lua detect: filename: "\\.lua$" @@ -51,13 +57,14 @@ rules: end: "$" rules: [] - - comment: + - comment: start: "\\-\\-" end: "$" rules: [] - - comment: + - comment: start: "\\-\\-\\[\\[" end: "\\]\\]" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/makefile.yaml b/syntax/stxMakefile.go similarity index 89% rename from syntax_files_todo/makefile.yaml rename to syntax/stxMakefile.go index 2c40235..0a161ee 100644 --- a/syntax_files_todo/makefile.yaml +++ b/syntax/stxMakefile.go @@ -1,4 +1,10 @@ -filetype: makefile +//go:build stxMakefile || stxAll + +package syntax + +func init() { + syntaxMap["makefile"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: makefile detect: filename: "([Mm]akefile|\\.ma?k)$" @@ -38,5 +44,6 @@ rules: - comment: start: "#" end: "$" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/man.yaml b/syntax/stxMan.go similarity index 51% rename from syntax_files_todo/man.yaml rename to syntax/stxMan.go index 0760048..d63491b 100644 --- a/syntax_files_todo/man.yaml +++ b/syntax/stxMan.go @@ -1,6 +1,12 @@ -filetype: man +//go:build stxMan || stxAll -detect: +package syntax + +func init() { + syntaxMap["man"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: man + +detect: filename: "\\.[1-9]x?$" rules: @@ -9,4 +15,6 @@ rules: - brightred: "\\.(BR?|I[PR]?).*$" - brightblue: "\\.(BR?|I[PR]?|PP)" - brightwhite: "\\\\f[BIPR]" - - yellow: "\\.(br|DS|RS|RE|PD)" + - yellow: "\\.(br|DS|RS|RE|PD)"`) + }} +} diff --git a/syntax/stxObjc.go b/syntax/stxObjc.go new file mode 100644 index 0000000..87aa442 --- /dev/null +++ b/syntax/stxObjc.go @@ -0,0 +1,67 @@ +//go:build stxObjc || stxAll + +package syntax + +func init() { + syntaxMap["objc"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: objective-c + +detect: + filename: "\\.(m|mm|h)$" + +rules: + - type: "\\b(float|double|CGFloat|id|bool|BOOL|Boolean|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline|Class|SEL|IMP|NS(U)?Integer)\\b" + - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" + - type: "\\b[A-Z][A-Z][[:alnum:]]*\\b" + - type: "\\b[A-Za-z0-9_]*_t\\b" + - type: "\\bdispatch_[a-zA-Z0-9_]*_t\\b" + + - statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__|__unused|_Nonnull|_Nullable|__block|__builtin.*)" + - statement: "\\b(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\\b" + - statement: "\\b(for|if|while|do|else|case|default|switch)\\b" + - statement: "\\b(try|throw|catch|operator|new|delete)\\b" + - statement: "\\b(goto|continue|break|return)\\b" + - statement: "\\b(nonatomic|atomic|readonly|readwrite|strong|weak|assign)\\b" + - statement: "@(encode|end|interface|implementation|class|selector|protocol|synchronized|try|catch|finally|property|optional|required|import|autoreleasepool)" + + - preproc: "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma).*$" + - preproc: "__[A-Z0-9_]*__" + + - special: "^[[:space:]]*[#|@][[:space:]]*(import|include)[[:space:]]*[\"|<].*\\/?[>|\"][[:space:]]*$" + + - statement: "([.:;,+*|=!\\%\\[\\]]|<|>|/|-|&)" + + - constant.number: "(\\b(-?)?[0-9]+\\b|\\b\\[0-9]+\\.[0-9]+\\b|\\b0x[0-9A-F]+\\b)" + - constant: "(@\\[(\\\\.|[^\\]])*\\]|@\\{(\\\\.|[^\\}])*\\}|@\\((\\\\.|[^\\)])*\\))" + - constant: "\\b<(\\\\.[^\\>])*\\>\\b" + - constant: "\\b(nil|NULL|YES|NO|TRUE|true|FALSE|false|self)\\b" + - constant: "\\bk[[:alnum]]*\\b" + - constant.string: "'.'" + + - constant.string: + start: "@\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax/stxOcaml.go b/syntax/stxOcaml.go new file mode 100644 index 0000000..85a809d --- /dev/null +++ b/syntax/stxOcaml.go @@ -0,0 +1,34 @@ +//go:build stxOcaml || stxAll + +package syntax + +func init() { + syntaxMap["ocaml"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: ocaml + +detect: + filename: "\\.mli?$" + +rules: + # Numbers + ## Integers + ### Binary + - constant.number: "-?0[bB][01][01_]*" + ### Octal + - constant.number: "-?0[oO][0-7][0-7_]*" + ### Decimal + - constant.number: "-?\\d[\\d_]*" + ### Hexadecimal + - constant.number: "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*" + ## Real + ### Decimal + - constant.number: "-?\\d[\\d_]*.\\d[\\d_]*([eE][+-]\\d[\\d_]*.\\d[\\d_]*)?" + ### Hexadecimal + - constant.number: "-?0[xX][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*([pP][+-][0-9a-fA-F][0-9a-fA-F_]*.[0-9a-fA-F][0-9a-fA-F_]*)?" + # Comments + - comment: + start: "\\(\\*" + end: "\\*\\)" + rules: []`) + }} +} diff --git a/syntax/stxPascal.go b/syntax/stxPascal.go new file mode 100644 index 0000000..d0ec4fd --- /dev/null +++ b/syntax/stxPascal.go @@ -0,0 +1,52 @@ +//go:build stxPascal || stxAll + +package syntax + +func init() { + syntaxMap["pascal"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: pascal + +detect: + filename: "\\.pas$" + +rules: + - type: "\\b(?i:(string|ansistring|widestring|shortstring|char|ansichar|widechar|boolean|byte|shortint|word|smallint|longword|cardinal|longint|integer|int64|single|currency|double|extended))\\b" + - statement: "\\b(?i:(and|asm|array|begin|break|case|const|constructor|continue|destructor|div|do|downto|else|end|file|for|function|goto|if|implementation|in|inline|interface|label|mod|not|object|of|on|operator|or|packed|procedure|program|record|repeat|resourcestring|set|shl|shr|then|to|type|unit|until|uses|var|while|with|xor))\\b" + - statement: "\\b(?i:(as|class|dispose|except|exit|exports|finalization|finally|inherited|initialization|is|library|new|on|out|property|raise|self|threadvar|try))\\b" + - statement: "\\b(?i:(absolute|abstract|alias|assembler|cdecl|cppdecl|default|export|external|forward|generic|index|local|name|nostackframe|oldfpccall|override|pascal|private|protected|public|published|read|register|reintroduce|safecall|softfloat|specialize|stdcall|virtual|write))\\b" + - constant: "\\b(?i:(false|true|nil))\\b" + - special: + start: "asm" + end: "end" + rules: [] + - constant.number: "\\$[0-9A-Fa-f]+" + - constant.number: "\\b[+-]?[0-9]+([.]?[0-9]+)?(?i:e[+-]?[0-9]+)?" + - constant.string: + start: "#[0-9]{1,}" + end: "$" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + - preproc: + start: "{\\$" + end: "}" + rules: [] + - comment: + start: "//" + end: "$" + rules: [] + - comment: + start: "\\(\\*" + end: "\\*\\)" + rules: [] + - comment: + start: "({)(?:[^$])" + end: "}" + rules: []`) + }} +} diff --git a/syntax/stxPerl.go b/syntax/stxPerl.go new file mode 100644 index 0000000..05713af --- /dev/null +++ b/syntax/stxPerl.go @@ -0,0 +1,34 @@ +//go:build stxPerl || stxAll + +package syntax + +func init() { + syntaxMap["perl"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: perl + +detect: + filename: "\\.p[lm]$" + header: "^#!.*/(env +)?perl( |$)" + +rules: + - type: "\\b(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\\b|\\b(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\\b|\\b(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\\b|\\b(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\\b|\\b(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\\b" + - statement: "\\b(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\\b" + - identifier: + start: "[$@%]" + end: "((?i) |[^0-9A-Z_]|-)" + rules: [] + + - constant.string: "\".*\"|qq\\|.*\\|" + - default: "[sm]/.*/" + - preproc: + start: "(^use| = new)" + end: ";" + rules: [] + + - comment: "#.*" + - identifier.macro: + start: "<< 'STOP'" + end: "STOP" + rules: []`) + }} +} diff --git a/syntax_files_todo/php.yaml b/syntax/stxPhp.go similarity index 93% rename from syntax_files_todo/php.yaml rename to syntax/stxPhp.go index 9f9742b..3f62c56 100644 --- a/syntax_files_todo/php.yaml +++ b/syntax/stxPhp.go @@ -1,6 +1,12 @@ -filetype: php +//go:build stxPhp || stxAll -detect: +package syntax + +func init() { + syntaxMap["php"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: php + +detect: filename: "\\.php[2345s~]|\\.inc[2345s~]$" header: "^(<\\?php)" @@ -47,4 +53,6 @@ rules: - preproc: "<\\?(php|=)?" - preproc: "\\?>" - - preproc: "" + - preproc: ""`) + }} +} diff --git a/syntax_files_todo/python3.yaml b/syntax/stxPython3.go similarity index 89% rename from syntax_files_todo/python3.yaml rename to syntax/stxPython3.go index 79b353d..dc0e8bb 100644 --- a/syntax_files_todo/python3.yaml +++ b/syntax/stxPython3.go @@ -1,4 +1,10 @@ -filename: python3 +//go:build stxPython3 || stxAll + +package syntax + +func init() { + syntaxMap["python3"] = &lazySyntax{init: func() []byte { + return []byte(`filename: python3 detect: filename: "\\.py3$" @@ -16,9 +22,9 @@ rules: # types - type: "\\b(bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|frozenset|int|list|map|memoryview|object|property|range|reversed|set|slice|staticmethod|str|super|tuple|type|zip)\\b" # definitions - - identifier: "def [a-zA-Z_0-9]+" + - identifier: "def [a-zA-Z_0-9]+" # keywords - - statement: "\\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b" + - statement: "\\b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\\b" # decorators - brightgreen: "@.*[(]" # operators @@ -55,5 +61,6 @@ rules: - comment: start: "#" end: "$" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/r.yaml b/syntax/stxR.go similarity index 62% rename from syntax_files_todo/r.yaml rename to syntax/stxR.go index f883002..70be7de 100644 --- a/syntax_files_todo/r.yaml +++ b/syntax/stxR.go @@ -1,4 +1,10 @@ -filetype: r +//go:build stxR || stxAll + +package syntax + +func init() { + syntaxMap["r"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: r detect: filename: "\\.(r|R)$" @@ -9,4 +15,6 @@ rules: - comment: start: "#" end: "$" - rules: [] + rules: []`) + }} +} diff --git a/syntax_files_todo/ruby.yaml b/syntax/stxRuby.go similarity index 81% rename from syntax_files_todo/ruby.yaml rename to syntax/stxRuby.go index 3e62e88..25790b7 100644 --- a/syntax_files_todo/ruby.yaml +++ b/syntax/stxRuby.go @@ -1,6 +1,12 @@ -filetype: ruby +//go:build stxRuby || stxAll -detect: +package syntax + +func init() { + syntaxMap["ruby"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: ruby + +detect: filename: "\\.rb$|\\.ru|\\.rbx|\\.rake|\\.gemspec$|Gemfile|Rakefile|Capfile|Vagrantfile" header: "^#!.*/(env +)?ruby( |$)" @@ -11,7 +17,7 @@ rules: - constant: "(i?)([ ]|^):[0-9A-Z_]+\\b" - constant: "\\b(__FILE__|__LINE__)\\b" - constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*" - - constant.string: "`[^`]*`|%x\\{[^}]*\\}" + - constant.string: "` + "`" + `[^` + "`" + `]*` + "`" + `|%x\\{[^}]*\\}" - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" - special: "#\\{[^}]*\\}" - constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" @@ -27,4 +33,6 @@ rules: rules: [] - todo: "(XXX|TODO|FIXME|\\?\\?\\?)" - - preproc.shebang: "^#!.+?( |$)" + - preproc.shebang: "^#!.+?( |$)"`) + }} +} diff --git a/syntax_files_todo/rust.yaml b/syntax/stxRust.go similarity index 87% rename from syntax_files_todo/rust.yaml rename to syntax/stxRust.go index 9bc1901..7027fed 100644 --- a/syntax_files_todo/rust.yaml +++ b/syntax/stxRust.go @@ -1,4 +1,10 @@ -filetype: rust +//go:build stxRust || stxAll + +package syntax + +func init() { + syntaxMap["rust"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: rust detect: filename: "\\.rs$" @@ -44,5 +50,6 @@ rules: - special: start: "#!\\[" end: "\\]" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/scala.yaml b/syntax/stxScala.go similarity index 83% rename from syntax_files_todo/scala.yaml rename to syntax/stxScala.go index 327b2b9..f0592b0 100644 --- a/syntax_files_todo/scala.yaml +++ b/syntax/stxScala.go @@ -1,4 +1,10 @@ -filetype: scala +//go:build stxScala || stxAll + +package syntax + +func init() { + syntaxMap["scala"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: scala detect: filename: "\\.scala$" @@ -25,5 +31,6 @@ rules: - comment: start: "/\\*\\*" end: "\\*/" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/swift.yaml b/syntax/stxSwift.go similarity index 85% rename from syntax_files_todo/swift.yaml rename to syntax/stxSwift.go index 348480a..5e4a17e 100644 --- a/syntax_files_todo/swift.yaml +++ b/syntax/stxSwift.go @@ -1,4 +1,10 @@ -filetype: swift +//go:build stxSwift || stxAll + +package syntax + +func init() { + syntaxMap["swift"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: swift detect: filename: "\\.swift$" @@ -47,5 +53,6 @@ rules: start: "/\\*\\*" end: "\\*/" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/systemd.yaml b/syntax/stxSystemd.go similarity index 96% rename from syntax_files_todo/systemd.yaml rename to syntax/stxSystemd.go index 35abc64..d8a087d 100644 --- a/syntax_files_todo/systemd.yaml +++ b/syntax/stxSystemd.go @@ -1,6 +1,12 @@ -filetype: systemd +//go:build stxSystemd || stxAll -detect: +package syntax + +func init() { + syntaxMap["systemd"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: systemd + +detect: filename: "\\.(service|socket)$" header: "^\\[Unit\\]$" @@ -13,4 +19,6 @@ rules: - constant.bool: "\\b(true|false)\\b" - comment: "(^|[[:space:]])#([^{].*)?$" - indent-char.whitespace: "[[:space:]]+$" - - indent-char: " + +| + +" + - indent-char: " + +| + +"`) + }} +} diff --git a/syntax_files_todo/toml.yaml b/syntax/stxToml.go similarity index 75% rename from syntax_files_todo/toml.yaml rename to syntax/stxToml.go index dcbc125..e505971 100644 --- a/syntax_files_todo/toml.yaml +++ b/syntax/stxToml.go @@ -1,4 +1,10 @@ -filetype: toml +//go:build stxToml || stxAll + +package syntax + +func init() { + syntaxMap["toml"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: toml detect: filename: "\\.toml" @@ -29,8 +35,8 @@ rules: - constant.specialChar: "\\\\." - constant.string: - start: "`" - end: "`" + start: "` + "`" + `" + end: "` + "`" + `" rules: - constant.specialChar: "\\\\." @@ -38,5 +44,6 @@ rules: start: "#" end: "$" rules: - - todo: "(TODO|XXX|FIXME):?" - + - todo: "(TODO|XXX|FIXME):?"`) + }} +} diff --git a/syntax_files_todo/typescript.yaml b/syntax/stxTs.go similarity index 89% rename from syntax_files_todo/typescript.yaml rename to syntax/stxTs.go index 9ce50eb..02c6c76 100644 --- a/syntax_files_todo/typescript.yaml +++ b/syntax/stxTs.go @@ -1,4 +1,10 @@ -filetype: typescript +//go:build stxTs || stxAll + +package syntax + +func init() { + syntaxMap["ts"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: typescript detect: filename: "\\.ts$" @@ -40,5 +46,6 @@ rules: end: "'" skip: "\\\\." rules: - - constant.specialChar: "\\\\." - + - constant.specialChar: "\\\\."`) + }} +} diff --git a/syntax_files_todo/xml.yaml b/syntax/stxXml.go similarity index 70% rename from syntax_files_todo/xml.yaml rename to syntax/stxXml.go index 9fff77d..3f66071 100644 --- a/syntax_files_todo/xml.yaml +++ b/syntax/stxXml.go @@ -1,4 +1,10 @@ -filetype: xml +//go:build stxXml || stxAll + +package syntax + +func init() { + syntaxMap["xml"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: xml detect: filename: "\\.(xml|sgml?|rng|plist)$" @@ -14,8 +20,10 @@ rules: start: "" rules: [] - - comment: + - comment: start: "" rules: [] - - special: "&[^;]*;" + - special: "&[^;]*;"`) + }} +} diff --git a/syntax_files_todo/yaml.yaml b/syntax/stxYaml.go similarity index 82% rename from syntax_files_todo/yaml.yaml rename to syntax/stxYaml.go index 68238df..3147d40 100644 --- a/syntax_files_todo/yaml.yaml +++ b/syntax/stxYaml.go @@ -1,4 +1,10 @@ -filetype: yaml +//go:build stxYaml || stxAll + +package syntax + +func init() { + syntaxMap["yaml"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: yaml detect: filename: "\\.ya?ml$" @@ -31,6 +37,6 @@ rules: - comment: start: "#" end: "$" - rules: [] - - + rules: []`) + }} +} diff --git a/syntax_files_todo/zsh.yaml b/syntax/stxZsh.go similarity index 88% rename from syntax_files_todo/zsh.yaml rename to syntax/stxZsh.go index 2182b8c..289b4b6 100644 --- a/syntax_files_todo/zsh.yaml +++ b/syntax/stxZsh.go @@ -1,4 +1,10 @@ -filetype: zsh +//go:build stxZsh || stxAll + +package syntax + +func init() { + syntaxMap["zsh"] = &lazySyntax{init: func() []byte { + return []byte(`filetype: zsh detect: filename: "(\\.zsh$|\\.?(zshenv|zprofile|zshrc|zlogin|zlogout)$)" @@ -11,7 +17,7 @@ rules: ## Conditionals and control flow - statement: "\\b(always|break|bye|case|continue|disown|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\\b" - - statement: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)" + - statement: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|` + "`" + `|\\\\|\\$|<|>|!|=|&|\\|)" ## Conditional flags - special: "-[Ldefgruwx]\\b" - special: "-(eq|ne|gt|lt|ge|le|s|n|z)\\b" @@ -48,5 +54,6 @@ rules: - comment: start: "#" end: "$" - rules: [] - + rules: []`) + }} +} diff --git a/syntax_files_todo/bash.yaml b/syntax_files_todo/bash.yaml deleted file mode 120000 index 3bc4250..0000000 --- a/syntax_files_todo/bash.yaml +++ /dev/null @@ -1 +0,0 @@ -sh.yaml \ No newline at end of file diff --git a/syntax_files_todo/c++.yaml b/syntax_files_todo/c++.yaml deleted file mode 100644 index f0ec8f6..0000000 --- a/syntax_files_todo/c++.yaml +++ /dev/null @@ -1,28 +0,0 @@ -filetype: c++ - -detect: - filename: "\\.c(c|pp|xx)$|\\.h(h|pp|xx)$|\\.ii?$|\\.(def)$" - -rules: - - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - - type: "\\b(auto|float|double|bool|char|int|short|long|sizeof|enum|void|static|const|constexpr|struct|union|typedef|extern|(un)?signed|inline)\\b" - - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" - - statement: "\\b(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\\b" - - statement: "\\b(for|if|while|do|else|case|default|switch)\\b" - - statement: "\\b(try|throw|catch|operator|new|delete)\\b" - - special: "\\b(goto|continue|break|return)\\b" - - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)" - - constant: "'([^'\\\\]|(\\\\[\"'abfnrtv\\\\]))'|'\\\\(([0-3]?[0-7]{1,2}))'|'\\\\x[0-9A-Fa-f]{1,2}'" - - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" - - symbol.operator: "[.:;,+*|=!\\%]|<|>|/|-|&" - - symbol.brackets: "[(){}]|\\[|\\]" - - constant.number: "\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b" - - constant.bool: "\\b(true|false)\\b|NULL" - - constant.string: "\"(\\\\.|[^\"])*\"" - - comment: "//.*" - - comment: - start: "/\\*" - end: "\\*/" - rules: [] - - - indent-char.whitespace: "[[:space:]]+$"