Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty rules in regions #3458

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pkg/highlight/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func ParseDef(f *File, header *Header) (s *Def, err error) {

if s.rules == nil {
// allow empty rules
s.rules = new(rules)
s.rules = &rules{}
}

return s, err
Expand Down Expand Up @@ -476,10 +476,17 @@ func parseRegion(group string, regionInfo map[interface{}]interface{}, prevRegio
r.limitGroup = r.group
}

r.rules, err = parseRules(regionInfo["rules"].([]interface{}), r)
// rules are optional
if rules, ok := regionInfo["rules"]; ok {
r.rules, err = parseRules(rules.([]interface{}), r)
if err != nil {
return nil, err
}
}

if err != nil {
return nil, err
if r.rules == nil {
// allow empty rules
r.rules = &rules{}
}

return r, nil
Expand Down
1 change: 0 additions & 1 deletion runtime/help/colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ highlighted. For example:
start: "\""
end: "\""
skip: "\\."
rules: []
```

#### Includes
Expand Down
1 change: 0 additions & 1 deletion runtime/plugins/literate/literate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function onBufferOpen(buf)
syntaxFile = syntaxFile .. " - special:\n"
syntaxFile = syntaxFile .. " start: \"@\\\\{\"\n"
syntaxFile = syntaxFile .. " end: \"\\\\}\"\n"
syntaxFile = syntaxFile .. " rules: []\n"
syntaxFile = syntaxFile .. " - include: " .. codetype .. "\n"

config.AddRuntimeFileFromMemory(config.RTSyntax, "literate.yaml", syntaxFile)
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/caddyfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

1 change: 0 additions & 1 deletion runtime/syntax/cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ rules:
- preproc:
start: "\\$(\\{|ENV\\{)"
end: "\\}"
rules: []

- identifier.macro: "\\b(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\\b"

Expand Down
3 changes: 0 additions & 3 deletions runtime/syntax/crystal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []

- constant.string:
start: "%x\\{"
end: "\\}"
rules: []

- constant.string:
start: "\""
Expand Down Expand Up @@ -68,5 +66,4 @@ rules:
- constant:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []

2 changes: 0 additions & 2 deletions runtime/syntax/css.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ rules:
# - normal:
# start: "\\{"
# end: "\\}"
# rules: []
# css commands
- type: "(align-content|align-items|alignment-baseline|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|appearance|azimuth|backdrop-filter|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|baseline-shift|bookmark-label|bookmark-level|bookmark-state|border|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-boundary|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|bottom|box-decoration-break|box-shadow|box-sizing|box-snap|box-suppress|break-after|break-before|break-inside|caption-side|caret|caret-animation|caret-color|caret-shape|chains|clear|clip|clip-path|clip-rule|color|color-interpolation-filters|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|columns|column-span|column-width|content|continue|counter-increment|counter-reset|counter-set|cue|cue-after|cue-before|cursor|direction|display|dominant-baseline|elevation|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|float-defer|float-offset|float-reference|flood-color|flood-opacity|flow|flow-from|flow-into|font|font-family|font-feature-settings|font-kerning|font-language-override|font-size|font-size-adjust|font-stretch|font-style|font-synthesis|font-variant|font-variant-alternates|font-variant-caps|font-variant-east-asian|font-variant-ligatures|font-variant-numeric|font-variant-position|font-weight|footnote-display|footnote-policy|gap|glyph-orientation-vertical|grid|grid-area|grid-auto-columns|grid-auto-flow|grid-auto-rows|grid-column|grid-column-end|grid-column-gap|grid-column-start|grid-gap|grid-row|grid-row-end|grid-row-gap|grid-row-start|grid-template|grid-template-areas|grid-template-columns|grid-template-rows|hanging-punctuation|height|hyphenate-character|hyphenate-limit-chars|hyphenate-limit-last|hyphenate-limit-lines|hyphenate-limit-zone|hyphens|image-orientation|image-rendering|image-resolution|initial-letter|initial-letter-align|initial-letter-wrap|isolation|justify-content|justify-items|justify-self|left|letter-spacing|lighting-color|line-break|line-grid|line-height|line-snap|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|marker|marker-end|marker-knockout-left|marker-knockout-right|marker-mid|marker-pattern|marker-segment|marker-side|marker-start|marquee-direction|marquee-loop|marquee-speed|marquee-style|mask|mask-border|mask-border-mode|mask-border-outset|mask-border-repeat|mask-border-slice|mask-border-source|mask-border-width|mask-clip|mask-composite|mask-image|mask-mode|mask-origin|mask-position|mask-repeat|mask-size|mask-type|max-height|max-lines|max-width|min-height|min-width|mix-blend-mode|motion|motion-offset|motion-path|motion-rotation|nav-down|nav-left|nav-right|nav-up|object-fit|object-position|offset-after|offset-before|offset-end|offset-start|opacity|order|orphans|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-style|overflow-wrap|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page|page-break-after|page-break-before|page-break-inside|pause|pause-after|pause-before|perspective|perspective-origin|pitch|pitch-range|play-during|pointer-events|polar-anchor|polar-angle|polar-distance|polar-origin|position|presentation-level|quotes|region-fragment|resize|rest|rest-after|rest-before|richness|right|rotation|rotation-point|ruby-align|ruby-merge|ruby-position|running|scrollbar-color|scroll-behavior|scroll-snap-align|scroll-snap-margin|scroll-snap-margin-block|scroll-snap-margin-block-end|scroll-snap-margin-block-start|scroll-snap-margin-bottom|scroll-snap-margin-inline|scroll-snap-margin-inline-end|scroll-snap-margin-inline-start|scroll-snap-margin-left|scroll-snap-margin-right|scroll-snap-margin-top|scroll-snap-padding|scroll-snap-padding-block|scroll-snap-padding-block-end|scroll-snap-padding-block-start|scroll-snap-padding-bottom|scroll-snap-padding-inline|scroll-snap-padding-inline-end|scroll-snap-padding-inline-start|scroll-snap-padding-left|scroll-snap-padding-right|scroll-snap-padding-top|scroll-snap-type|shape-image-threshold|shape-inside|shape-margin|shape-outside|size|speak|speak-as|speak-header|speak-numeral|speak-punctuation|speech-rate|stress|string-set|stroke|stroke-alignment|stroke-dashadjust|stroke-dasharray|stroke-dashcorner|stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|stroke-width|table-layout|tab-size|text-align|text-align-all|text-align-last|text-combine-upright|text-decoration|text-decoration-color|text-decoration-line|text-decoration-skip|text-decoration-style|text-emphasis|text-emphasis-color|text-emphasis-position|text-emphasis-style|text-indent|text-justify|text-orientation|text-overflow|text-shadow|text-space-collapse|text-space-trim|text-spacing|text-transform|text-underline-offset|text-underline-position|text-wrap|top|transform|transform-box|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|user-select|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch|voice-range|voice-rate|voice-stress|voice-volume|volume|white-space|widows|width|will-change|word-break|word-spacing|word-wrap|wrap-after|wrap-before|wrap-flow|wrap-inside|wrap-through|writing-mode|z-index):"
# - default:
# start: ":"
# end: "[;^\\{]"
# rules: []
- special: "!important"
- identifier: ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
- special: "(\\{|\\}|\\(|\\)|\\;|:|\\]|~|<|>|,)"
Expand Down
3 changes: 0 additions & 3 deletions runtime/syntax/d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,10 @@ rules:
- comment:
start: "//"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules: []
- comment:
start: "/\\+"
end: "\\+/"
rules: []

2 changes: 0 additions & 2 deletions runtime/syntax/erb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rules:
- default:
start: "<%"
end: "%>"
rules: []

- preproc: "<%|%>"
- red: "&[^;[[:space:]]]*;"
Expand All @@ -37,6 +36,5 @@ rules:
- identifier.macro:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []

- todo: "(XXX|TODO|FIXME|\\?\\?\\?)"
2 changes: 0 additions & 2 deletions runtime/syntax/erlang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []
# - constant.specialChar: "%."
# - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
# - constant.specialChar: "\\\\([0-7]{3}|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})"
Expand All @@ -42,4 +41,3 @@ rules:
- comment:
start: "%"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/fish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ rules:
start: "'"
end: "'"
skip: "\\\\."
rules: []

- comment:
start: "#"
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/forth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rules:
- constant.string:
start: "\\b([Ss.]\" )"
end: "\""
rules: []

- comment:
start: "\\("
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/fsharp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ rules:
- comment:
start: "\\(\\*"
end: "\\*\\)"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/gemini.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rules:
- special:
start: "^```"
end: "^```"
rules: []
# heading lines
- special: "^#{1,3}.*"
# unordered list items
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/gentoo-etc-portage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/git-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ rules:
- comment.line:
start: "^#"
end: "$"
rules: []

# Diffs (i.e. git commit --verbose)
- default:
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/git-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/git-rebase-todo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ rules:
- comment.line:
start: "^#"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ rules:
- constant.string:
start: "`"
end: "`"
rules: []

- comment:
start: "//"
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/graphql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
3 changes: 0 additions & 3 deletions runtime/syntax/groff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@ rules:
- constant:
start: "(\\\\|\\\\\\\\)n\\["
end: "]"
rules: []

- type: "^\\.[[:space:]]*[^[[:space:]]]*"
- comment: "^\\.\\\\\".*$"
- constant.string: "(\\\\|\\\\\\\\)\\*(.|\\(..)"
- constant.string:
start: "(\\\\|\\\\\\\\)\\*\\["
end: "]"
rules: []

- constant.specialChar: "\\\\\\(.."
- constant.specialChar:
start: "\\\\\\["
end: "]"
rules: []

- identifier.macro: "\\\\\\\\\\$[1-9]"
3 changes: 0 additions & 3 deletions runtime/syntax/groovy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ rules:
- identifier:
start: "[$][{]"
end: "[}]"
rules: []

# Triple-single-quoted strings
- constant.string:
Expand All @@ -90,7 +89,6 @@ rules:
- constant.string:
start: "[$]/"
end: "/[$]"
rules: []

# Single-line comments
- comment:
Expand All @@ -110,4 +108,3 @@ rules:
- comment:
start: "/[*][*]@?"
end: "[*]/"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/html4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ rules:
- default:
start: ">"
end: "<"
rules: []

- symbol.tag: "<|>"
- constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+"
Expand Down
1 change: 0 additions & 1 deletion runtime/syntax/html5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ rules:
- default:
start: ">"
end: "<"
rules: []

- symbol.tag: "<|>"
- constant.string.url: "(ftp(s)?|http(s)?|git|chrome)://[^ ]+"
Expand Down
2 changes: 0 additions & 2 deletions runtime/syntax/java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ rules:
- comment:
start: "//"
end: "$"
rules: []

- comment:
start: "/\\*"
end: "\\*/"
rules: []

1 change: 0 additions & 1 deletion runtime/syntax/jinja2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ rules:
- comment:
start: "{#"
end: "#}"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/jsonnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ rules:

start: "\\|\\|\\| *$"
end: "^ *\\|\\|\\|"
rules: []

# multi-line comment
- comment:
Expand Down
4 changes: 0 additions & 4 deletions runtime/syntax/julia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ rules:
- constant.string:
start: "\"\"\""
end: "\"\"\""
rules: []

- constant.string:
start: "\""
Expand All @@ -44,14 +43,11 @@ rules:
- constant.string:
start: "'\""
end: "'"
rules: []

- comment:
start: "#="
end: "=#"
rules: []

- comment:
start: "#"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/justfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ rules:
- comment:
start: "#"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/keymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ rules:
- comment:
start: "^!"
end: "$"
rules: []

3 changes: 0 additions & 3 deletions runtime/syntax/kvlang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ rules:
start: "\""
end: "(\"|$)"
skip: "\\\\."
rules: []
- constant.string:
start: "'"
end: "('|$)"
skip: "\\\\."
rules: []

- comment:
start: "#"
end: "$"
rules: []
2 changes: 0 additions & 2 deletions runtime/syntax/lilypond.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ rules:
- comment:
start: "%\\{"
end: "%\\}"
rules: []
- comment:
start: "%"
end: "$"
rules: []

1 change: 0 additions & 1 deletion runtime/syntax/log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ rules:
- constant.string.url:
start: "https?://"
end: "\\s"
rules: []

# path
# - constant.string.url: "\\b(.+)/([^/]+)\\b" # linux
Expand Down
5 changes: 0 additions & 5 deletions runtime/syntax/lua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,25 @@ rules:
- constant.string:
start: "\\[\\["
end: "\\]\\]"
rules: []

# support first few lengths of "long brackets" explicitly
# brackets longer than that will give false positives

- constant.string:
start: "\\[=\\["
end: "\\]=\\]"
rules: []

- constant.string:
start: "\\[==\\["
end: "\\]==\\]"
rules: []

- constant.string:
start: "\\[===\\["
end: "\\]===\\]"
rules: []

- constant.string:
start: "\\[====+\\["
end: "\\]====+\\]"
rules: []

- comment.block:
start: "\\-\\-\\[\\["
Expand Down
2 changes: 0 additions & 2 deletions runtime/syntax/mail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ rules:
- default:
start: "^\\n\\n"
end: ".*"
rules: []
- comment:
start: "^>.*"
end: "$"
rules: []
1 change: 0 additions & 1 deletion runtime/syntax/makefile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ rules:
- comment:
start: "#"
end: "$"
rules: []

1 change: 0 additions & 1 deletion runtime/syntax/markdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,3 @@ rules:
- special:
start: "`"
end: "`"
rules: []
Loading