Skip to content

Commit

Permalink
Merge pull request #1 from ngc92/brace-pop
Browse files Browse the repository at this point in the history
added a brace-pop utility context
  • Loading branch information
deathaxe authored Nov 19, 2022
2 parents 96d16df + d789979 commit 874f1d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 78 deletions.
84 changes: 21 additions & 63 deletions LaTeX/LaTeX.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ contexts:
3: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.include.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end

sections:
- match: |-
Expand Down Expand Up @@ -337,9 +335,7 @@ contexts:
push:
- meta_scope: meta.section.latex
- meta_content_scope: entity.name.section.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
structure:
Expand Down Expand Up @@ -448,9 +444,7 @@ contexts:
scope: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.group.brace.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: math-content

math-content:
Expand All @@ -472,9 +466,7 @@ contexts:
push:
- meta_scope: meta.function.ensuremath.latex
- meta_content_scope: meta.environment.math.inline.ensuremath.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: math-content

- match: (\\\()
Expand Down Expand Up @@ -568,9 +560,7 @@ contexts:
push:
- meta_scope: meta.function.emph.latex
- meta_content_scope: markup.italic.emph.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)textit)(\{)
captures:
Expand All @@ -580,9 +570,7 @@ contexts:
push:
- meta_scope: meta.function.textit.latex
- meta_content_scope: markup.italic.textit.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)textbf)(\{)
captures:
Expand All @@ -592,9 +580,7 @@ contexts:
push:
- meta_scope: meta.function.textbf.latex
- meta_content_scope: markup.bold.textbf.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)texttt)(\{)
captures:
Expand All @@ -604,9 +590,7 @@ contexts:
push:
- meta_scope: meta.function.texttt.latex
- meta_content_scope: markup.raw.texttt.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)textsl)(\{)
captures:
Expand All @@ -616,19 +600,15 @@ contexts:
push:
- meta_scope: meta.function.textsl.latex
- meta_content_scope: markup.italic.textsl.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)text)(\{)
captures:
1: support.function.text.latex
2: punctuation.definition.backslash.latex
3: punctuation.definition.group.brace.begin.latex
push:
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: ((\\)underline)(\{)
captures:
Expand All @@ -638,9 +618,7 @@ contexts:
push:
- meta_scope: meta.function.underline.latex
- meta_content_scope: markup.underline.underline.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main

footnote:
Expand All @@ -656,9 +634,7 @@ contexts:
set:
- meta_scope: meta.function.footnote.latex meta.group.brace.latex
- meta_content_scope: markup.italic.footnote.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: main
- match: (?=\S)
pop: true
Expand Down Expand Up @@ -710,9 +686,7 @@ contexts:
- meta_scope: meta.group.brace.latex
- match: '[a-zA-Z0-9\.:/*!^_-]+'
scope: constant.other.citation.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- match: ''
pop: true
- match: |-
Expand All @@ -734,9 +708,7 @@ contexts:
- meta_scope: meta.function.reference.latex meta.group.brace.latex
- match: '[a-zA-Z0-9\.:/*!^_-]+'
scope: constant.other.reference.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- match: ''
pop: true
- match: ((\\)label)(\{)
Expand All @@ -748,9 +720,7 @@ contexts:
- meta_scope: meta.function.label.latex
- match: '[a-zA-Z0-9\.:/*!^_-]+'
scope: entity.name.label.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end

begin-end-commands:
- match: ((\\)begin)(\{)\s*(\w*)\*?\s*(\})
Expand Down Expand Up @@ -1577,9 +1547,7 @@ contexts:
push:
- meta_include_prototype: false
- meta_scope: meta.function.newcolumntype.latex
- match: '\}'
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: array-preamble
Expand Down Expand Up @@ -1623,9 +1591,7 @@ contexts:
- match: \{
scope: punctuation.definition.group.brace.begin.latex
push:
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: array-preamble
Expand All @@ -1645,9 +1611,7 @@ contexts:
2: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.function.before-column-decl.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand All @@ -1658,9 +1622,7 @@ contexts:
2: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.function.after-column-decl.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand All @@ -1674,9 +1636,7 @@ contexts:
2: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.function.inter-column-decl.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand All @@ -1687,9 +1647,7 @@ contexts:
2: punctuation.definition.group.brace.begin.latex
push:
- meta_scope: meta.function.inter-column-decl.latex
- match: \}
scope: punctuation.definition.group.brace.end.latex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand Down
26 changes: 11 additions & 15 deletions LaTeX/TeX.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ contexts:
scope: punctuation.definition.group.brace.begin.tex
push:
- meta_scope: meta.group.brace.tex
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: true
- include: brace-group-end
- include: main

# within macros, it is possible that only part of some nested struture
Expand All @@ -169,9 +167,7 @@ contexts:
scope: punctuation.definition.group.brace.begin.tex
push:
- meta_scope: meta.group.brace.tex
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: true
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand All @@ -184,9 +180,7 @@ contexts:
3: punctuation.definition.group.brace.begin.tex
push:
- meta_scope: meta.function.box.tex
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: true
- include: brace-group-end
- include: main

macros:
Expand Down Expand Up @@ -244,9 +238,7 @@ contexts:

def-definition-body:
- meta_scope: meta.function.body.tex meta.group.brace.tex
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: 1
- include: brace-group-end
- include: general-constants
- include: general-commands
- include: macro-braces
Expand Down Expand Up @@ -332,9 +324,7 @@ contexts:
scope: punctuation.definition.group.brace.begin.tex
push:
- meta_scope: meta.group.brace.tex
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: true
- include: brace-group-end
- include: math-content

math-brackets:
Expand Down Expand Up @@ -393,6 +383,12 @@ contexts:
- match: (?=\S)
pop: true

# matches a closing brace and pops the context
brace-group-end:
- match: \}
scope: punctuation.definition.group.brace.end.tex
pop: true

immediately-pop:
- match: ''
pop: true
Expand Down

0 comments on commit 874f1d3

Please sign in to comment.