tree-sitter-godoc

November 2, 2025 ยท View on GitHub

This parser...

  • identifies structural regions in godoc output so to efficiently delegate Go syntax highlighting to the tree-sitter-go parser via tree-sitter query injections.
  • is designed to work with godoc.nvim.

Quickstart for Neovim users

Using nvim-treesitter (main branch)

  1. Configure how to install the godoc parser:
require('nvim-treesitter.parsers').godoc = {
  install_info = {
    url = "https://github.com/fredrikaverpil/tree-sitter-godoc",
    files = {"src/parser.c"},
    branch = "main",
  },
  filetype = "godoc",
}
  1. Install parsers via TSInstall:
:TSInstall godoc go
  1. Copy queries into Neovim configuration:
cp queries/*.csm ~/.config/nvim/after/queries/godoc/

Development

Prerequisites

Building

# Generate the parser from grammar.js
tree-sitter generate

# Test the grammar
tree-sitter test

# Build the parser
tree-sitter build

Testing with playground

tree-sitter playground

Then paste some go doc output to see how it's parsed.

Contributing

Contributions welcome! Please open an issue or PR.