mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 10:20:11 -04:00
feat(djot): update queries (#6375)
- Adjust some highlights to fit context better - Conceal inline content - Add locals - Add folds
This commit is contained in:
parent
0bfa0be5e4
commit
25ed904c75
4 changed files with 208 additions and 54 deletions
7
queries/djot/folds.scm
Normal file
7
queries/djot/folds.scm
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
(section)
|
||||||
|
(code_block)
|
||||||
|
(raw_block)
|
||||||
|
(list)
|
||||||
|
(div)
|
||||||
|
] @fold
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
(code_block)
|
(code_block)
|
||||||
(raw_block)
|
(raw_block)
|
||||||
(frontmatter)
|
(frontmatter)
|
||||||
] @markup.raw
|
] @markup.raw.block
|
||||||
(#set! "priority" 90))
|
(#set! "priority" 90))
|
||||||
|
|
||||||
; Remove @markup.raw for code with a language spec
|
; Remove @markup.raw for code with a language spec
|
||||||
|
|
@ -29,7 +29,8 @@
|
||||||
.
|
.
|
||||||
(code_block_marker_begin)
|
(code_block_marker_begin)
|
||||||
(language)
|
(language)
|
||||||
(code) @none)
|
(code) @none
|
||||||
|
(#set! "priority" 90))
|
||||||
|
|
||||||
[
|
[
|
||||||
(code_block_marker_begin)
|
(code_block_marker_begin)
|
||||||
|
|
@ -38,7 +39,11 @@
|
||||||
(raw_block_marker_end)
|
(raw_block_marker_end)
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
(language) @label
|
(language) @attribute
|
||||||
|
|
||||||
|
(inline_attribute
|
||||||
|
_ @conceal
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
((language_marker) @punctuation.delimiter
|
((language_marker) @punctuation.delimiter
|
||||||
(#set! conceal ""))
|
(#set! conceal ""))
|
||||||
|
|
@ -60,7 +65,7 @@
|
||||||
(table_caption
|
(table_caption
|
||||||
(marker) @punctuation.special)
|
(marker) @punctuation.special)
|
||||||
|
|
||||||
(table_caption) @markup.heading
|
(table_caption) @markup.italic
|
||||||
|
|
||||||
[
|
[
|
||||||
(list_marker_dash)
|
(list_marker_dash)
|
||||||
|
|
@ -85,10 +90,14 @@
|
||||||
] @markup.list
|
] @markup.list
|
||||||
|
|
||||||
(list_marker_task
|
(list_marker_task
|
||||||
(unchecked) @constant.builtin) @markup.list.unchecked
|
(unchecked)) @markup.list.unchecked
|
||||||
|
|
||||||
(list_marker_task
|
(list_marker_task
|
||||||
(checked) @constant.builtin) @markup.list.checked
|
(checked)) @markup.list.checked
|
||||||
|
|
||||||
|
; Colorize `x` in `[x]`
|
||||||
|
((checked) @constant.builtin
|
||||||
|
(#offset! @constant.builtin 0 1 0 -1))
|
||||||
|
|
||||||
[
|
[
|
||||||
(ellipsis)
|
(ellipsis)
|
||||||
|
|
@ -97,94 +106,137 @@
|
||||||
(quotation_marks)
|
(quotation_marks)
|
||||||
] @string.special
|
] @string.special
|
||||||
|
|
||||||
|
(list_item
|
||||||
|
(term) @type.definition)
|
||||||
|
|
||||||
|
; Conceal { and } but leave " and '
|
||||||
|
((quotation_marks) @string.special
|
||||||
|
(#any-of? @string.special "\"}" "'}")
|
||||||
|
(#offset! @string.special 0 1 0 0)
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
((quotation_marks) @string.special
|
||||||
|
(#any-of? @string.special "\\\"" "\\'" "{'" "{\"")
|
||||||
|
(#offset! @string.special 0 0 0 -1)
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
[
|
||||||
|
(hard_line_break)
|
||||||
|
(backslash_escape)
|
||||||
|
] @string.escape
|
||||||
|
|
||||||
|
; Only conceal \ but leave escaped character.
|
||||||
|
((backslash_escape) @string.escape
|
||||||
|
(#offset! @string.escape 0 0 0 -1)
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(frontmatter_marker) @punctuation.delimiter
|
(frontmatter_marker) @punctuation.delimiter
|
||||||
|
|
||||||
(emphasis) @markup.italic
|
(emphasis) @markup.italic
|
||||||
|
|
||||||
(strong) @markup.strong
|
(strong) @markup.strong
|
||||||
|
|
||||||
(emphasis
|
(symbol) @string.special.symbol
|
||||||
(emphasis_begin) @punctuation.delimiter)
|
|
||||||
|
|
||||||
(emphasis
|
(insert) @markup.underline
|
||||||
(emphasis_end) @punctuation.delimiter)
|
|
||||||
|
|
||||||
(strong
|
(delete) @markup.strikethrough
|
||||||
(strong_begin) @punctuation.delimiter)
|
|
||||||
|
|
||||||
(strong
|
[
|
||||||
(strong_end) @punctuation.delimiter)
|
(highlighted)
|
||||||
|
(superscript)
|
||||||
|
(subscript)
|
||||||
|
] @string.special
|
||||||
|
|
||||||
|
; We need to target tokens specifically because `{=` etc can exist as fallback symbols in
|
||||||
|
; regular text, which we don't want to highlight or conceal.
|
||||||
(highlighted
|
(highlighted
|
||||||
[
|
[
|
||||||
"{="
|
"{="
|
||||||
"=}"
|
"=}"
|
||||||
] @punctuation.delimiter)
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(insert
|
(insert
|
||||||
[
|
[
|
||||||
"{+"
|
"{+"
|
||||||
"+}"
|
"+}"
|
||||||
] @punctuation.delimiter)
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(delete
|
(delete
|
||||||
[
|
[
|
||||||
"{-"
|
"{-"
|
||||||
"-}"
|
"-}"
|
||||||
] @punctuation.delimiter)
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(superscript
|
(superscript
|
||||||
[
|
[
|
||||||
"^"
|
"^"
|
||||||
"{^"
|
"{^"
|
||||||
"^}"
|
"^}"
|
||||||
] @punctuation.delimiter)
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(subscript
|
(subscript
|
||||||
[
|
[
|
||||||
"~"
|
"~"
|
||||||
"{~"
|
"{~"
|
||||||
"~}"
|
"~}"
|
||||||
] @punctuation.delimiter)
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(verbatim) @markup.raw
|
([
|
||||||
|
(emphasis_begin)
|
||||||
[
|
(emphasis_end)
|
||||||
|
(strong_begin)
|
||||||
|
(strong_end)
|
||||||
(verbatim_marker_begin)
|
(verbatim_marker_begin)
|
||||||
(verbatim_marker_end)
|
(verbatim_marker_end)
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
(math) @markup.math
|
|
||||||
|
|
||||||
[
|
|
||||||
(math_marker)
|
(math_marker)
|
||||||
(math_marker_begin)
|
(math_marker_begin)
|
||||||
(math_marker_end)
|
(math_marker_end)
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
(raw_inline) @markup.raw
|
|
||||||
|
|
||||||
[
|
|
||||||
(raw_inline_attribute)
|
(raw_inline_attribute)
|
||||||
(raw_inline_marker_begin)
|
(raw_inline_marker_begin)
|
||||||
(raw_inline_marker_end)
|
(raw_inline_marker_end)
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
((math) @markup.math
|
||||||
|
(#set! "priority" 90))
|
||||||
|
|
||||||
|
(verbatim) @markup.raw
|
||||||
|
|
||||||
|
((raw_inline) @markup.raw
|
||||||
|
(#set! "priority" 90))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
"%" @comment
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
(span
|
||||||
|
[
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(inline_attribute
|
||||||
|
[
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(block_attribute
|
||||||
|
[
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
[
|
[
|
||||||
"{"
|
(class)
|
||||||
"}"
|
(class_name)
|
||||||
"!["
|
] @type
|
||||||
"["
|
|
||||||
"]"
|
|
||||||
"("
|
|
||||||
")"
|
|
||||||
"<"
|
|
||||||
">"
|
|
||||||
] @punctuation.bracket
|
|
||||||
|
|
||||||
(comment) @comment
|
|
||||||
|
|
||||||
(class) @type
|
|
||||||
|
|
||||||
(identifier) @tag
|
(identifier) @tag
|
||||||
|
|
||||||
|
|
@ -197,10 +249,23 @@
|
||||||
(key_value
|
(key_value
|
||||||
(value) @string)
|
(value) @string)
|
||||||
|
|
||||||
[
|
(link_text
|
||||||
(backslash_escape)
|
[
|
||||||
(hard_line_break)
|
"["
|
||||||
] @string.escape
|
"]"
|
||||||
|
] @punctuation.bracket
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
(autolink
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
] @punctuation.bracket
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
(inline_link
|
||||||
|
(inline_link_destination) @markup.link.url
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(link_reference_definition
|
(link_reference_definition
|
||||||
":" @punctuation.special)
|
":" @punctuation.special)
|
||||||
|
|
@ -209,7 +274,19 @@
|
||||||
(link_text) @markup.link)
|
(link_text) @markup.link)
|
||||||
|
|
||||||
(full_reference_link
|
(full_reference_link
|
||||||
(link_label) @markup.link.label)
|
(link_label) @markup.link.label
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
(collapsed_reference_link
|
||||||
|
"[]" @punctuation.bracket
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
|
(full_reference_link
|
||||||
|
[
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket
|
||||||
|
(#set! conceal ""))
|
||||||
|
|
||||||
(collapsed_reference_link
|
(collapsed_reference_link
|
||||||
(link_text) @markup.link)
|
(link_text) @markup.link)
|
||||||
|
|
@ -223,11 +300,48 @@
|
||||||
(full_reference_image
|
(full_reference_image
|
||||||
(link_label) @markup.link.label)
|
(link_label) @markup.link.label)
|
||||||
|
|
||||||
(image_description) @markup.link.label
|
(full_reference_image
|
||||||
|
[
|
||||||
|
"!["
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(collapsed_reference_image
|
||||||
|
[
|
||||||
|
"!["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(inline_image
|
||||||
|
[
|
||||||
|
"!["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(image_description) @markup.italic
|
||||||
|
|
||||||
|
(image_description
|
||||||
|
[
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
|
(link_reference_definition
|
||||||
|
[
|
||||||
|
"["
|
||||||
|
"]"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
(link_reference_definition
|
(link_reference_definition
|
||||||
(link_label) @markup.link.label)
|
(link_label) @markup.link.label)
|
||||||
|
|
||||||
|
(inline_link_destination
|
||||||
|
[
|
||||||
|
"("
|
||||||
|
")"
|
||||||
|
] @punctuation.bracket)
|
||||||
|
|
||||||
[
|
[
|
||||||
(autolink)
|
(autolink)
|
||||||
(inline_link_destination)
|
(inline_link_destination)
|
||||||
|
|
@ -236,16 +350,22 @@
|
||||||
] @markup.link.url
|
] @markup.link.url
|
||||||
|
|
||||||
(footnote
|
(footnote
|
||||||
(reference_label) @markup.link)
|
(reference_label) @markup.link.label)
|
||||||
|
|
||||||
(footnote_reference
|
(footnote_reference
|
||||||
(reference_label) @markup.link)
|
(reference_label) @markup.link.label)
|
||||||
|
|
||||||
[
|
[
|
||||||
(footnote_marker_begin)
|
(footnote_marker_begin)
|
||||||
(footnote_marker_end)
|
(footnote_marker_end)
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(todo) @comment.todo
|
||||||
|
|
||||||
|
(note) @comment.note
|
||||||
|
|
||||||
|
(fixme) @comment.error
|
||||||
|
|
||||||
[
|
[
|
||||||
(paragraph)
|
(paragraph)
|
||||||
(comment)
|
(comment)
|
||||||
|
|
|
||||||
10
queries/djot/indents.scm
Normal file
10
queries/djot/indents.scm
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
; The intention here is to rely on Neovims `autoindent` setting.
|
||||||
|
; This allows us to not indent after just a single list item
|
||||||
|
; so we can create narrow lists quickly, but indent blocks inside list items
|
||||||
|
; to the previous paragraph.
|
||||||
|
(list_item_content) @indent.auto
|
||||||
|
|
||||||
|
(footnote_content) @indent.align
|
||||||
|
|
||||||
|
((table_caption) @indent.begin
|
||||||
|
(#set! indent.immediate 1))
|
||||||
17
queries/djot/locals.scm
Normal file
17
queries/djot/locals.scm
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
(link_reference_definition
|
||||||
|
(link_label) @local.definition)
|
||||||
|
|
||||||
|
(footnote
|
||||||
|
(reference_label) @local.definition)
|
||||||
|
|
||||||
|
(collapsed_reference_link
|
||||||
|
(link_text) @local.reference)
|
||||||
|
|
||||||
|
(full_reference_link
|
||||||
|
(link_label) @local.reference)
|
||||||
|
|
||||||
|
(full_reference_image
|
||||||
|
(link_label) @local.reference)
|
||||||
|
|
||||||
|
(footnote_reference
|
||||||
|
(reference_label) @local.reference)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue