mirror of
https://github.com/rwinkhart/go-highlite.git
synced 2026-08-29 05:16:26 -04:00
Add rust, sh, swift
This commit is contained in:
@@ -45,7 +45,6 @@ type Region struct {
|
||||
}
|
||||
|
||||
// ParseDef parses an input syntax file into a highlight Def
|
||||
// Note that ParseDef may return multiple errors
|
||||
func ParseDef(input []byte) (*Def, error) {
|
||||
var rules map[interface{}]interface{}
|
||||
if err := yaml.Unmarshal(input, &rules); err != nil {
|
||||
|
||||
@@ -28,7 +28,8 @@ rules:
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules: []
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
filetype: rust
|
||||
|
||||
detect:
|
||||
filename: "\\.rs$"
|
||||
|
||||
rules:
|
||||
# function definition
|
||||
- identifier: "fn [a-z0-9_]+"
|
||||
# Reserved words
|
||||
- statement: "\\b(abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\\b"
|
||||
# macros
|
||||
- special: "[a-z_]+!"
|
||||
# Constants
|
||||
- constant: "[A-Z][A-Z_]+"
|
||||
# Numbers
|
||||
- constant.number: "\\b[0-9]+\\b"
|
||||
# Traits/Enums/Structs/Types/etc.
|
||||
- type: "[A-Z][a-z]+"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- constant.string:
|
||||
start: "r#+\""
|
||||
end: "\"#+"
|
||||
rules: []
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- special:
|
||||
start: "#!\\["
|
||||
end: "\\]"
|
||||
rules: []
|
||||
@@ -0,0 +1,41 @@
|
||||
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"
|
||||
- special: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)"
|
||||
# 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)\\b"
|
||||
# Coreutils commands
|
||||
- type: "\\b(base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|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"
|
||||
# Conditional flags
|
||||
- statement: "--[a-z-]+"
|
||||
- statement: "\\ -[a-z]+"
|
||||
|
||||
- identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?"
|
||||
- identifier: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- constant.string:
|
||||
start: "'"
|
||||
end: "'"
|
||||
rules:
|
||||
|
||||
- comment:
|
||||
start: "#"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
@@ -0,0 +1,49 @@
|
||||
filetype: swift
|
||||
|
||||
detect:
|
||||
filename: "\\.swift$"
|
||||
|
||||
rules:
|
||||
# Operators
|
||||
- statement: "[.:;,+*|=!?\\%]" "<" ">" "/" "-" "&"
|
||||
|
||||
# Statements
|
||||
- statement: "(class|import|let|var|struct|enum|func|if|else|switch|case|default|for|in|internal|external|unowned|private|public|throws)\\ "
|
||||
- statement: "(prefix|postfix|operator|extension|lazy|get|set|self|willSet|didSet|override|super|convenience|weak|strong|mutating|return|guard)\\ "
|
||||
|
||||
# Keywords
|
||||
- statement: "(print)"
|
||||
- statement: "(init)"
|
||||
|
||||
# Numbers
|
||||
- constant.number: "([0-9]+)"
|
||||
|
||||
# Standard Types
|
||||
- type: "\\ ((U)?Int(8|16|32|64))"
|
||||
- constant: "(true|false|nil)"
|
||||
- type: "\\ (Double|String|Float|Boolean|Dictionary|Array|Int)"
|
||||
- type: "\\ (AnyObject)"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
rules:
|
||||
- constant.specialChar: "\\\\."
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "///"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
|
||||
- comment:
|
||||
start: "/\\*\\*"
|
||||
end: "\\*/"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME):?"
|
||||
Reference in New Issue
Block a user