-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
$sheet.A1
style sheet references unique to Libre
Fixes #36
- Loading branch information
Showing
2 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,30 @@ contexts: | |
2: meta.function-call.arguments.libre punctuation.section.arguments.begin.libre | ||
push: function-call-body | ||
|
||
sheet-reference: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
michaelblyons
Contributor
|
||
- match: (?=\$?{{sheet}}[!\.]) | ||
push: sheet-reference-body | ||
|
||
sheet-reference-body: | ||
- meta_scope: meta.reference.sheet | ||
- match: '[!\.]' | ||
scope: punctuation.separator.sequence.sheet | ||
This comment has been minimized.
Sorry, something went wrong.
michaelblyons
Contributor
|
||
pop: 1 | ||
- match: \$ | ||
scope: punctuation.separator.sequence.libre | ||
This comment has been minimized.
Sorry, something went wrong. |
||
- match: \' | ||
scope: punctuation.definition.annotation.begin.sheet | ||
push: | ||
- meta_content_scope: entity.name.struct.sheet | ||
- match: \'\' | ||
scope: constant.character.escape.sheet | ||
- match: \'(?=[!\.]) | ||
scope: punctuation.definition.annotation.end.sheet | ||
pop: 1 | ||
- match: '{{sheet}}' | ||
scope: entity.name.struct.sheet | ||
- include: immediately-pop | ||
|
||
cell-or-range-reference: | ||
- meta_append: true | ||
- match: ({{rc}})(:)({{rc}}) | ||
|
@@ -71,8 +95,23 @@ variables: | |
# LibreOffice does not support tables | ||
table: (?!.) | ||
|
||
# # TODO: Update with LibreOffice alternate-format sheet references in addition. | ||
# sheet: (?#WIP) | ||
# TODO: Is there a cleaner more compact (and probably more efficient) way to | ||
#(dupe) do this? `'` are only legal in excel sheet names when padded on | ||
# either end with a legal character matched by [^:*/?\[\]\\], | ||
# and said `'` must come in pairs. | ||
# TODO: Update with LibreOffice alternate-format sheet references in addition. | ||
sheet_delimited: |- | ||
(?x: | ||
(?:'[^:*/?\[\]\\]+('')*[^:*/?\[\]\\]+')| | ||
(?:'[^:*/?\[\]\\]+')| | ||
(?:\$'[^:*/?\[\]\\]+('')*[^:*/?\[\]\\]+') | ||
) | ||
sheet_normal: |- | ||
(?x: | ||
(?:[\w&&[^0-9]]\w*)| | ||
(?:\$[^\.:*/?\[\]\\]+) | ||
) | ||
sheet: (?:{{sheet_delimited}}|{{sheet_normal}}) | ||
|
||
# RC row/column offset format | ||
r_: |- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I think I'd match each of the styles separately and push to different contexts with the right matches. With what you have here, you'll match all the right stuff, but maybe more of the wrong stuff than you want.