mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-20 04:10:06 -04:00
latex: update queries
Make use of parser updates
* add `\{re}newenvironment`
* add `\DeclarePairedDelimiter{X}`
* add `\title` and `\author`
* add optional arguments to sectioning commands
* use builtin nodes for math environments
This commit is contained in:
parent
6443a70e17
commit
94f19cad29
2 changed files with 42 additions and 61 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
(subparagraph)
|
(subparagraph)
|
||||||
|
|
||||||
(generic_environment)
|
(generic_environment)
|
||||||
|
(math_environment)
|
||||||
(comment_environment)
|
(comment_environment)
|
||||||
(displayed_equation)
|
(displayed_equation)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
|
||||||
|
|
@ -32,35 +32,11 @@
|
||||||
;; General environments
|
;; General environments
|
||||||
(begin
|
(begin
|
||||||
command: _ @text.environment
|
command: _ @text.environment
|
||||||
name: (curly_group_text
|
name: (curly_group_text (text) @text.environment.name))
|
||||||
(text) @text.environment.name)
|
|
||||||
(#not-any-of? @text.environment.name
|
|
||||||
"displaymath" "displaymath*"
|
|
||||||
"equation" "equation*"
|
|
||||||
"multline" "multline*"
|
|
||||||
"eqnarray" "eqnarray*"
|
|
||||||
"align" "align*"
|
|
||||||
"array" "array*"
|
|
||||||
"split" "split*"
|
|
||||||
"alignat" "alignat*"
|
|
||||||
"gather" "gather*"
|
|
||||||
"flalign" "flalign*"))
|
|
||||||
|
|
||||||
(end
|
(end
|
||||||
command: _ @text.environment
|
command: _ @text.environment
|
||||||
name: (curly_group_text
|
name: (curly_group_text (text) @text.environment.name))
|
||||||
(text) @text.environment.name)
|
|
||||||
(#not-any-of? @text.environment.name
|
|
||||||
"displaymath" "displaymath*"
|
|
||||||
"equation" "equation*"
|
|
||||||
"multline" "multline*"
|
|
||||||
"eqnarray" "eqnarray*"
|
|
||||||
"align" "align*"
|
|
||||||
"array" "array*"
|
|
||||||
"split" "split*"
|
|
||||||
"alignat" "alignat*"
|
|
||||||
"gather" "gather*"
|
|
||||||
"flalign" "flalign*"))
|
|
||||||
|
|
||||||
;; Definitions and references
|
;; Definitions and references
|
||||||
(new_command_definition
|
(new_command_definition
|
||||||
|
|
@ -73,10 +49,18 @@
|
||||||
command: _ @function.macro
|
command: _ @function.macro
|
||||||
declaration: (_) @function)
|
declaration: (_) @function)
|
||||||
|
|
||||||
|
(environment_definition
|
||||||
|
command: _ @function.macro
|
||||||
|
name: (curly_group_text (_) @text.reference))
|
||||||
|
|
||||||
(theorem_definition
|
(theorem_definition
|
||||||
command: _ @function.macro
|
command: _ @function.macro
|
||||||
name: (curly_group_text (_) @text.environment.name))
|
name: (curly_group_text (_) @text.environment.name))
|
||||||
|
|
||||||
|
(paired_delimiter_definition
|
||||||
|
command: _ @function.macro
|
||||||
|
declaration: (curly_group_command_name (_) @function))
|
||||||
|
|
||||||
(label_definition
|
(label_definition
|
||||||
command: _ @function.macro
|
command: _ @function.macro
|
||||||
name: (curly_group_text (_) @text.reference))
|
name: (curly_group_text (_) @text.reference))
|
||||||
|
|
@ -121,69 +105,65 @@
|
||||||
[
|
[
|
||||||
(displayed_equation)
|
(displayed_equation)
|
||||||
(inline_formula)
|
(inline_formula)
|
||||||
|
(math_set)
|
||||||
] @text.math
|
] @text.math
|
||||||
|
|
||||||
((generic_environment
|
(math_environment
|
||||||
(begin
|
(begin
|
||||||
command: _ @text.math
|
command: _ @text.math
|
||||||
name: (curly_group_text
|
name: (curly_group_text (text) @text.math)))
|
||||||
(text) @_env))) @text.math
|
|
||||||
(#any-of? @_env
|
(math_environment
|
||||||
"displaymath" "displaymath*"
|
|
||||||
"equation" "equation*"
|
|
||||||
"multline" "multline*"
|
|
||||||
"eqnarray" "eqnarray*"
|
|
||||||
"align" "align*"
|
|
||||||
"array" "array*"
|
|
||||||
"split" "split*"
|
|
||||||
"alignat" "alignat*"
|
|
||||||
"gather" "gather*"
|
|
||||||
"flalign" "flalign*"))
|
|
||||||
((generic_environment
|
|
||||||
(end
|
(end
|
||||||
command: _ @text.math
|
command: _ @text.math
|
||||||
name: (curly_group_text
|
name: (curly_group_text (text) @text.math)))
|
||||||
(text) @_env))) @text.math
|
|
||||||
(#any-of? @_env
|
|
||||||
"displaymath" "displaymath*"
|
|
||||||
"equation" "equation*"
|
|
||||||
"multline" "multline*"
|
|
||||||
"eqnarray" "eqnarray*"
|
|
||||||
"align" "align*"
|
|
||||||
"array" "array*"
|
|
||||||
"split" "split*"
|
|
||||||
"alignat" "alignat*"
|
|
||||||
"gather" "gather*"
|
|
||||||
"flalign" "flalign*"))
|
|
||||||
|
|
||||||
;; Sectioning
|
;; Sectioning
|
||||||
|
(title_declaration
|
||||||
|
command: _ @namespace
|
||||||
|
options: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
|
(author_declaration
|
||||||
|
command: _ @namespace
|
||||||
|
authors: (curly_group_author_list
|
||||||
|
((command_name)? @function)
|
||||||
|
((author)+ @text.title)))
|
||||||
|
|
||||||
(chapter
|
(chapter
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(part
|
(part
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(section
|
(section
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(subsection
|
(subsection
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(subsubsection
|
(subsubsection
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(paragraph
|
(paragraph
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
(subparagraph
|
(subparagraph
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
text: (curly_group) @text.title)
|
toc: (brack_group (_) @text.title)?
|
||||||
|
text: (curly_group (_) @text.title))
|
||||||
|
|
||||||
;; Beamer frames
|
;; Beamer frames
|
||||||
(generic_environment
|
(generic_environment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue