1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-09-21 18:09:09 +03:00

feat(rc): improve graphql syntax highlighters

This commit is contained in:
Gianni Chiappetta 2021-01-13 21:24:56 -05:00
parent c614b21d74
commit 1c639f7810
No known key found for this signature in database
GPG Key ID: 0E83B3D88ECF5E7C

View File

@ -34,15 +34,39 @@ provide-module graphql %(
add-highlighter shared/graphql regions
add-highlighter shared/graphql/code default-region group
add-highlighter shared/graphql/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/graphql/comment region '#' \n fill comment
add-highlighter shared/graphql/line-description region '#' '\n' fill comment
add-highlighter shared/graphql/block-description region '"""' '"""' fill comment
add-highlighter shared/graphql/description region '"' '"\s*\n' fill comment
add-highlighter shared/graphql/object region -recurse \{ [{] [}] regions
add-highlighter shared/graphql/code/ regex \b(fragment|query|mutation|on)\b 0:keyword
add-highlighter shared/graphql/code/ regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?)\b 0:value
add-highlighter shared/graphql/code/ regex \$[a-zA-Z0-9]+\b 0:value
add-highlighter shared/graphql/code/ regex @(?:include|skip) 0:meta
add-highlighter shared/graphql/code/ regex \b(Boolean|Float|ID|Int|String)\b 0:type
add-highlighter shared/graphql/code/ regex ! 0:operator
# Objects
add-highlighter shared/graphql/object/line-description region '#' '\n' fill comment
add-highlighter shared/graphql/object/block-description region '"""' '"""' fill comment
add-highlighter shared/graphql/object/field default-region group
add-highlighter shared/graphql/object/field/ regex ([A-Za-z][A-Za-z0-9_-]*)(?:\([\w\d\h,:$=]*\))?\h*[:{] 1:attribute
add-highlighter shared/graphql/object/field/ regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*$ 1:attribute
# Values
add-highlighter shared/graphql/object/field/values regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?)\b 0:value
add-highlighter shared/graphql/object/field/variables regex \$[a-zA-Z0-9]+\b 0:variable
add-highlighter shared/graphql/object/field/string regex '"[^"]*"' 0:string
# Meta
add-highlighter shared/graphql/object/field/directives regex @(?:include|skip) 0:meta
# Attributes
add-highlighter shared/graphql/object/field/required regex '(?<=[\w\]])(?<bang>!)' bang:operator
add-highlighter shared/graphql/object/field/assignment regex '=' 0:operator
# Keywords
add-highlighter shared/graphql/code/top-level regex '\bschema\b' 0:keyword
add-highlighter shared/graphql/code/keywords regex '\b(?<name>enum|fragment|input|implements|interface|mutation|on|query|scalar|subscription|type|union)\h+(?:[A-Za-z]\w*)' name:keyword
# Types
add-highlighter shared/graphql/object/field/scalars regex \b(Boolean|Float|ID|Int|String)\b 0:type
# Operators
add-highlighter shared/graphql/object/field/expand-fragment regex '\.\.\.(?=\w)' 0:operator
# Commands
# ‾‾‾‾‾‾‾‾