From 0d799235f693f0ab4e7b6d21a8b1f99881bb7166 Mon Sep 17 00:00:00 2001 From: Nik Revenco Date: Mon, 23 Jun 2025 20:03:30 +0100 Subject: [PATCH] feat: Inject markdown into Go's block documentation comments more chore: capture unlimited number of comments Each commen --- runtime/queries/go/injections.scm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/runtime/queries/go/injections.scm b/runtime/queries/go/injections.scm index d7b03da35..48dfae369 100644 --- a/runtime/queries/go/injections.scm +++ b/runtime/queries/go/injections.scm @@ -1,6 +1,33 @@ ((comment) @injection.content (#set! injection.language "comment")) +; Inject markdown into documentation comments +; +; Go's comments are documentation comments when they are directly followed +; by one of Go's statements (e.g. `type`, `func`, `const`) +; +; This is only a partial implementation, which covers only +; block comments. For line comments (which are more common), +; upstream changes to the grammar are required. +( + (comment) @injection.content . (comment)* . [ + (package_clause) ; `package` + (type_declaration) ; `type` + (method_declaration) ; `func` + (var_declaration) ; `var` + (const_declaration) ; `const` + ; var ( + ; A = 1 + ; B = 2 + ; ) + (const_spec) + ; const ( + ; A = 1 + ; B = 2 + ; ) + (var_spec) + ] + (#set! injection.language "markdown")) (call_expression (selector_expression) @_function