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

Update from jasonwilliams/sublime_toml_highlighting@master #2

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jason Williams

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 20 additions & 10 deletions TOML.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ file_extensions:
- Cargo.lock
- Gopkg.lock
- Pipfile
- pdm.lock
- poetry.lock
- uv.lock

scope: source.toml

Expand All @@ -29,10 +32,13 @@ variables:
oct_int: '0o[0-7](?:[0-7]|_[0-7])*'
bin_int: '0b[0-1](?:[0-1]|_[0-1])*'

# frac = "." DIGIT *( DIGIT / "_" DIGIT )
frac: '\. [0-9] (?: [0-9] | _ [0-9] )*'
# exp = ("e" / "E") integer
exp: '[eE] {{integer}}'
# zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT )
zero_prefixable_int: '[0-9] (?: [0-9] | _ [0-9] )*'
# frac = decimal-point zero-prefixable-int
frac: '\. {{zero_prefixable_int}}'
# exp = "e" float-exp-part
# float-exp-part = [ minus / plus ] zero-prefixable-int
exp: '[eE] [\+\-]? {{zero_prefixable_int}}'

# date-time = offset-date-time / local-date-time / local-date / local-time
date_time: '{{offset_date_time}} | {{local_date_time}} | {{local_date}} | {{local_time}}'
Expand All @@ -53,17 +59,17 @@ variables:
# time-numoffset = ( "+" / "-" ) time-hour ":" time-minute
time_numoffset: '[+-] {{time_hour}} : {{time_minute}}'
# time-offset = "Z" / time-numoffset
time_offset: '(?: Z | {{time_numoffset}} )'
time_offset: '(?: [zZ] | {{time_numoffset}} )'
# partial-time = time-hour ":" time-minute ":" time-second [time-secfrac]
partial_time: '{{time_hour}} : {{time_minute}} : {{time_second}} (?: {{time_secfrac}} )?'
# full-date = date-fullyear "-" date-month "-" date-mday
full_date: '{{date_fullyear}} - {{date_month}} - {{date_mday}}'
# full-time = partial-time time-offset
full_time: '{{partial_time}} {{time_offset}}'
# offset-date-time = full-date T|%20 full-time
offset_date_time: '{{full_date}} [T ] {{full_time}}'
offset_date_time: '{{full_date}} [tT ] {{full_time}}'
# local-date-time = full-date T|%20 partial-time
local_date_time: '{{full_date}} [T ] {{partial_time}}'
local_date_time: '{{full_date}} [tT ] {{partial_time}}'
# local-date = full-date
local_date: '{{full_date}}'
# local-time = partial-time
Expand Down Expand Up @@ -127,9 +133,10 @@ contexts:
pop: true

float:
# float = integer ( frac / ( frac exp ) / exp )
# frac = "." DIGIT *( DIGIT / "_" DIGIT )
# exp = ("e" / "E") integer
# float = float-int-part ( exp / frac [ exp ] )
# float =/ special-float
# special-float = [ minus / plus ] ( inf / nan )
# float-int-part = dec-int
- match: |-
(?x)
(?<!\w)
Expand Down Expand Up @@ -268,6 +275,9 @@ contexts:
scope: punctuation.separator.inline-table.toml
set:
- match: '{{ws}}'
- match: '\}'
scope: invalid.illegal.table-end.toml
pop: true
- match: ''
set: [inline-keyval-sep, key]
- match: '(?=\w+|.)'
Expand Down
26 changes: 24 additions & 2 deletions syntax_test_toml.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SYNTAX TEST "Packages/sublime_toml_highlighting/TOML.sublime-syntax"
# SYNTAX TEST "Packages/TOML/TOML.sublime-syntax"

# This is a TOML document. Boom.
# <- comment.line.number-sign punctuation.definition.comment
Expand Down Expand Up @@ -425,6 +425,10 @@ a = 5e+22
# ^^^^^ constant.numeric.float
a = 1e6
# ^^^ constant.numeric.float
a = 1e06
# ^^^^ constant.numeric.float
a = 1e+06
# ^^^^^ constant.numeric.float
a = -2E-2
# ^ keyword.operator.arithmetic
# ^^^^^ constant.numeric.float
Expand Down Expand Up @@ -521,6 +525,8 @@ ldt1s = 1979-05-27 07:32:00
# ^^^^^^^^^^^^^^^^^^^ constant.other.datetime
ldt2s = 1979-05-27 00:32:00.999999
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.datetime
lowercase = 1997-09-09t09:09:09z
# ^^^^^^^^^^^^^^^^^^^^ constant.other.datetime

#-----------------------------------------------------------------------------
# Invalid Date-Time
Expand Down Expand Up @@ -886,19 +892,35 @@ t = {b=true, i=1, f=1.0, dt=1979-05-27T07:32:00Z, s1='s', s2="s", s3='''s''', s4
t = {,}
# ^^ invalid.illegal
t = {=}
# ^ punctuation.definition.key-value
# ^ invalid.illegal
t = {
} # comment to clear scope
}
#<- invalid.illegal
t = {key=1,}
#<- meta.tag.key entity.name.tag
# ^ punctuation.separator.inline-table
# ^ invalid.illegal
t = {key}
# ^^^ meta.tag.key entity.name.tag
# ^ invalid.illegal
t = {key=1 asdf}
# ^^^^^ invalid.illegal
t = {key=1, asdf}
# ^^^^ meta.tag.key entity.name.tag
# ^ invalid.illegal
t = {key=invalid}
# ^ punctuation.definition.key-value
# ^^^^^^^ invalid.illegal.value
# ^ punctuation.definition.inline-table.end
t = {!=123}
# ^ invalid.illegal.key
# ^ punctuation.definition.key-value
# ^^^ constant.numeric.integer
# ^ punctuation.definition.inline-table.end
t = {a=1, }
# ^ punctuation.separator.inline-table
# ^ invalid.illegal.table-end
[test] # Verify that the illegal scope has popped
#^^^^ meta.tag.table.toml entity.name.table.toml
# ^ punctuation.definition.table.end.toml