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

Split LO Calc sheet refs #45

Merged
merged 1 commit into from
Jan 26, 2025
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
56 changes: 35 additions & 21 deletions LibreOffice Calc Formula.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,59 @@ contexts:
push: function-call-body

sheet-reference:
- match: (?=\$?{{sheet}}[!\.])
- match: \$(?={{sheet}}\.)
scope: punctuation.definition.annotation.begin.libre
push: sheet-reference-body-dollar
- match: (?={{sheet}}!)
push: sheet-reference-body

sheet-reference-body:
- meta_scope: meta.reference.sheet
- match: '[!\.]'
scope: punctuation.separator.sequence.sheet
sheet-reference-body-dollar:
- meta_scope: meta.reference.sheet.libre
- match: \.
scope: punctuation.separator.sequence.libre
pop: 1
- match: \$
- include: sheet-reference-quoted
- match: '{{sheet}}'
scope: entity.name.struct.sheet.libre
- include: immediately-pop

sheet-reference-body:
- meta_scope: meta.reference.sheet.libre
- match: '!'
scope: punctuation.separator.sequence.libre
pop: 1
- include: sheet-reference-quoted
- match: '{{sheet}}'
scope: entity.name.struct.sheet.libre
- include: immediately-pop

sheet-reference-quoted:
- match: \'
scope: punctuation.definition.annotation.begin.sheet
scope: punctuation.definition.annotation.begin.libre
push:
- meta_content_scope: entity.name.struct.sheet
- meta_content_scope: entity.name.struct.sheet.libre
- match: \'\'
scope: constant.character.escape.sheet
scope: constant.character.escape.libre
- match: \'(?=[!\.])
scope: punctuation.definition.annotation.end.sheet
scope: punctuation.definition.annotation.end.libre
pop: 1
- match: '{{sheet}}'
scope: entity.name.struct.sheet
- include: immediately-pop

cell-or-range-reference:
- meta_append: true
- match: ({{rc}})(:)({{rc}})
scope: meta.reference.range.cell.sheet
scope: meta.reference.range.cell.libre
captures:
1: storage.type.sheet
2: punctuation.separator.sequence.sheet
3: storage.type.sheet
1: storage.type.libre
2: punctuation.separator.sequence.libre
3: storage.type.libre
push: after-reference

- match: ({{rc}})
scope: meta.reference.range.cell.sheet
scope: meta.reference.range.cell.libre
captures:
1: storage.type.sheet
2: punctuation.separator.sequence.sheet
3: storage.type.sheet
1: storage.type.libre
2: punctuation.separator.sequence.libre
3: storage.type.libre
push: after-reference

variables:
Expand Down
83 changes: 53 additions & 30 deletions tests/syntax_test_libre_references.localc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,88 @@
='John''sSheetDon''tTouch'!A1

='s''s'!N36
'^^^^^^^ meta.reference.sheet
'^ punctuation.definition.annotation.begin.sheet - entity
' ^^^^ entity.name.struct.sheet
' ^^ constant.character.escape.sheet
' ^ punctuation.definition.annotation.end.sheet - entity
' ^ punctuation.separator.sequence.sheet
'^^^^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^^^ meta.reference.sheet.libre
'^ punctuation.definition.annotation.begin.libre - entity
' ^^^^ entity.name.struct.sheet.libre
' ^^ constant.character.escape.libre
' ^ punctuation.definition.annotation.end.libre - entity
' ^ punctuation.separator.sequence.libre
' ^^^ meta.reference.cell.sheet storage.type.sheet

='s''''s'!N36
'^^^^^^^^^ meta.reference.sheet
'^ punctuation.definition.annotation.begin.sheet - entity
'^^^^^^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^^^^^ meta.reference.sheet.libre
'^ punctuation.definition.annotation.begin.libre - entity
' ^^^^^^ entity.name.struct.sheet
' ^^^^ constant.character.escape.sheet
' ^ punctuation.definition.annotation.end.sheet - entity
' ^ punctuation.separator.sequence.sheet
' ^^^^ constant.character.escape.libre
' ^ punctuation.definition.annotation.end.libre - entity
' ^ punctuation.separator.sequence.libre
' ^^^ meta.reference.cell.sheet storage.type.sheet

=한국어!L11
' <- keyword.operator.assignment
'^^^^^^^ meta.reference - meta meta
' ^ - meta.reference
'^^^ entity.name.struct
' ^ punctuation.separator.sequence
' ^^^ storage.type
'^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^ meta.reference.sheet.libre
'^^^ entity.name.struct.sheet.libre
' ^ punctuation.separator.sequence.libre
' ^^^ meta.reference.cell.sheet storage.type.sheet

=_hello_2world!N36
'^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference
' <- keyword.operator.assignment
'^^^^^^^^^^^^^^^^^ meta.reference - meta meta
' ^ - meta.reference
'^^^^^^^^^^^^^ entity.name.struct
' ^ punctuation.separator.sequence - entity

='This''sASheetWithAnEscapedSingleQuote'!A1
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet - meta meta
'^ punctuation.definition.annotation.begin.sheet - entity
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet.libre - meta meta
'^ punctuation.definition.annotation.begin.libre - entity
' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.sheet
' ^^ constant.character.escape.sheet
' ^ punctuation.definition.annotation.end.sheet - entity
' ^ punctuation.separator.sequence.sheet
' ^^ constant.character.escape.libre
' ^ punctuation.definition.annotation.end.libre - entity
' ^ punctuation.separator.sequence.libre
' ^^ meta.reference.cell.sheet storage.type.sheet
' <- keyword.operator.assignment.sheet

=''''!A1
'^^^^^ meta.reference.sheet
'^ punctuation.definition.annotation.begin.sheet
' ^^ entity.name.struct.sheet constant.character.escape.sheet - punctuation
' ^ punctuation.definition.annotation.end.sheet
' ^ punctuation.separator.sequence.sheet
'^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^ meta.reference.sheet.libre
'^ punctuation.definition.annotation.begin.libre
' ^^ entity.name.struct.sheet.libre constant.character.escape.libre - punctuation
' ^ punctuation.definition.annotation.end.libre
' ^ punctuation.separator.sequence.libre
' ^^ meta.reference.cell.sheet storage.type.sheet
' <- keyword.operator.assignment.sheet

='^'!A1
'^^^^^^ meta.reference - meta.reference meta.reference
'^^^^ meta.reference.sheet
'^ punctuation.definition.annotation.begin.sheet
' ^ entity.name.struct.sheet
' ^ punctuation.definition.annotation.end.sheet
' ^ punctuation.separator.sequence.sheet
'^ punctuation.definition.annotation.begin.libre
' ^ entity.name.struct.sheet.libre
' ^ punctuation.definition.annotation.end.libre
' ^ punctuation.separator.sequence.libre
' ^^ meta.reference.cell.sheet storage.type.sheet

'''[ LIBRE REFERENCES ]''''''''''''''''''''''''''''''''''''''''''''''''''

=$_hello_2world.A1
'^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^^^^^^^^^^^ meta.reference.sheet.libre
'^ punctuation.definition.annotation.begin.libre
' ^^^^^^^^^^^^^ entity.name.struct.sheet.libre
' ^ punctuation.separator.sequence.libre
' ^^ meta.reference.cell.sheet storage.type.sheet

=$'John''sSheetDon''tTouch'.A1
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference - meta.reference meta.reference
'^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.reference.sheet.libre
'^^ punctuation.definition.annotation.begin.libre
' ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.struct.sheet.libre
' ^^ constant.character.escape.libre
' ^^ constant.character.escape.libre
' ^ punctuation.definition.annotation.end.libre
' ^ punctuation.separator.sequence.libre
' ^^ meta.reference.cell.sheet storage.type.sheet
Loading