add gotmpl matchup queries#446
Open
dpezto wants to merge 1 commit into
Open
Conversation
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 "{{-".
There was a problem hiding this comment.
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.scmwith scope + open/mid/close captures for gotmpl control structures. - Implements an anchored
if_actionopener match to avoid treating theifin{{ else if }}as a new opener. - Adds
continue/breakas mid targets withinrangeblocks.
💡 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onifkeeps theifinside{{ else if }}from being captured as an opener.Tested with nvim-treesitter's gotmpl parser on chezmoi templates.