Go tags grammar for tree-sitter, should match https://cs.opensource.google/go/go/+/refs/tags/go1.24.1:src/reflect/type.go;l=1036
As an alternative (if you only would like to have syntax highlighting and do not care about the tree structure), you could do this:
(field_declaration
tag: (raw_string_literal
(raw_string_literal_content) @injection.content
(#set! injection.self)
))
- Put this in your
nvim-treesitter
config
function
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
parser_config.go_tags = {
install_info = {
url = 'https://github.com/DanWlker/tree-sitter-go_tags',
files = { 'src/parser.c' },
branch = 'main',
},
}
- run
TSInstall go_tags
-
Copy the contents of
queries/highlights.scm
from this repo into<your nvim config folder>/queries/go_tags/highlights.scm
to enable syntax highlighting (if anyone knows a better way do let me know) -
To allow for injections into go struct tags, Add this to your
queries/go/injections.scm
(field_declaration
tag: (raw_string_literal
(raw_string_literal_content) @injection.content
(#set! injection.language "go_tags")
))