diff --git a/doc/tags b/doc/tags index 61767e4..f84bd12 100644 --- a/doc/tags +++ b/doc/tags @@ -1,3 +1,11 @@ -QuartoPreview quarto.txt /*QuartoPreview* -quarto.nvim quarto.txt /*quarto.nvim* -quarto.quartoPreview() quarto.txt /*quarto.quartoPreview()* +quarto-links quarto.txt /*quarto-links* +quarto-quarto-nvim quarto.txt /*quarto-quarto-nvim* +quarto-quarto-nvim-available-commands quarto.txt /*quarto-quarto-nvim-available-commands* +quarto-quarto-nvim-language-support quarto.txt /*quarto-quarto-nvim-language-support* +quarto-quarto-nvim-recommended-plugins quarto.txt /*quarto-quarto-nvim-recommended-plugins* +quarto-quarto-nvim-running-code quarto.txt /*quarto-quarto-nvim-running-code* +quarto-quarto-nvim-setup quarto.txt /*quarto-quarto-nvim-setup* +quarto-quarto-nvim-usage quarto.txt /*quarto-quarto-nvim-usage* +quarto-quarto-nvim-walkthrough quarto.txt /*quarto-quarto-nvim-walkthrough* +quarto-table-of-contents quarto.txt /*quarto-table-of-contents* +quarto.txt quarto.txt /*quarto.txt* diff --git a/ftplugin/quarto.lua b/ftplugin/quarto.lua index 4cd21f3..d57e702 100644 --- a/ftplugin/quarto.lua +++ b/ftplugin/quarto.lua @@ -2,7 +2,9 @@ vim.b.slime_cell_delimiter = '```' -- TODO: Workaround while nvim-treesitter doesn't link those anymore -- until our ouwn pandoc grammar is ready -vim.treesitter.language.register("markdown", { "quarto", "rmd" }) +-- vim.treesitter.language.register("markdown", { "quarto", "rmd" }) + +vim.bo.commentstring = "" local config = require('quarto.config').config local quarto = require 'quarto' diff --git a/queries/pandoc_markdown/folds.scm b/queries/pandoc_markdown/folds.scm new file mode 100644 index 0000000..a682e20 --- /dev/null +++ b/queries/pandoc_markdown/folds.scm @@ -0,0 +1,7 @@ +([ + (fenced_code_block) + (indented_code_block) + (list) + (section) +] @fold + (#trim! @fold)) diff --git a/queries/pandoc_markdown/highlights.scm b/queries/pandoc_markdown/highlights.scm new file mode 100644 index 0000000..a12669c --- /dev/null +++ b/queries/pandoc_markdown/highlights.scm @@ -0,0 +1,121 @@ +;From MDeiml/tree-sitter-markdown & Helix +(setext_heading + (paragraph) @markup.heading.1 + (setext_h1_underline) @markup.heading.1) + +(setext_heading + (paragraph) @markup.heading.2 + (setext_h2_underline) @markup.heading.2) + +(atx_heading + (atx_h1_marker)) @markup.heading.1 + +(atx_heading + (atx_h2_marker)) @markup.heading.2 + +(atx_heading + (atx_h3_marker)) @markup.heading.3 + +(atx_heading + (atx_h4_marker)) @markup.heading.4 + +(atx_heading + (atx_h5_marker)) @markup.heading.5 + +(atx_heading + (atx_h6_marker)) @markup.heading.6 + +(info_string) @label + +(pipe_table_header + (pipe_table_cell) @markup.heading) + +(pipe_table_header + "|" @punctuation.special) + +(pipe_table_row + "|" @punctuation.special) + +(pipe_table_delimiter_row + "|" @punctuation.special) + +(pipe_table_delimiter_cell) @punctuation.special + +; Code blocks (conceal backticks and language annotation) +(indented_code_block) @markup.raw.block + +((fenced_code_block) @markup.raw.block + (#set! priority 90)) + +(fenced_code_block + (fenced_code_block_delimiter) @markup.raw.block + (#set! conceal "")) + +(fenced_code_block + (info_string + (language) @label + (#set! conceal ""))) + +(link_destination) @markup.link.url + +[ + (link_title) + (link_label) +] @markup.link.label + +((link_label) + . + ":" @punctuation.delimiter) + +[ + (list_marker_plus) + (list_marker_minus) + (list_marker_star) + (list_marker_dot) + (list_marker_parenthesis) +] @markup.list + +; NOTE: The following has been commented out due to issues with spaces in the +; list marker nodes generated by the parser. If those spaces ever get captured +; by a different node (e.g. block_continuation) we can safely re-add these +; conceals. +; ;; Conceal bullet points +; ([(list_marker_plus) (list_marker_star)] +; @punctuation.special +; (#offset! @punctuation.special 0 0 0 -1) +; (#set! conceal "•")) +; ([(list_marker_plus) (list_marker_star)] +; @punctuation.special +; (#any-of? @punctuation.special "+" "*") +; (#set! conceal "•")) +; ((list_marker_minus) +; @punctuation.special +; (#offset! @punctuation.special 0 0 0 -1) +; (#set! conceal "—")) +; ((list_marker_minus) +; @punctuation.special +; (#eq? @punctuation.special "-") +; (#set! conceal "—")) +(thematic_break) @punctuation.special + +(task_list_marker_unchecked) @markup.list.unchecked + +(task_list_marker_checked) @markup.list.checked + +((block_quote) @markup.quote + (#set! priority 90)) + +([ + (plus_metadata) + (minus_metadata) +] @keyword.directive + (#set! priority 90)) + +[ + (block_continuation) + (block_quote_marker) +] @punctuation.special + +(backslash_escape) @string.escape + +(inline) @spell diff --git a/queries/pandoc_markdown/indents.scm b/queries/pandoc_markdown/indents.scm new file mode 100644 index 0000000..90c52d3 --- /dev/null +++ b/queries/pandoc_markdown/indents.scm @@ -0,0 +1 @@ +(list_item) @indent.auto diff --git a/queries/pandoc_markdown/injections.scm b/queries/pandoc_markdown/injections.scm new file mode 100644 index 0000000..283bedd --- /dev/null +++ b/queries/pandoc_markdown/injections.scm @@ -0,0 +1,26 @@ +(fenced_code_block + (info_string + (language) @_lang) + (code_fence_content) @injection.content + (#set-lang-from-info-string! @_lang)) + +((html_block) @injection.content + (#set! injection.language "html") + (#set! injection.combined) + (#set! injection.include-children)) + +((minus_metadata) @injection.content + (#set! injection.language "yaml") + (#offset! @injection.content 1 0 -1 0) + (#set! injection.include-children)) + +((plus_metadata) @injection.content + (#set! injection.language "toml") + (#offset! @injection.content 1 0 -1 0) + (#set! injection.include-children)) + +([ + (inline) + (pipe_table_cell) +] @injection.content + (#set! injection.language "pandoc_markdown_inline")) diff --git a/queries/pandoc_markdown/textobjects.scm b/queries/pandoc_markdown/textobjects.scm new file mode 100644 index 0000000..7b441d5 --- /dev/null +++ b/queries/pandoc_markdown/textobjects.scm @@ -0,0 +1,20 @@ +; extends +; (atx_heading +; heading_content: (_) @class.inner) @class.outer +; +; (setext_heading +; heading_content: (_) @class.inner) @class.outer +; +; (thematic_break) @class.outer + + +(fenced_code_block (code_fence_content) @class.inner) @class.outer + +(paragraph) @function.outer @function.inner + +(fenced_code_block (code_fence_content) @block.inner) @block.outer + +[ + (paragraph) + (list) +] @block.outer diff --git a/queries/pandoc_markdown_inline/highlights.scm b/queries/pandoc_markdown_inline/highlights.scm new file mode 100644 index 0000000..68d75d5 --- /dev/null +++ b/queries/pandoc_markdown_inline/highlights.scm @@ -0,0 +1,132 @@ +; From MDeiml/tree-sitter-markdown +(code_span) @markup.raw @nospell + +(emphasis) @markup.italic + +(strong_emphasis) @markup.strong + +(strikethrough) @markup.strikethrough + +(shortcut_link + (link_text) @nospell) + +[ + (backslash_escape) + (hard_line_break) +] @string.escape + +; Conceal codeblock and text style markers +([ + (code_span_delimiter) + (emphasis_delimiter) +] @conceal + (#set! conceal "")) + +; Conceal inline links +(inline_link + [ + "[" + "]" + "(" + (link_destination) + ")" + ] @markup.link + (#set! conceal "")) + +[ + (link_label) + (link_text) + (link_title) + (image_description) +] @markup.link.label + +((inline_link + (link_destination) @_url) @_label + (#set! @_label url @_url)) + +((image + (link_destination) @_url) @_label + (#set! @_label url @_url)) + +; Conceal image links +(image + [ + "!" + "[" + "]" + "(" + (link_destination) + ")" + ] @markup.link + (#set! conceal "")) + +; Conceal full reference links +(full_reference_link + [ + "[" + "]" + (link_label) + ] @markup.link + (#set! conceal "")) + +; Conceal collapsed reference links +(collapsed_reference_link + [ + "[" + "]" + ] @markup.link + (#set! conceal "")) + +; Conceal shortcut links +(shortcut_link + [ + "[" + "]" + ] @markup.link + (#set! conceal "")) + +[ + (link_destination) + (uri_autolink) + (email_autolink) +] @markup.link.url @nospell + +((uri_autolink) @_url + (#offset! @_url 0 1 0 -1) + (#set! @_url url @_url)) + +(entity_reference) @nospell + +; Replace common HTML entities. +((entity_reference) @character.special + (#eq? @character.special " ") + (#set! conceal " ")) + +((entity_reference) @character.special + (#eq? @character.special "<") + (#set! conceal "<")) + +((entity_reference) @character.special + (#eq? @character.special ">") + (#set! conceal ">")) + +((entity_reference) @character.special + (#eq? @character.special "&") + (#set! conceal "&")) + +((entity_reference) @character.special + (#eq? @character.special """) + (#set! conceal "\"")) + +((entity_reference) @character.special + (#any-of? @character.special " " " ") + (#set! conceal " ")) + + +(strikethrough +(emphasis_delimiter) +(strikethrough + (emphasis_delimiter) + (emphasis_delimiter)) +(emphasis_delimiter))@markup.doublestrikethrough + diff --git a/queries/pandoc_markdown_inline/injections.scm b/queries/pandoc_markdown_inline/injections.scm new file mode 100644 index 0000000..6448b77 --- /dev/null +++ b/queries/pandoc_markdown_inline/injections.scm @@ -0,0 +1,7 @@ +((html_tag) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +((latex_block) @injection.content + (#set! injection.language "latex") + (#set! injection.include-children))