aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/djot
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/djot
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/djot')
-rw-r--r--runtime/queries/djot/folds.scm7
-rw-r--r--runtime/queries/djot/highlights.scm372
-rw-r--r--runtime/queries/djot/indents.scm10
-rw-r--r--runtime/queries/djot/injections.scm24
-rw-r--r--runtime/queries/djot/locals.scm17
5 files changed, 430 insertions, 0 deletions
diff --git a/runtime/queries/djot/folds.scm b/runtime/queries/djot/folds.scm
new file mode 100644
index 000000000..94f3724eb
--- /dev/null
+++ b/runtime/queries/djot/folds.scm
@@ -0,0 +1,7 @@
+[
+ (section)
+ (code_block)
+ (raw_block)
+ (list)
+ (div)
+] @fold
diff --git a/runtime/queries/djot/highlights.scm b/runtime/queries/djot/highlights.scm
new file mode 100644
index 000000000..73dd66057
--- /dev/null
+++ b/runtime/queries/djot/highlights.scm
@@ -0,0 +1,372 @@
+(heading) @markup.heading
+
+((heading
+ (marker) @_heading.marker) @markup.heading.1
+ (#eq? @_heading.marker "# "))
+
+((heading
+ (marker) @_heading.marker) @markup.heading.2
+ (#eq? @_heading.marker "## "))
+
+((heading
+ (marker) @_heading.marker) @markup.heading.3
+ (#eq? @_heading.marker "### "))
+
+((heading
+ (marker) @_heading.marker) @markup.heading.4
+ (#eq? @_heading.marker "##### "))
+
+((heading
+ (marker) @_heading.marker) @markup.heading.5
+ (#eq? @_heading.marker "###### "))
+
+((heading
+ (marker) @_heading.marker) @markup.heading.6
+ (#eq? @_heading.marker "####### "))
+
+(thematic_break) @string.special
+
+[
+ (div_marker_begin)
+ (div_marker_end)
+] @punctuation.delimiter
+
+([
+ (code_block)
+ (raw_block)
+ (frontmatter)
+] @markup.raw.block
+ (#set! priority 90))
+
+; Remove @markup.raw for code with a language spec
+(code_block
+ .
+ (code_block_marker_begin)
+ (language)
+ (code) @none
+ (#set! priority 90))
+
+[
+ (code_block_marker_begin)
+ (code_block_marker_end)
+ (raw_block_marker_begin)
+ (raw_block_marker_end)
+] @punctuation.delimiter
+
+(language) @attribute
+
+(inline_attribute
+ _ @conceal
+ (#set! conceal ""))
+
+((language_marker) @punctuation.delimiter
+ (#set! conceal ""))
+
+(block_quote) @markup.quote
+
+(block_quote_marker) @punctuation.special
+
+(table_header) @markup.heading
+
+(table_header
+ "|" @punctuation.special)
+
+(table_row
+ "|" @punctuation.special)
+
+(table_separator) @punctuation.special
+
+(table_caption
+ (marker) @punctuation.special)
+
+(table_caption) @markup.italic
+
+[
+ (list_marker_dash)
+ (list_marker_plus)
+ (list_marker_star)
+ (list_marker_definition)
+ (list_marker_decimal_period)
+ (list_marker_decimal_paren)
+ (list_marker_decimal_parens)
+ (list_marker_lower_alpha_period)
+ (list_marker_lower_alpha_paren)
+ (list_marker_lower_alpha_parens)
+ (list_marker_upper_alpha_period)
+ (list_marker_upper_alpha_paren)
+ (list_marker_upper_alpha_parens)
+ (list_marker_lower_roman_period)
+ (list_marker_lower_roman_paren)
+ (list_marker_lower_roman_parens)
+ (list_marker_upper_roman_period)
+ (list_marker_upper_roman_paren)
+ (list_marker_upper_roman_parens)
+] @markup.list
+
+(list_marker_task
+ (unchecked)) @markup.list.unchecked
+
+(list_marker_task
+ (checked)) @markup.list.checked
+
+; Colorize `x` in `[x]`
+((checked) @constant.builtin
+ (#offset! @constant.builtin 0 1 0 -1))
+
+[
+ (ellipsis)
+ (en_dash)
+ (em_dash)
+ (quotation_marks)
+] @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
+
+(emphasis) @markup.italic
+
+(strong) @markup.strong
+
+(symbol) @string.special.symbol
+
+(insert) @markup.underline
+
+(delete) @markup.strikethrough
+
+[
+ (highlighted)
+ (superscript)
+ (subscript)
+] @string.special
+
+([
+ (emphasis_begin)
+ (emphasis_end)
+ (strong_begin)
+ (strong_end)
+ (superscript_begin)
+ (superscript_end)
+ (subscript_begin)
+ (subscript_end)
+ (highlighted_begin)
+ (highlighted_end)
+ (insert_begin)
+ (insert_end)
+ (delete_begin)
+ (delete_end)
+ (verbatim_marker_begin)
+ (verbatim_marker_end)
+ (math_marker)
+ (math_marker_begin)
+ (math_marker_end)
+ (raw_inline_attribute)
+ (raw_inline_marker_begin)
+ (raw_inline_marker_end)
+] @punctuation.delimiter
+ (#set! conceal ""))
+
+((math) @markup.math
+ (#set! priority 90))
+
+(verbatim) @markup.raw
+
+((raw_inline) @markup.raw
+ (#set! priority 90))
+
+[
+ (comment)
+ (inline_comment)
+] @comment
+
+(span
+ [
+ "["
+ "]"
+ ] @punctuation.bracket)
+
+(inline_attribute
+ [
+ "{"
+ "}"
+ ] @punctuation.bracket)
+
+(block_attribute
+ [
+ "{"
+ "}"
+ ] @punctuation.bracket)
+
+[
+ (class)
+ (class_name)
+] @type
+
+(identifier) @tag
+
+(key_value
+ "=" @operator)
+
+(key_value
+ (key) @property)
+
+(key_value
+ (value) @string)
+
+(link_text
+ [
+ "["
+ "]"
+ ] @punctuation.bracket
+ (#set! conceal ""))
+
+(autolink
+ [
+ "<"
+ ">"
+ ] @punctuation.bracket
+ (#set! conceal ""))
+
+(inline_link
+ (inline_link_destination) @markup.link.url
+ (#set! conceal ""))
+
+(link_reference_definition
+ ":" @punctuation.special)
+
+(full_reference_link
+ (link_text) @markup.link)
+
+(full_reference_link
+ (link_label) @markup.link.label
+ (#set! conceal ""))
+
+(collapsed_reference_link
+ "[]" @punctuation.bracket
+ (#set! conceal ""))
+
+(full_reference_link
+ [
+ "["
+ "]"
+ ] @punctuation.bracket
+ (#set! conceal ""))
+
+(collapsed_reference_link
+ (link_text) @markup.link)
+
+(collapsed_reference_link
+ (link_text) @markup.link.label)
+
+(inline_link
+ (link_text) @markup.link)
+
+(full_reference_image
+ (link_label) @markup.link.label)
+
+(full_reference_image
+ [
+ "["
+ "]"
+ ] @punctuation.bracket)
+
+(collapsed_reference_image
+ "[]" @punctuation.bracket)
+
+(image_description
+ [
+ "!["
+ "]"
+ ] @punctuation.bracket)
+
+(image_description) @markup.italic
+
+(link_reference_definition
+ [
+ "["
+ "]"
+ ] @punctuation.bracket)
+
+(link_reference_definition
+ (link_label) @markup.link.label)
+
+(inline_link_destination
+ [
+ "("
+ ")"
+ ] @punctuation.bracket)
+
+[
+ (autolink)
+ (inline_link_destination)
+ (link_destination)
+ (link_reference_definition)
+] @markup.link.url
+
+(footnote
+ (reference_label) @markup.link.label)
+
+(footnote_reference
+ (reference_label) @markup.link.label)
+
+[
+ (footnote_marker_begin)
+ (footnote_marker_end)
+] @punctuation.bracket
+
+(todo) @comment.todo
+
+(note) @comment.note
+
+(fixme) @comment.error
+
+[
+ (paragraph)
+ (comment)
+ (table_cell)
+] @spell
+
+[
+ (autolink)
+ (inline_link_destination)
+ (link_destination)
+ (code_block)
+ (raw_block)
+ (math)
+ (raw_inline)
+ (verbatim)
+ (reference_label)
+ (class)
+ (class_name)
+ (identifier)
+ (key_value)
+ (frontmatter)
+] @nospell
+
+(full_reference_link
+ (link_label) @nospell)
+
+(full_reference_image
+ (link_label) @nospell)
diff --git a/runtime/queries/djot/indents.scm b/runtime/queries/djot/indents.scm
new file mode 100644
index 000000000..3b1a56ebd
--- /dev/null
+++ b/runtime/queries/djot/indents.scm
@@ -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))
diff --git a/runtime/queries/djot/injections.scm b/runtime/queries/djot/injections.scm
new file mode 100644
index 000000000..0e4141046
--- /dev/null
+++ b/runtime/queries/djot/injections.scm
@@ -0,0 +1,24 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+(math
+ (content) @injection.content
+ (#set! injection.language "latex"))
+
+(code_block
+ (language) @injection.language
+ (code) @injection.content)
+
+(raw_block
+ (raw_block_info
+ (language) @injection.language)
+ (content) @injection.content)
+
+(raw_inline
+ (content) @injection.content
+ (raw_inline_attribute
+ (language) @injection.language))
+
+(frontmatter
+ (language) @injection.language
+ (frontmatter_content) @injection.content)
diff --git a/runtime/queries/djot/locals.scm b/runtime/queries/djot/locals.scm
new file mode 100644
index 000000000..1ac27529f
--- /dev/null
+++ b/runtime/queries/djot/locals.scm
@@ -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)