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:
Christian Clason 2023-05-13 11:23:50 +02:00
parent 15300c1a10
commit 680807fa6a
5 changed files with 43 additions and 53 deletions

View file

@ -126,48 +126,48 @@
;; Sectioning
(title_declaration
command: _ @namespace
options: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
options: (brack_group (_) @text.title.1)?
text: (curly_group (_) @text.title.1))
(author_declaration
command: _ @namespace
authors: (curly_group_author_list
((author)+ @text.title)))
((author)+ @text.title.1)))
(chapter
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.2)?
text: (curly_group (_) @text.title.2))
(part
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.2)?
text: (curly_group (_) @text.title.2))
(section
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.3)?
text: (curly_group (_) @text.title.3))
(subsection
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.4)?
text: (curly_group (_) @text.title.4))
(subsubsection
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.5)?
text: (curly_group (_) @text.title.5))
(paragraph
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.6)?
text: (curly_group (_) @text.title.6))
(subparagraph
command: _ @namespace
toc: (brack_group (_) @text.title)?
text: (curly_group (_) @text.title))
toc: (brack_group (_) @text.title.6)?
text: (curly_group (_) @text.title.6))
;; Beamer frames
(generic_environment

View file

@ -1,17 +1,13 @@
;From MDeiml/tree-sitter-markdown
(atx_heading (inline) @text.title)
(setext_heading (paragraph) @text.title)
;From MDeiml/tree-sitter-markdown & Helix
(setext_heading (paragraph) @text.title.1 (setext_h1_underline) @text.title.1.marker)
(setext_heading (paragraph) @text.title.2 (setext_h2_underline) @text.title.2.marker)
[
(atx_h1_marker)
(atx_h2_marker)
(atx_h3_marker)
(atx_h4_marker)
(atx_h5_marker)
(atx_h6_marker)
(setext_h1_underline)
(setext_h2_underline)
] @punctuation.special
(atx_heading (atx_h1_marker) @text.title.1.marker (inline) @text.title.1)
(atx_heading (atx_h2_marker) @text.title.2.marker (inline) @text.title.2)
(atx_heading (atx_h3_marker) @text.title.3.marker (inline) @text.title.3)
(atx_heading (atx_h4_marker) @text.title.4.marker (inline) @text.title.4)
(atx_heading (atx_h5_marker) @text.title.5.marker (inline) @text.title.5)
(atx_heading (atx_h6_marker) @text.title.6.marker (inline) @text.title.6)
[
(link_title)
@ -19,6 +15,8 @@
(fenced_code_block)
] @text.literal
(info_string) @label
(pipe_table_header (pipe_table_cell) @text.title)
(pipe_table_header "|" @punctuation.special)
@ -64,10 +62,4 @@
(backslash_escape)
] @string.escape
([
(info_string)
(fenced_code_block_delimiter)
] @conceal
(#set! conceal ""))
(inline) @spell

View file

@ -31,12 +31,10 @@
(hard_line_break)
] @string.escape
; "(" not part of query because of
; https://github.com/nvim-treesitter/nvim-treesitter/issues/2206
; TODO: Find better fix for this
(image ["!" "[" "]" "(" ")"] @punctuation.delimiter)
(inline_link ["[" "]" "(" ")"] @punctuation.delimiter)
(shortcut_link ["[" "]"] @punctuation.delimiter)
(image "!" @punctuation.special)
(image ["[" "]" "(" ")"] @punctuation.bracket)
(inline_link ["[" "]" "(" ")"] @punctuation.bracket)
(shortcut_link ["[" "]"] @punctuation.bracket)
; Conceal codeblock and text style markers
([

View file

@ -1,7 +1,7 @@
(h1) @text.title
(h2) @text.title
(h3) @text.title
(column_heading) @text.title
(h1) @text.title.1
(h2) @text.title.2
(h3) @text.title.3
(column_heading) @text.title.4
(column_heading
"~" @conceal (#set! conceal ""))
(tag

View file

@ -1,8 +1,8 @@
# H1
<!-- <- punctuation.special -->
<!-- <- text.title.1.marker -->
## H2
<!-- <- punctuation.special -->
<!-- <- text.title.2.marker -->
- Item 1
- Item 2
@ -16,13 +16,13 @@
<!-- ^ text.reference -->
<!-- ^ text.uri -->
<!-- ^ text.literal -->
<!--^ punctuation.delimiter -->
<!-- ^ punctuation.delimiter -->
<!-- //TODO: currently disabled punctuation.delimiter -->
<!--^ punctuation.special -->
<!-- ^ punctuation.bracket -->
<!-- ^ punctuation.bracket -->
[link_text](#local_reference "link go brr...")
<!-- ^ text.reference -->
<!-- ^ text.uri -->
<!-- ^ text.literal -->
<!-- <- punctuation.delimiter -->
<!-- //TODO: currently disabled punctuation.delimiter -->
<!-- <- punctuation.bracket -->
<!-- ^ punctuation.bracket -->