mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
highlights(markup): distinguish heading level in queries
also add a few queries from Helix and remove controversial code block conceal in Markdown
This commit is contained in:
parent
15300c1a10
commit
680807fa6a
5 changed files with 43 additions and 53 deletions
|
|
@ -126,48 +126,48 @@
|
||||||
;; Sectioning
|
;; Sectioning
|
||||||
(title_declaration
|
(title_declaration
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
options: (brack_group (_) @text.title)?
|
options: (brack_group (_) @text.title.1)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.1))
|
||||||
|
|
||||||
(author_declaration
|
(author_declaration
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
authors: (curly_group_author_list
|
authors: (curly_group_author_list
|
||||||
((author)+ @text.title)))
|
((author)+ @text.title.1)))
|
||||||
|
|
||||||
(chapter
|
(chapter
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.2)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.2))
|
||||||
|
|
||||||
(part
|
(part
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.2)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.2))
|
||||||
|
|
||||||
(section
|
(section
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.3)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.3))
|
||||||
|
|
||||||
(subsection
|
(subsection
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.4)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.4))
|
||||||
|
|
||||||
(subsubsection
|
(subsubsection
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.5)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.5))
|
||||||
|
|
||||||
(paragraph
|
(paragraph
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.6)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.6))
|
||||||
|
|
||||||
(subparagraph
|
(subparagraph
|
||||||
command: _ @namespace
|
command: _ @namespace
|
||||||
toc: (brack_group (_) @text.title)?
|
toc: (brack_group (_) @text.title.6)?
|
||||||
text: (curly_group (_) @text.title))
|
text: (curly_group (_) @text.title.6))
|
||||||
|
|
||||||
;; Beamer frames
|
;; Beamer frames
|
||||||
(generic_environment
|
(generic_environment
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
;From MDeiml/tree-sitter-markdown
|
;From MDeiml/tree-sitter-markdown & Helix
|
||||||
(atx_heading (inline) @text.title)
|
(setext_heading (paragraph) @text.title.1 (setext_h1_underline) @text.title.1.marker)
|
||||||
(setext_heading (paragraph) @text.title)
|
(setext_heading (paragraph) @text.title.2 (setext_h2_underline) @text.title.2.marker)
|
||||||
|
|
||||||
[
|
(atx_heading (atx_h1_marker) @text.title.1.marker (inline) @text.title.1)
|
||||||
(atx_h1_marker)
|
(atx_heading (atx_h2_marker) @text.title.2.marker (inline) @text.title.2)
|
||||||
(atx_h2_marker)
|
(atx_heading (atx_h3_marker) @text.title.3.marker (inline) @text.title.3)
|
||||||
(atx_h3_marker)
|
(atx_heading (atx_h4_marker) @text.title.4.marker (inline) @text.title.4)
|
||||||
(atx_h4_marker)
|
(atx_heading (atx_h5_marker) @text.title.5.marker (inline) @text.title.5)
|
||||||
(atx_h5_marker)
|
(atx_heading (atx_h6_marker) @text.title.6.marker (inline) @text.title.6)
|
||||||
(atx_h6_marker)
|
|
||||||
(setext_h1_underline)
|
|
||||||
(setext_h2_underline)
|
|
||||||
] @punctuation.special
|
|
||||||
|
|
||||||
[
|
[
|
||||||
(link_title)
|
(link_title)
|
||||||
|
|
@ -19,6 +15,8 @@
|
||||||
(fenced_code_block)
|
(fenced_code_block)
|
||||||
] @text.literal
|
] @text.literal
|
||||||
|
|
||||||
|
(info_string) @label
|
||||||
|
|
||||||
(pipe_table_header (pipe_table_cell) @text.title)
|
(pipe_table_header (pipe_table_cell) @text.title)
|
||||||
|
|
||||||
(pipe_table_header "|" @punctuation.special)
|
(pipe_table_header "|" @punctuation.special)
|
||||||
|
|
@ -64,10 +62,4 @@
|
||||||
(backslash_escape)
|
(backslash_escape)
|
||||||
] @string.escape
|
] @string.escape
|
||||||
|
|
||||||
([
|
|
||||||
(info_string)
|
|
||||||
(fenced_code_block_delimiter)
|
|
||||||
] @conceal
|
|
||||||
(#set! conceal ""))
|
|
||||||
|
|
||||||
(inline) @spell
|
(inline) @spell
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,10 @@
|
||||||
(hard_line_break)
|
(hard_line_break)
|
||||||
] @string.escape
|
] @string.escape
|
||||||
|
|
||||||
; "(" not part of query because of
|
(image "!" @punctuation.special)
|
||||||
; https://github.com/nvim-treesitter/nvim-treesitter/issues/2206
|
(image ["[" "]" "(" ")"] @punctuation.bracket)
|
||||||
; TODO: Find better fix for this
|
(inline_link ["[" "]" "(" ")"] @punctuation.bracket)
|
||||||
(image ["!" "[" "]" "(" ")"] @punctuation.delimiter)
|
(shortcut_link ["[" "]"] @punctuation.bracket)
|
||||||
(inline_link ["[" "]" "(" ")"] @punctuation.delimiter)
|
|
||||||
(shortcut_link ["[" "]"] @punctuation.delimiter)
|
|
||||||
|
|
||||||
; Conceal codeblock and text style markers
|
; Conceal codeblock and text style markers
|
||||||
([
|
([
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(h1) @text.title
|
(h1) @text.title.1
|
||||||
(h2) @text.title
|
(h2) @text.title.2
|
||||||
(h3) @text.title
|
(h3) @text.title.3
|
||||||
(column_heading) @text.title
|
(column_heading) @text.title.4
|
||||||
(column_heading
|
(column_heading
|
||||||
"~" @conceal (#set! conceal ""))
|
"~" @conceal (#set! conceal ""))
|
||||||
(tag
|
(tag
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# H1
|
# H1
|
||||||
<!-- <- punctuation.special -->
|
<!-- <- text.title.1.marker -->
|
||||||
|
|
||||||
## H2
|
## H2
|
||||||
<!-- <- punctuation.special -->
|
<!-- <- text.title.2.marker -->
|
||||||
|
|
||||||
- Item 1
|
- Item 1
|
||||||
- Item 2
|
- Item 2
|
||||||
|
|
@ -16,13 +16,13 @@
|
||||||
<!-- ^ text.reference -->
|
<!-- ^ text.reference -->
|
||||||
<!-- ^ text.uri -->
|
<!-- ^ text.uri -->
|
||||||
<!-- ^ text.literal -->
|
<!-- ^ text.literal -->
|
||||||
<!--^ punctuation.delimiter -->
|
<!--^ punctuation.special -->
|
||||||
<!-- ^ punctuation.delimiter -->
|
<!-- ^ punctuation.bracket -->
|
||||||
<!-- //TODO: currently disabled punctuation.delimiter -->
|
<!-- ^ punctuation.bracket -->
|
||||||
|
|
||||||
[link_text](#local_reference "link go brr...")
|
[link_text](#local_reference "link go brr...")
|
||||||
<!-- ^ text.reference -->
|
<!-- ^ text.reference -->
|
||||||
<!-- ^ text.uri -->
|
<!-- ^ text.uri -->
|
||||||
<!-- ^ text.literal -->
|
<!-- ^ text.literal -->
|
||||||
<!-- <- punctuation.delimiter -->
|
<!-- <- punctuation.bracket -->
|
||||||
<!-- //TODO: currently disabled punctuation.delimiter -->
|
<!-- ^ punctuation.bracket -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue