From a262aab7be5e78f059185c0fdb43ebf1e8bcde60 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 04 Jul 2026 20:20:59 +0000 Subject: [PATCH] Add language support for Doxygen Co-authored-by: Marian Buschsieweke <2041729+maribu@users.noreply.github.com> --- languages.toml | 14 ++++++++++++++ book/src/generated/lang-support.md | 1 + runtime/queries/c/injections.scm | 12 ++++++++++++ runtime/queries/doxygen/highlights.scm | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ runtime/queries/doxygen/injections.scm | 9 +++++++++ 5 file(s) changed, 89 insertion(s)(+), 0 deletion(s)(-) diff --git a/languages.toml b/languages.toml --- a/languages.toml +++ b/languages.toml @@ -5648,3 +5648,17 @@ name = "batch" source = { git = "https://github.com/wharflab/tree-sitter-batch", rev = "5fc5f54267ef9a78e7a5319b80e092194252aabf" } +[[language]] +name = "doxygen" +scope = "source.doxygen" +injection-regex = "doxygen" +file-types = [ + "doxygen", + "dox", + { glob = "doc.md" }, +] +indent = { tab-width = 4, unit = " " } + +[[grammar]] +name = "doxygen" +source = { git = "https://codeberg.org/maribu/tree-sitter-doxygen", rev = "26afdde765b43dc42d2c90172c238a64a93cd53caff9adce795a0e2127f4bfc9" } diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -57,6 +57,7 @@ | dockerfile | ✓ | ✓ | | | | `docker-langserver`, `docker-language-server` | | dot | ✓ | | | | | `dot-language-server` | | doxyfile | ✓ | ✓ | ✓ | ✓ | | | +| doxygen | ✓ | | | | | | | drools | | | | | | `drools-lsp` | | dtd | ✓ | | | | | | | dune | ✓ | | | | | | diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm --- a/runtime/queries/c/injections.scm +++ b/runtime/queries/c/injections.scm @@ -4,3 +4,15 @@ ((preproc_arg) @injection.content (#set! injection.language "c") (#set! injection.include-children)) + +; Comments starting with `///`, `//!` are C++ style Doxygen comments, but +; comments starting with `////` are not. +((comment) @injection.content + (#match? @injection.content "^[\t ]*(//!|///[^/])") + (#set! injection.language "doxygen")) + +; Comments starting with `/**`, `/*!` are C style Doxygen, but comments +; starting with `/***` are not. +((comment) @injection.content + (#match? @injection.content "^[\t ]*(/\\*(!|\\*($|[^*])))") + (#set! injection.language "doxygen")) diff --git a/runtime/queries/doxygen/highlights.scm b/runtime/queries/doxygen/highlights.scm new file mode 100644 --- /dev/null +++ b/runtime/queries/doxygen/highlights.scm @@ -0,0 +1,53 @@ +; block commands +(block_command + command: _ @keyword) +(block_command + ["@" "\\"] @keyword ) +(block_command + (parameter) @variable.parameter) +(block_command + (description (content) @string)) + +; inline commands +(inline_command + command: _ @keyword) +(inline_command + ["@" "\\"] @keyword ) +(inline_command + (parameter) @variable.parameter) + +; @param command +(param_attribute) @keyword.storage + +; markdown +(header) @markup.heading +(link) @markup.link.text +(link + (link_uri) @markup.link.url) +(link + (link_ref) @markup.link.url) +(email) @markup.link.url + +; styling +(bold) @markup.bold +(inline_command command: "b" + (_) @markup.bold) +(italic) @markup.italic +(inline_command command: ["e" "em" "a"] + (_) @markup.italic) +(code) @markup.raw.inline +(inline_command command: "c" + (_) @markup.raw.inline) +(code_block + (code_line) @markup.raw.block) + +; let important commands stick out +(block_command + command: _ @_cmd @keyword + (description (content) @warning) + (#any-of? @_cmd "warning" "note")) + +(block_command + command: _ @_cmd @keyword + (description (content) @markup.heading) + (#any-of? @_cmd "brief")) diff --git a/runtime/queries/doxygen/injections.scm b/runtime/queries/doxygen/injections.scm new file mode 100644 --- /dev/null +++ b/runtime/queries/doxygen/injections.scm @@ -0,0 +1,9 @@ +(markdown + (markdown_line) @injection.content + (#set! injection.language "markdown") + (#set! injection.combined)) + +(code_block + (code_language) @injection.language + (code_line) @injection.content + (#set! injection.combined)) -- tangled.sh