diff --git a/README.md b/README.md index ba44d5e..5bdefbb 100644 --- a/README.md +++ b/README.md @@ -71,36 +71,36 @@ func main() { // Check if the group changed at the current position if group, ok := matches[lineN][colN]; ok { // Check the group name and set the color accordingly (the colors chosen are arbitrary) - if group == "statement" { - color.Set(color.FgGreen) - } else if group == "identifier" { - color.Set(color.FgBlue) - } else if group == "preproc" { - color.Set(color.FgHiRed) - } else if group == "special" { - color.Set(color.FgRed) - } else if group == "constant.string" { - color.Set(color.FgCyan) - } else if group == "constant" { - color.Set(color.FgCyan) - } else if group == "constant.specialChar" { - color.Set(color.FgHiMagenta) - } else if group == "type" { - color.Set(color.FgYellow) - } else if group == "constant.number" { - color.Set(color.FgCyan) - } else if group == "comment" { - color.Set(color.FgHiGreen) - } else { - color.Unset() - } + if group == highlight.Groups["statement"] { + color.Set(color.FgGreen) + } else if group == highlight.Groups["identifier"] { + color.Set(color.FgBlue) + } else if group == highlight.Groups["preproc"] { + color.Set(color.FgHiRed) + } else if group == highlight.Groups["special"] { + color.Set(color.FgRed) + } else if group == highlight.Groups["constant.string"] { + color.Set(color.FgCyan) + } else if group == highlight.Groups["constant"] { + color.Set(color.FgCyan) + } else if group == highlight.Groups["constant.specialChar"] { + color.Set(color.FgHiMagenta) + } else if group == highlight.Groups["type"] { + color.Set(color.FgYellow) + } else if group == highlight.Groups["constant.number"] { + color.Set(color.FgCyan) + } else if group == highlight.Groups["comment"] { + color.Set(color.FgHiGreen) + } else { + color.Unset() + } } // Print the character fmt.Print(string(c)) } // This is at a newline, but highlighting might have been turned off at the very end of the line so we should check that. if group, ok := matches[lineN][len(l)]; ok { - if group == "" { + if group == highlight.Groups["default"] || group == highlight.Groups[""] { color.Unset() } } diff --git a/examples/syncat.go b/examples/syncat.go index 7bc4960..6b41526 100644 --- a/examples/syncat.go +++ b/examples/syncat.go @@ -47,25 +47,25 @@ func main() { colN := 0 for _, c := range l { if group, ok := matches[lineN][colN]; ok { - if group == "statement" { + if group == highlight.Groups["statement"] { color.Set(color.FgGreen) - } else if group == "identifier" { + } else if group == highlight.Groups["identifier"] { color.Set(color.FgBlue) - } else if group == "preproc" { + } else if group == highlight.Groups["preproc"] { color.Set(color.FgHiRed) - } else if group == "special" { + } else if group == highlight.Groups["special"] { color.Set(color.FgRed) - } else if group == "constant.string" { + } else if group == highlight.Groups["constant.string"] { color.Set(color.FgCyan) - } else if group == "constant" { + } else if group == highlight.Groups["constant"] { color.Set(color.FgCyan) - } else if group == "constant.specialChar" { + } else if group == highlight.Groups["constant.specialChar"] { color.Set(color.FgHiMagenta) - } else if group == "type" { + } else if group == highlight.Groups["type"] { color.Set(color.FgYellow) - } else if group == "constant.number" { + } else if group == highlight.Groups["constant.number"] { color.Set(color.FgCyan) - } else if group == "comment" { + } else if group == highlight.Groups["comment"] { color.Set(color.FgHiGreen) } else { color.Unset() @@ -75,7 +75,7 @@ func main() { colN++ } if group, ok := matches[lineN][colN]; ok { - if group == "default" || group == "" { + if group == highlight.Groups["default"] || group == highlight.Groups[""] { color.Unset() } } diff --git a/ftdetect.go b/ftdetect.go index a0ac389..2d9e296 100644 --- a/ftdetect.go +++ b/ftdetect.go @@ -2,11 +2,11 @@ package highlight func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def { for _, d := range defs { - if d.ftdetect[0].Match([]byte(filename)) { + if d.ftdetect[0].MatchString(filename) { return d } if len(d.ftdetect) > 1 { - if d.ftdetect[1].Match(firstLine) { + if d.ftdetect[1].MatchString(string(firstLine)) { return d } } diff --git a/highlighter.go b/highlighter.go index 20c3466..14c5962 100644 --- a/highlighter.go +++ b/highlighter.go @@ -3,12 +3,14 @@ package highlight import ( "regexp" "strings" + + "github.com/dlclark/regexp2" ) func combineLineMatch(src, dst LineMatch) LineMatch { for k, v := range src { if g, ok := dst[k]; ok { - if g == "" { + if g == 0 { dst[k] = v } } else { @@ -18,29 +20,36 @@ func combineLineMatch(src, dst LineMatch) LineMatch { return dst } +// A State represents the region at the end of a line type State *Region +// LineStates is an interface for a buffer-like object which can also store the states and matches for every line type LineStates interface { - LineData() [][]byte + Line(n int) string + LinesNum() int State(lineN int) State SetState(lineN int, s State) SetMatch(lineN int, m LineMatch) } +// A Highlighter contains the information needed to highlight a string type Highlighter struct { lastRegion *Region def *Def } +// NewHighlighter returns a new highlighter from the given syntax definition func NewHighlighter(def *Def) *Highlighter { h := new(Highlighter) h.def = def return h } -type LineMatch map[int]string +// LineMatch represents the syntax highlighting matches for one line. Each index where the coloring is changed is marked with that +// color's group (represented as one byte) +type LineMatch map[int]uint8 -func FindIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool) []int { +func findIndex(regex *regexp2.Regexp, str []rune, canMatchStart, canMatchEnd bool) []int { regexStr := regex.String() if strings.Contains(regexStr, "^") { if !canMatchStart { @@ -52,10 +61,14 @@ func FindIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool return nil } } - return regex.FindIndex(str) + match, _ := regex.FindStringMatch(string(str)) + if match == nil { + return nil + } + return []int{match.Index, match.Index + match.Length} } -func FindAllIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd bool) [][]int { +func findAllIndex(regex *regexp.Regexp, str []rune, canMatchStart, canMatchEnd bool) [][]int { regexStr := regex.String() if strings.Contains(regexStr, "^") { if !canMatchStart { @@ -67,27 +80,40 @@ func FindAllIndex(regex *regexp.Regexp, str []byte, canMatchStart, canMatchEnd b return nil } } - return regex.FindAllIndex(str, -1) + return regex.FindAllIndex([]byte(string(str)), -1) } -func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, line []byte, region *Region) LineMatch { - highlights := make(LineMatch) +func (h *Highlighter) highlightRegion(highlights LineMatch, start int, canMatchEnd bool, lineNum int, line []rune, region *Region, statesOnly bool) LineMatch { + // highlights := make(LineMatch) - loc := FindIndex(region.end, line, start == 0, canMatchEnd) + if start == 0 { + if !statesOnly { + highlights[0] = region.group + } + } + + loc := findIndex(region.end, line, start == 0, canMatchEnd) if loc != nil { - if region.parent == nil { - highlights[start+loc[1]] = "" - return combineLineMatch(highlights, - combineLineMatch(h.highlightRegion(start, false, lineNum, line[:loc[0]], region), - h.highlightEmptyRegion(start+loc[1], canMatchEnd, lineNum, line[loc[1]:]))) + if !statesOnly { + highlights[start+loc[1]-1] = region.group } - highlights[start+loc[1]] = region.parent.group - return combineLineMatch(highlights, - combineLineMatch(h.highlightRegion(start, false, lineNum, line[:loc[0]], region), - h.highlightRegion(start+loc[1], canMatchEnd, lineNum, line[loc[1]:], region.parent))) + if region.parent == nil { + if !statesOnly { + highlights[start+loc[1]] = 0 + h.highlightRegion(highlights, start, false, lineNum, line[:loc[0]], region, statesOnly) + } + h.highlightEmptyRegion(highlights, start+loc[1], canMatchEnd, lineNum, line[loc[1]:], statesOnly) + return highlights + } + if !statesOnly { + highlights[start+loc[1]] = region.parent.group + h.highlightRegion(highlights, start, false, lineNum, line[:loc[0]], region, statesOnly) + } + h.highlightRegion(highlights, start+loc[1], canMatchEnd, lineNum, line[loc[1]:], region.parent, statesOnly) + return highlights } - if len(line) == 0 { + if len(line) == 0 || statesOnly { if canMatchEnd { h.lastRegion = region } @@ -98,7 +124,7 @@ func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, firstLoc := []int{len(line), 0} var firstRegion *Region for _, r := range region.rules.regions { - loc := FindIndex(r.start, line, start == 0, canMatchEnd) + loc := findIndex(r.start, line, start == 0, canMatchEnd) if loc != nil { if loc[0] < firstLoc[0] { firstLoc = loc @@ -108,17 +134,28 @@ func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, } if firstLoc[0] != len(line) { highlights[start+firstLoc[0]] = firstRegion.group - return combineLineMatch(highlights, - combineLineMatch(h.highlightRegion(start, false, lineNum, line[:firstLoc[0]], region), - h.highlightRegion(start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion))) + h.highlightRegion(highlights, start, false, lineNum, line[:firstLoc[0]], region, statesOnly) + h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly) + return highlights + } + + fullHighlights := make([]uint8, len([]rune(string(line)))) + for i := 0; i < len(fullHighlights); i++ { + fullHighlights[i] = region.group } for _, p := range region.rules.patterns { - matches := FindAllIndex(p.regex, line, start == 0, canMatchEnd) + matches := findAllIndex(p.regex, line, start == 0, canMatchEnd) for _, m := range matches { - highlights[start+m[0]] = p.group - if _, ok := highlights[start+m[1]]; !ok { - highlights[start+m[1]] = region.group + for i := m[0]; i < m[1]; i++ { + fullHighlights[i] = p.group + } + } + } + for i, h := range fullHighlights { + if i == 0 || h != fullHighlights[i-1] { + if _, ok := highlights[start+i]; !ok { + highlights[start+i] = h } } } @@ -130,8 +167,7 @@ func (h *Highlighter) highlightRegion(start int, canMatchEnd bool, lineNum int, return highlights } -func (h *Highlighter) highlightEmptyRegion(start int, canMatchEnd bool, lineNum int, line []byte) LineMatch { - highlights := make(LineMatch) +func (h *Highlighter) highlightEmptyRegion(highlights LineMatch, start int, canMatchEnd bool, lineNum int, line []rune, statesOnly bool) LineMatch { if len(line) == 0 { if canMatchEnd { h.lastRegion = nil @@ -142,7 +178,7 @@ func (h *Highlighter) highlightEmptyRegion(start int, canMatchEnd bool, lineNum firstLoc := []int{len(line), 0} var firstRegion *Region for _, r := range h.def.rules.regions { - loc := FindIndex(r.start, line, start == 0, canMatchEnd) + loc := findIndex(r.start, line, start == 0, canMatchEnd) if loc != nil { if loc[0] < firstLoc[0] { firstLoc = loc @@ -151,18 +187,35 @@ func (h *Highlighter) highlightEmptyRegion(start int, canMatchEnd bool, lineNum } } if firstLoc[0] != len(line) { - highlights[start+firstLoc[0]] = firstRegion.group - return combineLineMatch(highlights, - combineLineMatch(h.highlightEmptyRegion(start, false, lineNum, line[:firstLoc[0]]), - h.highlightRegion(start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion))) + if !statesOnly { + highlights[start+firstLoc[0]] = firstRegion.group + } + h.highlightEmptyRegion(highlights, start, false, lineNum, line[:firstLoc[0]], statesOnly) + h.highlightRegion(highlights, start+firstLoc[1], canMatchEnd, lineNum, line[firstLoc[1]:], firstRegion, statesOnly) + return highlights } + if statesOnly { + if canMatchEnd { + h.lastRegion = nil + } + + return highlights + } + + fullHighlights := make([]uint8, len(line)) for _, p := range h.def.rules.patterns { - matches := FindAllIndex(p.regex, line, start == 0, canMatchEnd) + matches := findAllIndex(p.regex, line, start == 0, canMatchEnd) for _, m := range matches { - highlights[start+m[0]] = p.group - if _, ok := highlights[start+m[1]]; !ok { - highlights[start+m[1]] = "" + for i := m[0]; i < m[1]; i++ { + fullHighlights[i] = p.group + } + } + } + for i, h := range fullHighlights { + if i == 0 || h != fullHighlights[i-1] { + if _, ok := highlights[start+i]; !ok { + highlights[start+i] = h } } } @@ -174,47 +227,103 @@ func (h *Highlighter) highlightEmptyRegion(start int, canMatchEnd bool, lineNum return highlights } +// HighlightString syntax highlights a string +// Use this function for simple syntax highlighting and use the other functions for +// more advanced syntax highlighting. They are optimized for quick rehighlighting of the same +// text with minor changes made func (h *Highlighter) HighlightString(input string) []LineMatch { lines := strings.Split(input, "\n") var lineMatches []LineMatch for i := 0; i < len(lines); i++ { - line := []byte(lines[i]) + line := []rune(lines[i]) + highlights := make(LineMatch) if i == 0 || h.lastRegion == nil { - lineMatches = append(lineMatches, h.highlightEmptyRegion(0, true, i, line)) + lineMatches = append(lineMatches, h.highlightEmptyRegion(highlights, 0, true, i, line, false)) } else { - lineMatches = append(lineMatches, h.highlightRegion(0, true, i, line, h.lastRegion)) + lineMatches = append(lineMatches, h.highlightRegion(highlights, 0, true, i, line, h.lastRegion, false)) } } return lineMatches } -func (h *Highlighter) Highlight(input LineStates, startline int) { - lines := input.LineData() +// HighlightStates correctly sets all states for the buffer +func (h *Highlighter) HighlightStates(input LineStates) { + for i := 0; i < input.LinesNum(); i++ { + line := []rune(input.Line(i)) + // highlights := make(LineMatch) - for i := startline; i < len(lines); i++ { - line := []byte(lines[i]) - - var match LineMatch if i == 0 || h.lastRegion == nil { - match = h.highlightEmptyRegion(0, true, i, line) + h.highlightEmptyRegion(nil, 0, true, i, line, true) } else { - match = h.highlightRegion(0, true, i, line, h.lastRegion) + h.highlightRegion(nil, 0, true, i, line, h.lastRegion, true) } curState := h.lastRegion - input.SetMatch(i, match) input.SetState(i, curState) } } -func (h *Highlighter) ReHighlightLine(input LineStates, lineN int) { - lines := input.LineData() +// HighlightMatches sets the matches for each line in between startline and endline +// It sets all other matches in the buffer to nil to conserve memory +// This assumes that all the states are set correctly +func (h *Highlighter) HighlightMatches(input LineStates, startline, endline int) { + for i := startline; i < endline; i++ { + if i >= input.LinesNum() { + break + } - line := []byte(lines[lineN]) + line := []rune(input.Line(i)) + highlights := make(LineMatch) + + var match LineMatch + if i == 0 || input.State(i-1) == nil { + match = h.highlightEmptyRegion(highlights, 0, true, i, line, false) + } else { + match = h.highlightRegion(highlights, 0, true, i, line, input.State(i-1), false) + } + + input.SetMatch(i, match) + } +} + +// ReHighlightStates will scan down from `startline` and set the appropriate end of line state +// for each line until it comes across the same state in two consecutive lines +func (h *Highlighter) ReHighlightStates(input LineStates, startline int) { + // lines := input.LineData() + + h.lastRegion = nil + if startline > 0 { + h.lastRegion = input.State(startline - 1) + } + for i := startline; i < input.LinesNum(); i++ { + line := []rune(input.Line(i)) + // highlights := make(LineMatch) + + // var match LineMatch + if i == 0 || h.lastRegion == nil { + h.highlightEmptyRegion(nil, 0, true, i, line, true) + } else { + h.highlightRegion(nil, 0, true, i, line, h.lastRegion, true) + } + curState := h.lastRegion + lastState := input.State(i) + + input.SetState(i, curState) + + if curState == lastState { + break + } + } +} + +// ReHighlightLine will rehighlight the state and match for a single line +func (h *Highlighter) ReHighlightLine(input LineStates, lineN int) { + line := []rune(input.Line(lineN)) + highlights := make(LineMatch) h.lastRegion = nil if lineN > 0 { @@ -223,40 +332,12 @@ func (h *Highlighter) ReHighlightLine(input LineStates, lineN int) { var match LineMatch if lineN == 0 || h.lastRegion == nil { - match = h.highlightEmptyRegion(0, true, lineN, line) + match = h.highlightEmptyRegion(highlights, 0, true, lineN, line, false) } else { - match = h.highlightRegion(0, true, lineN, line, h.lastRegion) + match = h.highlightRegion(highlights, 0, true, lineN, line, h.lastRegion, false) } curState := h.lastRegion input.SetMatch(lineN, match) input.SetState(lineN, curState) } - -func (h *Highlighter) ReHighlight(input LineStates, startline int) { - lines := input.LineData() - - h.lastRegion = nil - if startline > 0 { - h.lastRegion = input.State(startline - 1) - } - for i := startline; i < len(lines); i++ { - line := []byte(lines[i]) - - var match LineMatch - if i == 0 || h.lastRegion == nil { - match = h.highlightEmptyRegion(0, true, i, line) - } else { - match = h.highlightRegion(0, true, i, line, h.lastRegion) - } - curState := h.lastRegion - lastState := input.State(i) - - input.SetMatch(i, match) - input.SetState(i, curState) - - if curState == lastState { - break - } - } -} diff --git a/parser.go b/parser.go index 21a905f..bf57752 100644 --- a/parser.go +++ b/parser.go @@ -4,9 +4,23 @@ import ( "fmt" "regexp" + "github.com/dlclark/regexp2" + "gopkg.in/yaml.v2" ) +var Groups map[string]uint8 +var numGroups uint8 + +func GetGroup(n uint8) string { + for k, v := range Groups { + if v == n { + return k + } + } + return "" +} + // A Def is a full syntax definition for a language // It has a filetype, information about how to detect the filetype based // on filename or header (the first line of the file) @@ -21,7 +35,7 @@ type Def struct { // It has a group that the rule belongs to, as well as // the regular expression to match the pattern type Pattern struct { - group string + group uint8 regex *regexp.Regexp } @@ -39,13 +53,17 @@ type Rules struct { // region and also rules from the above region do not match inside this region // Note that a region may contain more regions type Region struct { - group string + group uint8 parent *Region - start *regexp.Regexp - end *regexp.Regexp + start *regexp2.Regexp + end *regexp2.Regexp rules *Rules } +func init() { + Groups = make(map[string]uint8) +} + // ParseDef parses an input syntax file into a highlight Def func ParseDef(input []byte) (s *Def, err error) { // This is just so if we have an error, we can exit cleanly and return the parse error to the user @@ -155,7 +173,13 @@ func parseRules(input []interface{}, curRegion *Region) (*Rules, error) { return nil, err } - rules.patterns = append(rules.patterns, &Pattern{group.(string), r}) + groupStr := group.(string) + if _, ok := Groups[groupStr]; !ok { + numGroups++ + Groups[groupStr] = numGroups + } + groupNum := Groups[groupStr] + rules.patterns = append(rules.patterns, &Pattern{groupNum, r}) } case map[interface{}]interface{}: // Region @@ -177,16 +201,21 @@ func parseRegion(group string, regionInfo map[interface{}]interface{}, prevRegio var err error region := new(Region) - region.group = group + if _, ok := Groups[group]; !ok { + numGroups++ + Groups[group] = numGroups + } + groupNum := Groups[group] + region.group = groupNum region.parent = prevRegion - region.start, err = regexp.Compile(regionInfo["start"].(string)) + region.start, err = regexp2.Compile(regionInfo["start"].(string), 0) if err != nil { return nil, err } - region.end, err = regexp.Compile(regionInfo["end"].(string)) + region.end, err = regexp2.Compile(regionInfo["end"].(string), 0) if err != nil { return nil, err diff --git a/syntax_files/README.md b/syntax_files/README.md index c77e145..f2ddef4 100644 --- a/syntax_files/README.md +++ b/syntax_files/README.md @@ -1,5 +1,11 @@ # Syntax Files -Here are highlight's syntax files. If you would like to make a new syntax file, you should first check it -with the `syntax_checker.go` program. Just place it in this directory and run the program (`go run syntax_checker.go`) -and it will let you know if there are issues with any of the files in the directory. \ No newline at end of file +Here are highlights's syntax files. + +Each yaml file specifies how to detect the filetype based on file extension or headers (first line of the file). +Then there are patterns and regions linked to highlight groups which tell micro how to highlight that filetype. + +Making your own syntax files is very simple. I recommend you check the file after you are finished with the +[`syntax_checker.go`](./syntax_checker.go) program (located in this directory). Just place your yaml syntax +file in the current directory and run `go run syntax_checker.go` and it will check every file. If there are no +errors it will print `No issues!`. diff --git a/syntax_files/apacheconf.yaml b/syntax_files/apacheconf.yaml new file mode 100644 index 0000000..7e852fd --- /dev/null +++ b/syntax_files/apacheconf.yaml @@ -0,0 +1,58 @@ +filetype: apacheconf + +detect: + filename: "httpd\\.conf|mime\\.types|vhosts\\.d\\\\*|\\.htaccess" + +rules: + - identifier: "(AcceptMutex|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding)" + - identifier: "(AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch)" + - identifier: "(Allow|AllowCONNECT|AllowEncodedSlashes|AllowOverride|Anonymous|Anonymous_Authoritative|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID)" + - identifier: "(Anonymous_VerifyEmail|AssignUserID|AuthAuthoritative|AuthDBMAuthoritative|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm)" + - identifier: "(AuthDigestDomain|AuthDigestFile|AuthDigestGroupFile|AuthDigestNcCheck|AuthDigestNonceFormat|AuthDigestNonceLifetime|AuthDigestQop|AuthDigestShmemSize)" + - identifier: "(AuthGroupFile|AuthLDAPAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases)" + - identifier: "(AuthLDAPEnabled|AuthLDAPFrontPageHack|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPRemoteUserIsDN|AuthLDAPUrl|AuthName|AuthType|AuthUserFile)" + - identifier: "(BrowserMatch|BrowserMatchNoCase|BS2000Account|BufferedLogs|CacheDefaultExpire|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheExpiryCheck)" + - identifier: "(CacheFile|CacheForceCompletion|CacheGcClean|CacheGcDaily|CacheGcInterval|CacheGcMemUsage|CacheGcUnused|CacheIgnoreCacheControl|CacheIgnoreHeaders)" + - identifier: "(CacheIgnoreNoLastMod|CacheLastModifiedFactor|CacheMaxExpire|CacheMaxFileSize|CacheMinFileSize|CacheNegotiatedDocs|CacheRoot|CacheSize|CacheTimeMargin)" + - identifier: "(CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckSpelling|ChildPerUserID|ContentDigest|CookieDomain|CookieExpires|CookieLog|CookieName)" + - identifier: "(CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavLockDB|DavMinTimeout|DefaultIcon|DefaultLanguage|DefaultType)" + - identifier: "(DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateMemLevel|DeflateWindowSize|Deny|Directory|DirectoryIndex|DirectoryMatch|DirectorySlash)" + - identifier: "(DocumentRoot|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|ErrorDocument|ErrorLog|Example|ExpiresActive|ExpiresByType)" + - identifier: "(ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FileETag|Files|FilesMatch|ForceLanguagePriority|ForceType|ForensicLog|Group|Header)" + - identifier: "(HeaderName|HostnameLookups|IdentityCheck|IfDefine|IfModule|IfVersion|ImapBase|ImapDefault|ImapMenu|Include|IndexIgnore|IndexOptions|IndexOrderDefault)" + - identifier: "(ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout)" + - identifier: "(LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionTimeout|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPSharedCacheFile|LDAPSharedCacheSize)" + - identifier: "(LDAPTrustedCA|LDAPTrustedCAType|Limit|LimitExcept|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine)" + - identifier: "(LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|Location|LocationMatch|LockFile|LogFormat|LogLevel|MaxClients|MaxKeepAliveRequests)" + - identifier: "(MaxMemFree|MaxRequestsPerChild|MaxRequestsPerThread|MaxSpareServers|MaxSpareThreads|MaxThreads|MaxThreadsPerChild|MCacheMaxObjectCount|MCacheMaxObjectSize)" + - identifier: "(MCacheMaxStreamingBuffer|MCacheMinObjectSize|MCacheRemovalAlgorithm|MCacheSize|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads)" + - identifier: "(MMapFile|ModMimeUsePathInfo|MultiviewsMatch|NameVirtualHost|NoProxy|NumServers|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|PassEnv|PidFile)" + - identifier: "(ProtocolEcho|Proxy|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyIOBufferSize|ProxyMatch|ProxyMaxForwards|ProxyPass|ProxyPassReverse)" + - identifier: "(ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxyTimeout|ProxyVia|ReadmeName|Redirect|RedirectMatch)" + - identifier: "(RedirectPermanent|RedirectTemp|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader)" + - identifier: "(Require|RewriteBase|RewriteCond|RewriteEngine|RewriteLock|RewriteLog|RewriteLogLevel|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC)" + - identifier: "(Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen)" + - identifier: "(SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|SetEnv|SetEnvIf|SetEnvIfNoCase|SetHandler)" + - identifier: "(SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath)" + - identifier: "(SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLEngine|SSLMutex|SSLOptions)" + - identifier: "(SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCipherSuite)" + - identifier: "(SSLProxyEngine|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRequire)" + - identifier: "(SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLUserName|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|SuexecUserGroup|ThreadLimit)" + - identifier: "(ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnsetEnv|UseCanonicalName|User|UserDir|VirtualDocumentRoot)" + - identifier: "(VirtualDocumentRootIP|VirtualHost|VirtualScriptAlias|VirtualScriptAliasIP|Win32DisableAcceptEx|XBitHack)" + - symbol.tag: "<[^>]+>" + - identifier: ")" + + - constant.string: + start: "\"" + end: "(?>" + # main header + - preproc: "^====+$" + # h1 + - statement: "^==[[:space:]].*$" + - statement: "^----+$" + # h2 + - symbol: "^===[[:space:]].*$" + - symbol: "^~~~~+$" + # h4 + - type: "^====[[:space:]].*$" + - type: "^\\^\\^\\^\\^+$" + # h5 + - constant: "^=====[[:space:]].*$" + - constant: "^\\+\\+\\+\\++$" + + # attributes + - type.keyword: ":.*:" + - identifier.macro: "\\{[a-z0-9]*\\}" + - identifier: "\\\\\\{[a-z0-9]*\\}" + - identifier: "\\+\\+\\+\\{[a-z0-9]*\\}\\+\\+\\+" + + # Paragraph Title + - statement: "^\\..*$" + + # source + - identifier: "^\\[(source,.+|NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]" + + # Other markup + - constant.string: ".*[[:space:]]\\+$" + - constant.string: "_[^_]+_" + - constant.string: "\\*[^\\*]+\\*" + - constant.string: "\\+[^\\+]+\\+" + - constant.string: "`[^`]+`" + - constant.string: "\\^[^\\^]+\\^" + - constant.string: "~[^~]+~" + - constant.string: "'[^']+'" + + - constant: "`{1,2}[^']+'{1,2}" + + # bullets + - symbol: "^[[:space:]]*[\\*\\.-]{1,5}[[:space:]]" + + # anchors + - "bold default": "\\[\\[.*\\]\\]" + - "bold default": "<<.*>>" diff --git a/syntax_files/asm.yaml b/syntax_files/asm.yaml index 2752b6f..dd53259 100644 --- a/syntax_files/asm.yaml +++ b/syntax_files/asm.yaml @@ -90,13 +90,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(??;:]|\\\\|\\[|\\]" + - statement: "\\b(for|if|while|do|else|in|delete|exit)\\b" + - special: "\\b(break|continue|return)\\b" + - statement: "\\b(close|getline|next|nextfile|print|printf|system|fflush)\\b" + - statement: "\\b(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\\b" + - statement: "\\b(asort|asorti|gensub|gsub|index|length|match)\\b" + - statement: "\\b(split|sprintf|strtonum|sub|substr|tolower|toupper)\\b" + - statement: "\\b(mktime|strftime|systime)\\b" + - statement: "\\b(and|compl|lshift|or|rshift|xor)\\b" + - statement: "\\b(bindtextdomain|dcgettext|dcngettext)\\b" + - special: "/.*[^\\\\]/" + + - constant.string: + start: "\"" + end: "(?|/|-|&" + - 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:]]+$" diff --git a/syntax_files/c.yaml b/syntax_files/c.yaml index a397448..0511555 100644 --- a/syntax_files/c.yaml +++ b/syntax_files/c.yaml @@ -7,6 +7,7 @@ rules: - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" - 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" + - type.extended: "\\b(bool)\\b" - statement: "\\b(typename|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" @@ -19,19 +20,20 @@ rules: - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)" - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" # Operator Color - - statement: "([.:;,+*|=!\\%]|<|>|/|-|&)" + - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" + - symbol.brackets: "[(){}]|\\[|\\]" - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)" - constant.number: "NULL" - constant.string: start: "\"" - end: "\"" + end: "(?+\\-*/'?]" + + # Types/casting + - type: "\\b(byte|short|(big)?int(eger)?|long|float|num|bigdec|rationalize)\\b" + + # String highlighting + - constant.string: + start: "\"" + end: "(?]|\\b(and|or|is|isnt|not)\\b" - - identifier: "([A-Za-z_][A-Za-z0-9_]*:[[:space:]]*(->|\\()|->)" - - statement: "[()]" + - symbol.operator: "[!&|=/*+-<>]|\\b(and|or|is|isnt|not)\\b" + - identifier.class: "([A-Za-z_][A-Za-z0-9_]*:[[:space:]]*(->|\\()|->)" + - symbol.brackets: "[()]" - statement: "\\b(for|of|continue|break|isnt|null|unless|this|else|if|return)\\b" - statement: "\\b(try|catch|finally|throw|new|delete|typeof|in|instanceof)\\b" - statement: "\\b(debugger|switch|while|do|class|extends|super)\\b" - statement: "\\b(undefined|then|unless|until|loop|of|by|when)\\b" - - constant: "\\b(true|false|yes|no|on|off)\\b" - - preproc: "@[A-Za-z0-9_]*" + - constant.bool: "\\b(true|false|yes|no|on|off)\\b" + - identifier: "@[A-Za-z0-9_]*" - constant.string: start: "\"" - end: "\"" + end: "(?|!|=|&|\\|)" + - constant.macro: "^TEXT$" diff --git a/syntax_files/cpp.yaml b/syntax_files/cpp.yaml index 610cd4a..5c06545 100644 --- a/syntax_files/cpp.yaml +++ b/syntax_files/cpp.yaml @@ -15,25 +15,26 @@ rules: - 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}')" - ## - ## GCC builtins + # GCC builtins - statement: "(__attribute__[[:space:]]*\\(\\([^)]*\\)\\)|__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__)" - #Operator Color - - statement: "([.:;,+*|=!\\%]|<|>|/|-|&)" + # Operator Color + - symbol.operator: "([.:;,+*|=!\\%]|<|>|/|-|&)" + # Parenthetical Color + - symbol.brackets: "[(){}]|\\[|\\]" - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)" - - constant.number: "(\\b(true|false)\\b|NULL)" + - constant.bool: "(\\b(true|false)\\b|NULL)" - constant.string: start: "\"" - end: "\"" + end: "(??:!~%&|]" + - constant.number: "\\b([0-9._]+|0x[A-Fa-f0-9_]+|0b[0-1_]+)[FL]?\\b" + + - constant.string: + start: "\"" + end: "(?|/|-|&" + + # Parenthetical Color + - symbol.brackets: "[(){}]|\\[|\\]" + + - constant.string: + start: "\"\"\"" + end: "\"\"\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'''" + end: "'''" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "\"" + end: "(?|--" + + - constant.string: + start: "\"" + end: "(?" + - symbol.tag: "(?i)<[/]?(a(bbr|cronym|ddress|pplet|rea|rticle|side|udio)?|b(ase(font)?|d(i|o)|ig|lockquote|r)?|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata(list)?|d|el|etails|fn|ialog|ir|l|t)|em(bed)?|fieldset|fig(caption|ure)|font|form|(i)?frame|frameset|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li(nk)?|ma(in|p|rk)|menu(item)?|met(a|er)|nav|no(frames|script)|o(l|pt(group|ion)|utput)|p(aram|icture|re|rogress)?|q|r(p|t|uby)|s(trike)?|samp|se(ction|lect)|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u(l)?|var|video|wbr)( .*|>)*?>" + - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*|>)*?>" + - preproc: "(?i)<[/]?(script|style)( .*|>)*?>" + - special: "&[^;[[:space:]]]*;" + - symbol: "[:=]" + - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)=" + - constant.string: "\"[^\"]*\"" + - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" + - comment: "" + - preproc: "" + - default: + start: "<%" + end: "%>" + rules: [] + + - preproc: "<%|%>" + - red: "&[^;[[:space:]]]*;" + - statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\\b" + - identifier.var: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*" + - magenta: "(?i)([ ]|^):[0-9A-Z_]+\\b" + - identifier.macro: "\\b(__FILE__|__LINE__)\\b" + - brightmagenta: "!/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*" + - brightblue: "`[^`]*`|%x\\{[^}]*\\}" + - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" + - brightgreen: "#\\{[^}]*\\}" + - green: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" + - comment: "#[^{].*$|#$" + - comment.bright: "##[^{].*$|##$" + - identifier.macro: + start: "<<-?'?EOT'?" + end: "^EOT" + rules: [] + + - todo: "(XXX|TODO|FIXME|\\?\\?\\?)" diff --git a/syntax_files/fish.yaml b/syntax_files/fish.yaml index 690f795..416a145 100644 --- a/syntax_files/fish.yaml +++ b/syntax_files/fish.yaml @@ -29,13 +29,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(?|/|-|&" + + # parentheses + - statement: "[(){}]|\\[|\\]" + + # numbers + - constant: "\\b[0-9]+\\b" + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'" + + - comment: + start: "\"\"\"" + end: "\"\"\"" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "'''" + end: "'''" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - constant.string: + start: "\"" + end: "(?|!|=|&|\\|)" - statement: "-(e|d|f|r|g|u|w|x|L)\\b" - - statement: "-(eq|ne|gt|lt|ge|le|s|n|z)\\b" - # Highlight variables ... official portage ones in red, all others in bright red + - statement: "-(eq|ne|gt|lt|ge|le|s|n|z)\\b" + # Highlight variables ... official portage ones in red, all others in bright red - preproc: "\\$\\{?[a-zA-Z_0-9]+\\}?" - - special: "\\b(ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)\\b" + - special: "\\b(ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)\\b" - special: "\\b(S|D|T|PV|PF|P|PN|A)\\b|\\bC(XX)?FLAGS\\b|\\bLDFLAGS\\b|\\bC(HOST|TARGET|BUILD)\\b" - # Highlight portage commands + # Highlight portage commands - identifier: "\\buse(_(with|enable))?\\b [!a-zA-Z0-9_+ -]*|inherit.*" - statement: "\\be(begin|end|conf|install|make|warn|infon?|error|log|patch|new(group|user))\\b" - statement: "\\bdie\\b|\\buse(_(with|enable))?\\b|\\binherit\\b|\\bhas\\b|\\b(has|best)_version\\b|\\bunpack\\b" - statement: "\\b(do|new)(ins|s?bin|doc|lib(\\.so|\\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)\\b" - - statement: "\\bdo(python|sed|dir|hard|sym|html|jar|mo)\\b|\\bkeepdir|\b" + - statement: "\\bdo(python|sed|dir|hard|sym|html|jar|mo)\\b|\\bkeepdir\\b" - statement: "prepall(docs|info|man|strip)|prep(info|lib|lib\\.(so|a)|man|strip)" - statement: "\\b(doc|ins|exe)into\\b|\\bf(owners|perms)\\b|\\b(exe|ins|dir)opts\\b" - # Highlight common commands used in ebuilds + # Highlight common commands used in ebuilds - type: "\\bmake\\b|\\b(cat|cd|chmod|chown|cp|echo|env|export|grep|let|ln|mkdir|mv|rm|sed|set|tar|touch|unset)\\b" - # Highlight comments (doesnt work that well) + + - constant.string: + start: "\"" + end: "(?|>=|=>)" + # Comments: + - comment: + start: "#" + end: "$" + rules: [] diff --git a/syntax_files/git-commit.yaml b/syntax_files/git-commit.yaml index 40b46ac..483f4fd 100644 --- a/syntax_files/git-commit.yaml +++ b/syntax_files/git-commit.yaml @@ -26,5 +26,3 @@ rules: - keyword: "^#[[:space:]]On branch" # Recolor hash symbols - special: "#" - # Trailing spaces (+LINT is not ok, git uses tabs) - - error: "[[:space:]]+$" diff --git a/syntax_files/git-rebase-todo.yaml b/syntax_files/git-rebase-todo.yaml index 8866c97..30ede72 100644 --- a/syntax_files/git-rebase-todo.yaml +++ b/syntax_files/git-rebase-todo.yaml @@ -4,26 +4,24 @@ detect: filename: "git-rebase-todo" rules: - # Default - - ignore: ".*" # Comments - comment: start: "#" end: "$" rules: [] # Rebase commands - - keyword: "^(e|edit) [0-9a-f]{7,40}" - - keyword: "^# (e, edit)" - - keyword: "^(f|fixup) [0-9a-f]{7,40}" - - keyword: "^# (f, fixup)" - - keyword: "^(p|pick) [0-9a-f]{7,40}" - - keyword: "^# (p, pick)" - - keyword: "^(r|reword) [0-9a-f]{7,40}" - - keyword: "^# (r, reword)" - - keyword: "^(s|squash) [0-9a-f]{7,40}" - - keyword: "^# (s, squash)" - - keyword: "^(x|exec) [^ ]+ [0-9a-f]{7,40}" - - keyword: "^# (x, exec)" + - statement: "^(e|edit) [0-9a-f]{7,40}" + - statement: "^# (e, edit)" + - statement: "^(f|fixup) [0-9a-f]{7,40}" + - statement: "^# (f, fixup)" + - statement: "^(p|pick) [0-9a-f]{7,40}" + - statement: "^# (p, pick)" + - statement: "^(r|reword) [0-9a-f]{7,40}" + - statement: "^# (r, reword)" + - statement: "^(s|squash) [0-9a-f]{7,40}" + - statement: "^# (s, squash)" + - statement: "^(x|exec) [^ ]+ [0-9a-f]{7,40}" + - statement: "^# (x, exec)" # Recolor hash symbols - special: "#" # Commit IDs diff --git a/syntax_files/glsl.yaml b/syntax_files/glsl.yaml index faf30d5..73369c8 100644 --- a/syntax_files/glsl.yaml +++ b/syntax_files/glsl.yaml @@ -5,13 +5,13 @@ detect: rules: - identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[()]" - - type: "\\<(void|bool|bvec2|bvec3|bvec4|int|ivec2|ivec3|ivec4|float|vec2|vec3|vec4|mat2|mat3|mat4|struct|sampler1D|sampler2D|sampler3D|samplerCUBE|sampler1DShadow|sampler2DShadow)\\>" - - statement: "\\" - - statement: "\\<(const|attribute|varying|uniform|in|out|inout|if|else|return|discard|while|for|do)\\>" - - statement: "\\<(break|continue)\\>" - - constant: "\\<(true|false)\\>" - - statement: "[-+/*=<>?:!~%&|^]" - - constant.number: "\\<([0-9]+|0x[0-9a-fA-F]*)\\>" + - type: "\\b(void|bool|bvec2|bvec3|bvec4|int|ivec2|ivec3|ivec4|float|vec2|vec3|vec4|mat2|mat3|mat4|struct|sampler1D|sampler2D|sampler3D|samplerCUBE|sampler1DShadow|sampler2DShadow)\\b" + - identifier: "\\bgl_(DepthRangeParameters|PointParameters|MaterialParameters|LightSourceParameters|LightModelParameters|LightModelProducts|LightProducts|FogParameters)\\b" + - statement: "\\b(const|attribute|varying|uniform|in|out|inout|if|else|return|discard|while|for|do)\\b" + - statement: "\\b(break|continue)\\b" + - constant.bool: "\\b(true|false)\\b" + - symbol.operator: "[-+/*=<>?:!~%&|^]" + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b" - comment: start: "//" diff --git a/syntax_files/go.yaml b/syntax_files/go.yaml index 44bd570..ede5555 100644 --- a/syntax_files/go.yaml +++ b/syntax_files/go.yaml @@ -4,20 +4,50 @@ detect: filename: "\\.go$" rules: - - statement: "\\b(break|case|continue|default|else|for|go|goto|if|range|return|switch)\\b" - - statement: "\\b(package|import|const|var|type|struct|func|go|defer|iota)\\b" - - statement: "[-+/*=<>!~%&|^]|:=" - - identifier: "[a-zA-Z0-9]*\\(" + # Conditionals and control flow + - special: "\\b(break|case|continue|default|go|goto|range|return)\\b" + - statement: "\\b(else|for|if|switch)\\b" + - preproc: "\\b(package|import|const|var|type|struct|func|go|defer|iota)\\b" + - symbol.operator: "[-+/*=<>!~%&|^]|:=" + + # Types + - special: "[a-zA-Z0-9]*\\(" + - symbol: "(,|\\.)" - type: "\\b(u?int(8|16|32|64)?|float(32|64)|complex(64|128))\\b" - type: "\\b(uintptr|byte|rune|string|interface|bool|map|chan|error)\\b" - - constant: "\\b(true|false|nil)\\b" - - statement: "(\\{|\\})" - - statement: "(\\(|\\))" - - statement: "(\\[|\\])" - - statement: "!" - - statement: "," - - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b" - - constant.specialChar: "([0-7]{3|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" + ##I'm... not sure, but aren't structs a type? + - type.keyword: "\\b(struct)\\b" + - constant.bool: "\\b(true|false|nil)\\b" + + # Brackets + - symbol.brackets: "(\\{|\\})" + - symbol.brackets: "(\\(|\\))" + - symbol.brackets: "(\\[|\\])" + + # Numbers and strings + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'" + + - constant.string: + start: "\"" + end: "(?!~%&|^]|:=" + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b|'.'" + + - constant.string: + start: "\"" + end: "(?|=>" + - constant: "([ ]|^)%[0-9A-Za-z_]+>" + - special: ":[0-9A-Za-z_]+>" + - type: "\\.[A-Za-z_]+>" + - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" + - constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" + - identifier: "#\\{[^}]*\\}" + - identifier.var: "(@|@@)[0-9A-Z_a-z]+" + - comment: "#[^{].*$|#$" diff --git a/syntax_files/haskell.yaml b/syntax_files/haskell.yaml new file mode 100644 index 0000000..a71646a --- /dev/null +++ b/syntax_files/haskell.yaml @@ -0,0 +1,49 @@ +filetype: haskell + +detect: + filename: "\\.hs$" + +rules: + # Keywords + - statement: "[ ](as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|mdo|module|newtype|qualified|type|where)[ ]" + - statement: "(^data|^foreign|^import|^infix|^infixl|^infixr|^instance|^module|^newtype|^type)[ ]" + - statement: "[ ](as$|case$|of$|class$|data$|default$|deriving$|do$|forall$|foreign$|hiding$|if$|then$|else$|import$|infix$|infixl$|infixr$|instance$|let$|in$|mdo$|module$|newtype$|qualified$|type$|where$)" + + # Various symbols + - symbol: "(\\||@|!|:|_|~|=|\\\\|;|\\(\\)|,|\\[|\\]|\\{|\\})" + + # Operators + - symbol.operator: "(==|/=|&&|\\|\\||<|>|<=|>=)" + + # Various symbols + - special: "(->|<-)" + - symbol: "\\.|\\$" + + # Data constructors + - constant.bool: "\\b(True|False)\\b" + - constant: "(Nothing|Just|Left|Right|LT|EQ|GT)" + + # Data classes + - identifier.class: "[ ](Read|Show|Enum|Eq|Ord|Data|Bounded|Typeable|Num|Real|Fractional|Integral|RealFrac|Floating|RealFloat|Monad|MonadPlus|Functor)" + + # Strings + - constant.string: + start: "\"" + end: "(?" - special: "&[^;[[:space:]]]*;" - statement: "(alt|bgcolor|height|href|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)=" - - constant: "\"[^\"]*\"|qq\\|.*\\|" - \ No newline at end of file + + - constant.string: + start: "\"" + end: "(?" + end: "" + rules: + - include: "javascript" + + - default: + start: "" + end: "" + rules: + - include: "css" + diff --git a/syntax_files/html4.yaml b/syntax_files/html4.yaml new file mode 100644 index 0000000..cd66276 --- /dev/null +++ b/syntax_files/html4.yaml @@ -0,0 +1,25 @@ +filetype: html4 + +detect: + filename: "\\.htm[l]?$" + header: "" + +rules: + - error: "<[^!].*?>" + - symbol.tag: "(?i)<[/]?(a(bbr|cronym|ddress|pplet|rea|rticle|side|udio)?|b(ase(font)?|d(i|o)|ig|lockquote|r)?|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata(list)?|d|el|etails|fn|ialog|ir|l|t)|em(bed)?|fieldset|fig(caption|ure)|font|form|(i)?frame|frameset|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li(nk)?|ma(in|p|rk)|menu(item)?|met(a|er)|nav|no(frames|script)|o(l|pt(group|ion)|utput)|p(aram|icture|re|rogress)?|q|r(p|t|uby)|s(trike)?|samp|se(ction|lect)|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u(l)?|var|video|wbr)( .*|>)*?>" + - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*)*?>" + - preproc: "(?i)<[/]?(script|style)( .*)*?>" + - special: "&[^;[[:space:]]]*;" + - symbol: "[:=]" + - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|style|target|type|value|width)=" + - constant.string: "\"[^\"]*\"" + - constant.number: "(?i)#[0-9A-F]{6,6}" + - default: + start: ">" + end: "<" + rules: [] + + - symbol.tag: "<|>" + - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" + - comment: "" + - preproc: "" diff --git a/syntax_files/html5.yaml b/syntax_files/html5.yaml new file mode 100644 index 0000000..8232327 --- /dev/null +++ b/syntax_files/html5.yaml @@ -0,0 +1,25 @@ +filetype: html5 + +detect: + filename: "\\.htm[l]?$" + header: "" + +rules: + - error: "<[^!].*?>" + - symbol.tag: "(?i)<[/]?(a|a(bbr|ddress|rea|rticle|side|udio)|b|b(ase|d(i|o)|lockquote|r|utton)|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata|atalist|d|el|etails|fn|ialog|l|t)|em|embed|fieldset|fig(caption|ure)|form|iframe|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li|link|ma(in|p|rk)|menu|menuitem|met(a|er)|nav|noscript|o(bject|l|pt(group|ion)|utput)|p|param|picture|pre|progress|q|r(p|t|uby)|s|samp|se(ction|lect)|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u|ul|var|video|wbr)( .*)*?>" + - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*)*?>" + - preproc: "(?i)<[/]?(script|style)( .*)*?>" + - special: "&[^;[[:space:]]]*;" + - symbol: "[:=]" + - identifier: "(alt|bgcolor|height|href|id|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|style|target|type|value|width)=" + - constant.string: "\"[^\"]*\"" + - constant.number: "(?i)#[0-9A-F]{6,6}" + - default: + start: ">" + end: "<" + rules: [] + + - symbol.tag: "<|>" + - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" + - comment: "" + - preproc: "" diff --git a/syntax_files/ini.yaml b/syntax_files/ini.yaml new file mode 100644 index 0000000..a6ab79a --- /dev/null +++ b/syntax_files/ini.yaml @@ -0,0 +1,14 @@ +filetype: ini + +detect: + filename: "\\.(ini|desktop|lfl|override)$|(mimeapps\\.list|pinforc|setup\\.cfg)$|weechat/.+\\.conf$" + header: "^\\[[A-Za-z]+\\]$" + +rules: + - constant.bool.true: "\\btrue\\b" + - constant.bool.false: "\\bfalse\\b" + - identifier: "^[[:space:]]*[^=]*=" + - special: "^[[:space:]]*\\[.*\\]$" + - statement: "[=;]" + - comment: "(^|[[:space:]])#([^{].*)?$" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" diff --git a/syntax_files/inputrc.yaml b/syntax_files/inputrc.yaml new file mode 100644 index 0000000..9df431e --- /dev/null +++ b/syntax_files/inputrc.yaml @@ -0,0 +1,14 @@ +filetype: inputrc + +detect: + filename: "inputrc$" + +rules: + - constant.bool.false: "\\b(off|none)\\b" + - constant.bool.true: "\\bon\\b" + - preproc: "\\bset|\\$include\\b" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - constant.specialChar: "\\\\.?" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/java.yaml b/syntax_files/java.yaml index 23798d9..10719aa 100644 --- a/syntax_files/java.yaml +++ b/syntax_files/java.yaml @@ -12,13 +12,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(?)" + - statement: "\\$(releasever|basearch)\\>" + - brightblack: "^@[A-Za-z][A-Za-z-]*" + - brightred: "^-@[a-zA-Z0-9*-]+" + - red: "^-[a-zA-Z0-9*-]+" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/ledger.yaml b/syntax_files/ledger.yaml new file mode 100644 index 0000000..cb05c8a --- /dev/null +++ b/syntax_files/ledger.yaml @@ -0,0 +1,14 @@ +filetype: ledger + +detect: + filename: "(^|\\.|/)ledger|ldgr|beancount|bnct$" + +rules: + - special: "^([0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}|[=~]) .*" + - constant: "^[0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}" + - statement: "^~ .*" + - identifier.var: "^= .*" + - identifier: "^[[:space:]]+(![[:space:]]+)?\\(?[A-Za-z ]+(:[A-Za-z ]+)*\\)?" + - identifier: "^[[:space:]]+(![[:space:]]+)?\\(?[A-Za-z_\\-]+(:[A-Za-z_\\-]+)*\\)?" + - symbol: "[*!]" + - comment: "^[[:space:]]*;.*" diff --git a/syntax_files/lfe.yaml b/syntax_files/lfe.yaml new file mode 100644 index 0000000..c51ffbd --- /dev/null +++ b/syntax_files/lfe.yaml @@ -0,0 +1,17 @@ +filetype: lfe + +detect: + filename: "lfe$|\\.lfe$" + +rules: + - symbol.brackets: "\\(|\\)" + - type: "defun|define-syntax|define|defmacro|defmodule|export" + - constant: "\\ [A-Za-z][A-Za-z0-9_-]+\\ " + - symbol.operator: "\\(([\\-+*/<>]|<=|>=)|'" + - constant.number: "\\b[0-9]+\\b" + - constant.string: "\\\"(\\\\.|[^\"])*\\\"" + - special: "['|`][A-Za-z][A-Za-z0-9_\\-]+" + - constant.specialChar: "\\\\.?" + - comment: "(^|[[:space:]]);.*" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/lilypond.yaml b/syntax_files/lilypond.yaml index eda0b9a..b336cfd 100644 --- a/syntax_files/lilypond.yaml +++ b/syntax_files/lilypond.yaml @@ -11,7 +11,7 @@ rules: - special: "[(){}<>]|\\[|\\]" - constant.string: start: "\"" - end: "\"" + end: "(?]|<=|>=)|'" + - constant.number: "\\b[0-9]+b>" + - special: "\\bnil\\b" + - preproc: "\\b[tT]b>" + - constant.string: "\\\"(\\\\.|[^\"])*\\\"" + - constant.specialChar: "'[A-Za-z][A-Za-z0-9_-]+" + - constant.specialChar: "\\\\.?" + - comment: "(^|[[:space:]]);.*" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/lua.yaml b/syntax_files/lua.yaml index 0b485d5..b02233c 100644 --- a/syntax_files/lua.yaml +++ b/syntax_files/lua.yaml @@ -26,13 +26,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(?|^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\\b" + - preproc: "(?i)^[[:space:]]*(set|unset|include|syntax|header)\\b" + - constant.bool.true: "(?i)(set)\\b" + - constant.bool.false: "(?i)(unset)\\b" + - identifier: "(?i)^[[:space:]]*(i)?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\\b" + - special: "(?i)^[[:space:]]*(i)?color\\b|\\b(start|end)=" + - constant.string: "\"(\\\\.|[^\"])*\"" + - comment: "^[[:space:]]*#.*$" + - comment.bright: "^[[:space:]]*##.*$" diff --git a/syntax_files/nginx.yaml b/syntax_files/nginx.yaml new file mode 100644 index 0000000..c2223b5 --- /dev/null +++ b/syntax_files/nginx.yaml @@ -0,0 +1,22 @@ +filetype: nginx + +detect: + filename: "nginx.*\\.conf$|\\.nginx$" + header: "^(server|upstream)[a-z ]*\\{$" + +rules: + - preproc: "\\b(events|server|http|location|upstream)[[:space:]]*\\{" + - statement: "(^|[[:space:]{;])(access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth_basic|auth_basic_user_file|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|default_type|deny|directio|directio_alignment|disable_symlinks|empty_gif|env|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|log_format|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|port_in_redirect|postpone_output|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_header|proxy_read_timeout|proxy_redirect|proxy_send_timeout|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|working_directory|xml_entities|xslt_stylesheet|xslt_types)([[:space:]]|$)" + - constant.bool.true: "\\b(on)\\b" + - constant.bool.false: "\\b(off)\\b" + - identifier: "\\$[A-Za-z][A-Za-z0-9_]*" + - symbol: "[*]" + - constant-string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - constant.string: + start: "'$" + end: "';$" + rules: [] + + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/nim.yaml b/syntax_files/nim.yaml new file mode 100644 index 0000000..e766cad --- /dev/null +++ b/syntax_files/nim.yaml @@ -0,0 +1,27 @@ +filetype: nim + +detect: + filename: "\\.nim$" + +rules: + - preproc: "[\\{\\|]\\b(atom|lit|sym|ident|call|lvalue|sideeffect|nosideeffect|param|genericparam|module|type|let|var|const|result|proc|method|iterator|converter|macro|template|field|enumfield|forvar|label|nk[a-zA-Z]+|alias|noalias)\\b[\\}\\|]" + - statement: "\\b(addr|and|as|asm|atomic|bind|block|break|case|cast|concept|const|continue|converter|defer|discard|distinct|div|do|elif|else|end|enum|except|export|finally|for|from|func|generic|if|import|in|include|interface|is|isnot|iterator|let|macro|method|mixin|mod|nil|not|notin|object|of|or|out|proc|ptr|raise|ref|return|shl|shr|static|template|try|tuple|type|using|var|when|while|with|without|xor|yield)\\b" + - statement: "\\b(deprecated|noSideEffect|constructor|destructor|override|procvar|compileTime|noReturn|acyclic|final|shallow|pure|asmNoStackFrame|error|fatal|warning|hint|line|linearScanEnd|computedGoto|unroll|immediate|checks|boundsChecks|overflowChecks|nilChecks|assertations|warnings|hints|optimization|patterns|callconv|push|pop|global|pragma|experimental|bitsize|volatile|noDecl|header|incompleteStruct|compile|link|passC|passL|emit|importc|importcpp|importobjc|codegenDecl|injectStmt|intdefine|strdefine|varargs|exportc|extern|bycopy|byref|union|packed|unchecked|dynlib|cdecl|thread|gcsafe|threadvar|guard|locks|compileTime)\\b" + - symbol.operator: "[=\\+\\-\\*/<>@\\$~&%\\|!\\?\\^\\.:\\\\]+" + - special: "\\{\\.|\\.\\}|\\[\\.|\\.\\]|\\(\\.|\\.\\)|;|,|`" + - statement: "\\.\\." + - type: "\\b(int|cint|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|float32|float64|bool|char|enum|string|cstring|array|openarray|seq|varargs|tuple|object|set|void|auto|cshort|range|nil|T|untyped|typedesc)\\b" + - type: "'[iI](8|16|32|64)?\\b|'[uU](8|16|32|64)?\\b|'[fF](32|64|128)?\\b|'[dD]\\b" + - constant.number: "\\b[0-9]+\\b" + - constant.number: "\\b0[xX][0-9A-Fa-f][0-9_A-Fa-f]+\\b" + - constant.number: "\\b0[ocC][0-7][0-7_]+\\b" + - constant.number: "\\b0[bB][01][01_]+\\b" + - constant.number: "\\b[0-9_]((\\.?)[0-9_]+)?[eE][+\\-][0-9][0-9_]+\\b" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - comment: "[[:space:]]*#.*$" + - comment: + start: "\\#\\[" + end: "\\]\\#" + rules: [] + + - todo: "(TODO|FIXME|XXX):?" diff --git a/syntax_files/objc.yaml b/syntax_files/objc.yaml index 22d82af..a099d2b 100644 --- a/syntax_files/objc.yaml +++ b/syntax_files/objc.yaml @@ -34,13 +34,13 @@ rules: - constant.string: start: "@\"" - end: "\"" + end: "(?|<-|=>" + - identifier.var: "%[A-Za-z][A-Za-z0-9_]*" + - special: "\\[[^]]*\\]" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - comment: "(^|[[:space:]])\\-\\-.*$" + - todo: "TODO:?" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/perl.yaml b/syntax_files/perl.yaml new file mode 100644 index 0000000..15193e0 --- /dev/null +++ b/syntax_files/perl.yaml @@ -0,0 +1,27 @@ +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/perl6.yaml b/syntax_files/perl6.yaml new file mode 100644 index 0000000..4b4d7df --- /dev/null +++ b/syntax_files/perl6.yaml @@ -0,0 +1,27 @@ +filetype: perl6 + +detect: + filename: "\\.p6$" + +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)|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|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|seekdir|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|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" + - special: "\\b(has|is|class|role|given|when|BUILD|multi|returns|method|submethod|slurp|say|sub)\\b" + - identifier: + start: "[$@%]" + end: "( |\\\\W|-)" + rules: [] + + - constant.string: "\".*\"|qq\\|.*\\|" + - default: "[sm]/.*/" + - preproc: + start: "(^use| = new)" + end: ";" + rules: [] + + - comment: "#.*" + - identifier.macro: + start: "<" + - error: "<[^!].*?>" + - symbol.tag: "(?i)<[/]?(a(bbr|cronym|ddress|pplet|rea|rticle|side|udio)?|b(ase(font)?|d(i|o)|ig|lockquote|r)?|ca(nvas|ption)|center|cite|co(de|l|lgroup)|d(ata(list)?|d|el|etails|fn|ialog|ir|l|t)|em(bed)?|fieldset|fig(caption|ure)|font|form|(i)?frame|frameset|h[1-6]|hr|i|img|in(put|s)|kbd|keygen|label|legend|li(nk)?|ma(in|p|rk)|menu(item)?|met(a|er)|nav|no(frames|script)|o(l|pt(group|ion)|utput)|p(aram|icture|re|rogress)?|q|r(p|t|uby)|s(trike)?|samp|se(ction|lect)|small|source|span|strong|su(b|p|mmary)|textarea|time|track|u(l)?|var|video|wbr)( .*|>)*?>" + - symbol.tag.extended: "(?i)<[/]?(body|div|html|head(er)?|footer|title|table|t(body|d|h(ead)?|r|foot))( .*|>)*?>" + - preproc: "(?i)<[/]?(script|style)( .*|>)*?>" + - special: "&[^;[[:space:]]]*;" + - symbol: "[:=]" + - identifier: "(alt|bgcolor|height|href|label|longdesc|name|onclick|onfocus|onload|onmouseover|size|span|src|style|target|type|value|width)=" + - constant.string: "\"[^\"]*\"" + - constant.number: "(?i)#[0-9A-F]{6,6}" + - constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+" + - comment: "" + - default: "<\\?(php|=)\" end=\"\\?>" + - identifier.class: "([a-zA-Z0-9_-]+)\\(" + - preproc: "(require|include|require_once|include_once)" + - type: "\\b(var|class|extends|function|echo|case|default|exit|switch|extends|as|define|do|declare|in|trait|interface|[E|e]xception|array|int|string|bool|iterable|void)\\b" + - identifier.class: "[a-zA-Z\\\\]+::" + - identifier: "([A-Z][a-zA-Z0-9_]+)\\s" + - identifier: "([A-Z0-9_]+)[;|\\s|\\)|,]" + - type.keyword: "(global|public|private|protected|static|const)" + - statement: "(implements|abstract|instanceof|if|else(if)?|endif|namespace|use|as|new|throw|catch|try|while|print|(end)?(foreach)?)\\b" + - identifier: "new\\s([a-zA-Z0-9\\\\]+)" + - special: "(break|continue|goto|return)" + - constant.bool: "(true|false|null|TRUE|FALSE|NULL)" + - constant: "[\\s|=|\\s|\\(|/|+|-|\\*|\\[]" + - constant.number: "[0-9]" + - identifier: "(\\$this|parent|self|\\$this->)" + - symbol.operator: "(=>|===|!==|==|!=|&&|\\|\\||::|=|->|\\!)" + - identifier.var: "(\\$[a-zA-Z0-9\\-_]+)" + - symbol.operator: "[\\(|\\)|/|+|\\-|\\*|\\[|.|,|;]" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" + - symbol.brackets: "(\\[|\\]|\\{|\\}|[()])" + - comment: "(^|[[:space:]])//.*" + - comment: "(^|[[:space:]])#.*" + - comment: + start: "/\\*" + end: "\\*/" + rules: [] + + - preproc: "<\\?(php|=)?" + - preproc: "\\?>" + - preproc: "" diff --git a/syntax_files/pkg-config.yaml b/syntax_files/pkg-config.yaml new file mode 100644 index 0000000..3a7651e --- /dev/null +++ b/syntax_files/pkg-config.yaml @@ -0,0 +1,12 @@ +filetype: pc + +detect: + filename: "\\.pc$" + +rules: + - preproc: "^(Name|Description|URL|Version|Conflicts|Cflags):" + - preproc: "^(Requires|Libs)(\\.private)?:" + - symbol.operator: "=" + - identifier.var: "\\$\\{[A-Za-z_][A-Za-z0-9_]*\\}" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/po.yaml b/syntax_files/po.yaml new file mode 100644 index 0000000..26fbc05 --- /dev/null +++ b/syntax_files/po.yaml @@ -0,0 +1,12 @@ +filetype: po + +detect: + filename: "\\.pot?$" + +rules: + - preproc: "\\b(msgid|msgstr)\\b" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - special: "\\\\.?" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/pony.yaml b/syntax_files/pony.yaml new file mode 100644 index 0000000..68729c6 --- /dev/null +++ b/syntax_files/pony.yaml @@ -0,0 +1,37 @@ +filetype: pony + +detect: + filename: "\\.pony$" + +rules: + - statement: "\\b(type|interface|trait|primitive|class|struct|actor)\\b" + - statement: "\\b(compiler_intrinsic)\\b" + - statement: "\\b(use)\\b" + - statement: "\\b(var|let|embed)\\b" + - statement: "\\b(new|be|fun)\\b" + - statement: "\\b(iso|trn|ref|val|box|tag|consume)\\b" + - statement: "\\b(break|continue|return|error)\\b" + - statement: "\\b(if|then|elseif|else|end|match|where|try|with|as|recover|object|lambda|as|digestof|ifdef)\\b" + - statement: "\\b(while|do|repeat|until|for|in)\\b" + - statement: "(\\?|=>)" + - statement: "(\\||\\&|\\,|\\^)" + - symbol.operator: "(\\-|\\+|\\*|/|\\!|%|<<|>>)" + - symbol.operator: "(==|!=|<=|>=|<|>)" + - statement: "\\b(is|isnt|not|and|or|xor)\\b" + - type: "\\b(_*[A-Z][_a-zA-Z0-9\\']*)\\b" + - constant: "\\b(this)\\b" + - constant.bool: "\\b(true|false)\\b" + - constant.number: "\\b((0b[0-1_]*)|(0o[0-7_]*)|(0x[0-9a-fA-F_]*)|([0-9_]+(\\.[0-9_]+)?((e|E)(\\\\+|-)?[0-9_]+)?))\\b" + - constant.string: "\"(\\\\.|[^\"])*\"" + - comment: + start: "\"\"\"[^\"]*" + end: "\"\"\"" + rules: [] + + - comment: "(^|[[:space:]])//.*" + - comment: + start: "/\\*" + end: "\\*/" + rules: [] + + - todo: "TODO:?" diff --git a/syntax_files/pov.yaml b/syntax_files/pov.yaml new file mode 100644 index 0000000..01f4270 --- /dev/null +++ b/syntax_files/pov.yaml @@ -0,0 +1,21 @@ +filetype: pov + +detect: + filename: "\\.(pov|POV|povray|POVRAY)$" + +rules: + - preproc: "^[[:space:]]*#[[:space:]]*(declare)" + - statement: "\\b(sphere|cylinder|translate|matrix|rotate|scale)\\b" + - statement: "\\b(orthographic|location|up|right|direction|clipped_by)\\b" + - statement: "\\b(fog_type|fog_offset|fog_alt|rgb|distance|transform)\\b" + - identifier: "^\\b(texture)\\b" + - identifier: "\\b(light_source|background)\\b" + - identifier: "\\b(fog|object|camera)\\b" + - symbol.operator: "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)" + - special: "\\b(union|group|subgroup)\\b" + - comment: "//.*" + - comment: + start: "/\\*" + end: "\\*/" + rules: [] + diff --git a/syntax_files/privoxy-action.yaml b/syntax_files/privoxy-action.yaml new file mode 100644 index 0000000..33e15ad --- /dev/null +++ b/syntax_files/privoxy-action.yaml @@ -0,0 +1,14 @@ +filetype: privoxy-action + +detect: + filename: "\\.action$" + +rules: + - constant.bool.false: "[{[:space:]]\\-block([[:space:]{}]|$)" + - constant.bool.true: "[{[:space:]]\\+block([[:space:]{}]|$)" + - constant.bool.false: "-(add-header|change-x-forwarded-for|client-header-filter|client-header-tagger|content-type-overwrite|crunch-client-header|crunch-if-none-match|crunch-incoming-cookies|crunch-outgoing-cookies|crunch-server-header|deanimate-gifs|downgrade-http-version|fast-redirects|filter|force-text-mode|forward-override|handle-as-empty-document|handle-as-image|hide-accept-language|hide-content-disposition|hide-from-header|hide-if-modified-since|hide-referrer|hide-user-agent|limit-connect|overwrite-last-modified|prevent-compression|redirect|server-header-filter|server-header-tagger|session-cookies-only|set-image-blocker)" + - constant.bool.true: "\\+(add-header|change-x-forwarded-for|client-header-filter|client-header-tagger|content-type-overwrite|crunch-client-header|crunch-if-none-match|crunch-incoming-cookies|crunch-outgoing-cookies|crunch-server-header|deanimate-gifs|downgrade-http-version|fast-redirects|filter|force-text-mode|forward-override|handle-as-empty-document|handle-as-image|hide-accept-language|hide-content-disposition|hide-from-header|hide-if-modified-since|hide-referrer|hide-user-agent|limit-connect|overwrite-last-modified|prevent-compression|redirect|server-header-filter|server-header-tagger|session-cookies-only|set-image-blocker)" + - constant.specialChar: "\\\\.?" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/privoxy-config.yaml b/syntax_files/privoxy-config.yaml new file mode 100644 index 0000000..bdce3f6 --- /dev/null +++ b/syntax_files/privoxy-config.yaml @@ -0,0 +1,10 @@ +filetype: privoxy-config + +detect: + filename: "privoxy/config$" + +rules: + - statement: "(accept-intercepted-requests|actionsfile|admin-address|allow-cgi-request-crunching|buffer-limit|compression-level|confdir|connection-sharing|debug|default-server-timeout|deny-access|enable-compression|enable-edit-actions|enable-remote-http-toggle|enable-remote-toggle|enforce-blocks|filterfile|forward|forwarded-connect-retries|forward-socks4|forward-socks4a|forward-socks5|handle-as-empty-doc-returns-ok|hostname|keep-alive-timeout|listen-address|logdir|logfile|max-client-connections|permit-access|proxy-info-url|single-threaded|socket-timeout|split-large-forms|templdir|toggle|tolerate-pipelining|trustfile|trust-info-url|user-manual)[[:space:]]" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/privoxy-filter.yaml b/syntax_files/privoxy-filter.yaml new file mode 100644 index 0000000..7be9351 --- /dev/null +++ b/syntax_files/privoxy-filter.yaml @@ -0,0 +1,12 @@ +filetype: privoxy-filter + +detect: + filename: "\\.filter$" + +rules: + - statement: "^(FILTER|CLIENT-HEADER-FILTER|CLIENT-HEADER-TAGGER|SERVER-HEADER-FILTER|SERVER-HEADER-TAGGER): [a-z-]+" + - identifier: "^(FILTER|CLIENT-HEADER-FILTER|CLIENT-HEADER-TAGGER|SERVER-HEADER-FILTER|SERVER-HEADER-TAGGER):" + - constant.specialChar: "\\\\.?" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/puppet.yaml b/syntax_files/puppet.yaml new file mode 100644 index 0000000..7fd1b54 --- /dev/null +++ b/syntax_files/puppet.yaml @@ -0,0 +1,22 @@ +filetype: puppet + +detect: + filename: "\\.pp$" + +rules: + - default: "^[[:space:]]([a-z][a-z0-9_]+)" + - identifier.var: "\\$[a-z:][a-z0-9_:]+" + - type: "\\b(augeas|computer|cron|exec|file|filebucket|group|host|interface|k5login|macauthorization|mailalias|maillist|mcx|mount|nagios_command|nagios_contact|nagios_contactgroup|nagios_host|nagios_hostdependency|nagios_hostescalation|nagios_hostextinfo|nagios_hostgroup|nagios_service|nagios_servicedependency|nagios_serviceescalation|nagios_serviceextinfo|nagios_servicegroup|nagios_timeperiod|notify|package|resources|router|schedule|scheduled_task|selboolean|selmodule|service|ssh_authorized_key|sshkey|stage|tidy|user|vlan|yumrepo|zfs|zone|zpool|anchor)\\b" + - statement: "\\b(class|define|if|else|undef|inherits)\\b" + - symbol: "(=|-|~|>)" + - identifier.var: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*" + - symbol: "([ ]|^):[0-9A-Z_]+\\b" + - constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*" + - constant.string: "`[^`]*`|%x\\{[^}]*\\}" + - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" + - special: "\\$\\{[^}]*\\}" + - constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" + - comment: "#[^{].*$|#$" + - comment.bright: "##[^{].*$|##$" + - todo: "(XXX|TODO|FIXME|\\?\\?\\?)" + - indent-char.whitespace: "[[:space:]]+$" diff --git a/syntax_files/python2.yaml b/syntax_files/python2.yaml index bddf66d..68e0424 100644 --- a/syntax_files/python2.yaml +++ b/syntax_files/python2.yaml @@ -29,23 +29,6 @@ rules: # numbers - constant.number: "\\b[0-9]+\\b" - - constant.string: - start: "\"" - end: "\"" - rules: - - constant.specialChar: "\\\\." - - - constant.string: - start: "'" - end: "'" - rules: - - constant.specialChar: "\\\\." - - - comment: - start: "#" - end: "$" - rules: [] - - comment: start: "\"\"\"" end: "\"\"\"" @@ -55,3 +38,21 @@ rules: start: "'''" end: "'''" rules: [] + + - constant.string: + start: "\"" + end: "(?" + - special: "^%(build$|changelog|check$|clean$|description)" + - special: "^%(files|install$|package|prep$)" + - special: "^%(pre|preun|pretrans|post|postun|posttrans)" + - special: "^%(trigger|triggerin|triggerpostun|triggerun|verifyscript)" + - comment: "(^|[[:space:]])#([^{].*)?$" + - constant: "^\\*.*$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" + - todo: "TODO:?" diff --git a/syntax_files/ruby.yaml b/syntax_files/ruby.yaml new file mode 100644 index 0000000..b0b1816 --- /dev/null +++ b/syntax_files/ruby.yaml @@ -0,0 +1,26 @@ +filetype: ruby + +detect: + filename: "\\.rb$|\\.gemspec$|Gemfile|config.ru|Rakefile|Capfile|Vagrantfile" + header: "^#!.*/(env +)?ruby( |$)" + +rules: + - statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\\b" + - constant: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*" + - constant.number: "\\b[0-9]+\\b" + - constant: "(i?)([ ]|^):[0-9A-Z_]+\\b" + - constant: "\\b(__FILE__|__LINE__)\\b" + - constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*" + - constant.string: "`[^`]*`|%x\\{[^}]*\\}" + - constant.string: "\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!" + - special: "#\\{[^}]*\\}" + - constant.string: "'([^']|(\\\\'))*'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!" + - comment: "#[^{].*$|#$" + - comment.bright: "##[^{].*$|##$" + - constant.macro: + start: "<<-?'?EOT'?" + end: "^EOT" + rules: [] + + - todo: "(XXX|TODO|FIXME|\\?\\?\\?)" + - preproc.shebang: "^#!.+?( |$)" diff --git a/syntax_files/rust.yaml b/syntax_files/rust.yaml index dc6d101..3c61e51 100644 --- a/syntax_files/rust.yaml +++ b/syntax_files/rust.yaml @@ -19,7 +19,7 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(?" + - symbol: "=" + - special: "^\\[(Unit|Install|Service|Socket)\\]" + - identifier.class: "\\$MAINPID" + - constant.bool: "\\b(true|false)\\b" + - comment: "(^|[[:space:]])#([^{].*)?$" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/tcl.yaml b/syntax_files/tcl.yaml new file mode 100644 index 0000000..82963c2 --- /dev/null +++ b/syntax_files/tcl.yaml @@ -0,0 +1,18 @@ +filetype: tcl + +detect: + filename: "\\.tcl$" + header: "^#!.*/(env +)?tclsh( |$)" + +rules: + - statement: "\\b(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|else|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\\b" + - statement: "\\b(array anymore|array donesearch|array exists|array get|array names|array nextelement|array set|array size|array startsearch|array statistics|array unset)\\b" + - statement: "\\b(string bytelength|string compare|string equal|string first|string index|string is|string last|string length|string map|string match|string range|string repeat|string replace|string to|string tolower|string totitle|string toupper|string trim|string trimleft|string trimright|string will|string wordend|string wordstart)\\b" + - statement: "\\b(alarm|auto_load_pkg|bsearch|catclose|catgets|catopen|ccollate|cconcat|cequal|chgrp|chmod|chown|chroot|cindex|clength|cmdtrace|commandloop|crange|csubstr|ctoken|ctype|dup|echo|execl|fcntl|flock|fork|fstat|ftruncate|funlock|host_info|id|infox|keyldel|keylget|keylkeys|keylset|kill|lassign|lcontain|lempty|lgets|link|lmatch|loadlibindex|loop|lvarcat|lvarpop|lvarpush|max|min|nice|pipe|profile|random|readdir|replicate|scancontext|scanfile|scanmatch|select|server_accept|server_create|signal|sleep|sync|system|tclx_findinit|tclx_fork|tclx_load_tndxs|tclx_sleep|tclx_system|tclx_wait|times|translit|try_eval|umask|wait)\\b" + - identifier.class: "proc[[:space:]]|(\\{|\\})" + - symbol.operator: "(\\(|\\)|\\;|`|\\\\|\\$|<|>|!|=|&|\\|)" + - constant.number: "\\b[0-9]+(\\.[0-9]+)?\\b" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - identifier.var: "\\$\\{?[0-9A-Z_!@#$*?-]+\\}?" + - comment: "(^|;)[[:space:]]*#.*" + - indent-char.whitespace: "[[:space:]]+$" diff --git a/syntax_files/toml.yaml b/syntax_files/toml.yaml index 639be32..e123802 100644 --- a/syntax_files/toml.yaml +++ b/syntax_files/toml.yaml @@ -16,13 +16,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(??:!~%&|]|->" + - constant.string: "\"(\\\\.|[^\"])*\"|'(\\\\.|[^'])*'" + - comment: "(^|[[:space:]])//.*" + - comment: + start: "/\\*" + end: "\\*/" + rules: [] + + - todo: "TODO:?" + - indent-char.whitespace: "[[:space:]]+$" + - indent-char: " + +| + +" diff --git a/syntax_files/vhdl.yaml b/syntax_files/vhdl.yaml new file mode 100644 index 0000000..6bd3b53 --- /dev/null +++ b/syntax_files/vhdl.yaml @@ -0,0 +1,37 @@ +filetype: vhdl + +detect: + filename: "\\.vhdl?$" + +rules: + - type: "(i)\\b(string|integer|natural|positive|(un)?signed|std_u?logic(_vector)?|bit(_vector)?|boolean|u?x01z?|array|range)\\b" + - identifier: "(?i)library[[:space:]]+[a-zA-Z_0-9]+" + - identifier: "(?i)use[[:space:]]+[a-zA-Z_0-9\\.]+" + - identifier: "(?i)component[[:space:]]+[a-zA-Z_0-9]+" + - identifier: "(?i)(architecture|configuration)[[:space:]]+[a-zA-Z_0-9]+[[:space:]]+of[[:space:]]+[a-zA-Z_0-9]+" + - identifier: "(?i)(entity|package)[[:space:]]+[a-zA-Z_0-9]+[[:space:]]+is" + - identifier: "(?i)end[[:space:]]+((architecture|entity|component|process|package|generate)[[:space:]]+)?[a-zA-Z_0-9]+" + - statement: "(?i)\\b(abs|access|after|alias|all|and|architecture|assert|attribute)\\b" + - statement: "(?i)\\b(begin|block|body|buffer|bus|case|component|configuration|constant)\\b" + - statement: "(?i)\\b(disconnect|downto|else|elsif|end|entity|exit)\\b" + - statement: "(?i)\\b(file|for|function|generate|generic|guarded)\\b" + - statement: "(?i)\\b(if|impure|in|inertial|inout|is)\\b" + - statement: "(?i)\\b(label|library|linkage|literal|loop|map|mod)\\b" + - statement: "(?i)\\b(nand|new|next|nor|not|null|of|on|open|or|others|out)\\b" + - statement: "(?i)\\b(package|port|postponed|procedure|process|pure)\\b" + - statement: "(?i)\\b(range|record|register|reject|rem|report|return|rol|ror)\\b" + - statement: "(?i)\\b(select|severity|shared|signal|sla|sll|sra|srl|subtype)\\b" + - statement: "(?i)\\b(then|to|transport|type|unaffected|units|until|use)\\b" + - statement: "(?i)\\b(variable|wait|when|while|with|xnor|xor)\\b" + - statement: "(?i)'(base|left|right|high|low|pos|val|succ|pred|leftof|rightof|image|(last_)?value)" + - statement: "(?i)'((reverse_)?range|length|ascending|event|stable)" + - statement: "(?i)'(simple|path|instance)_name" + - statement: "(?i)\\b(std_match|(rising|falling)_edge|is_x)\\b" + - statement: "(?i)\\bto_(unsigned|signed|integer|u?x01z?|stdu?logic(vector)?)\\b" + - symbol.operator: "(\\+|-|\\*|/|&|<|>|=|\\.|:)" + - constant.number: "(?i)'([0-1]|u|x|z|w|l|h|-)'|[box]?\"([0-1a-fA-F]|u|x|z|w|l|h|-)+\"" + - constant.number: "(?i)\\b[0-9\\._]+(e[\\-]?[0-9]+)?( ?[fpnum]?s)?\\b" + - constant.bool: "(?i)\\b(true|false)\\b" + - constant: "(?i)\\b(note|warning|error|failure)\\b" + - constant.string: "\"[^\"]*\"" + - comment: "--.*" diff --git a/syntax_files/vi.yaml b/syntax_files/vi.yaml index 43fa54d..84020ef 100644 --- a/syntax_files/vi.yaml +++ b/syntax_files/vi.yaml @@ -12,13 +12,13 @@ rules: - constant.string: start: "\"" - end: "\"" + end: "(?]|^[[:space:]]*- )" - identifier: "[[:space:]][\\*&][A-Za-z0-9]+" - - type: "([-\\w]+:\\s+)|([-\\w]+:$)" + - type: "[-.\\w]+:" + - statement: ":" - special: "(^---|^\\.\\.\\.|^%YAML|^%TAG)" - constant.string: start: "\"" - end: "\"" + end: "(?