Skip to content

add gotmpl matchup queries#446

Open
dpezto wants to merge 1 commit into
andymass:masterfrom
dpezto:feat/gotmpl-queries
Open

add gotmpl matchup queries#446
dpezto wants to merge 1 commit into
andymass:masterfrom
dpezto:feat/gotmpl-queries

Conversation

@dpezto

@dpezto dpezto commented Jul 21, 2026

Copy link
Copy Markdown

Adds matchup queries for Go templates (gotmpl): if/else/end, range (+ continue/break as mids), with, block, define.

Both {{ and the trim marker {{- are listed since they're distinct tokens in the grammar; chezmoi and helm templates use {{- heavily. The anchor on if keeps the if inside {{ else if }} from being captured as an opener.

Tested with nvim-treesitter's gotmpl parser on chezmoi templates.

Adds tree-sitter matchup queries for Go templates (gotmpl):
if/else/end, range/else/end (with continue/break as mids),
with/else/end, block/end, and define/end.

Both "{{" and the whitespace-trim marker "{{-" are listed since
they are distinct grammar tokens; templates written for chezmoi and
helm commonly use "{{-".
Copilot AI review requested due to automatic review settings July 21, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds tree-sitter matchup queries for the gotmpl (Go templates) parser so vim-matchup can navigate template block structures (if/range/with/block/define) using @open/@mid/@close captures, including support for {{- trim-marker delimiters and handling else if in if blocks.

Changes:

  • Introduces after/queries/gotmpl/matchup.scm with scope + open/mid/close captures for gotmpl control structures.
  • Implements an anchored if_action opener match to avoid treating the if in {{ else if }} as a new opener.
  • Adds continue/break as mid targets within range blocks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +31
(continue_action
"continue" @mid.range.2)

(break_action
"break" @mid.range.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants