Skip to content

Add support for Rego String Interpolation - #19

Merged
FallenAngel97 merged 4 commits into
FallenAngel97:masterfrom
charlieegan3:string-interpolation
Jan 14, 2026
Merged

Add support for Rego String Interpolation#19
FallenAngel97 merged 4 commits into
FallenAngel97:masterfrom
charlieegan3:string-interpolation

Conversation

@charlieegan3

@charlieegan3 charlieegan3 commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Hello @FallenAngel97! In OPA 1.12 we released support for string interpolation (https://github.com/open-policy-agent/opa/releases/tag/v1.12.0).

This PR is my work to add this feature to tree-sitter-rego so we can support highlighting of this new syntax in editors using this library (I have been testing in the helix editor).

We have added support for this in various other places, e.g. open-policy-agent/vscode-opa#375

I have also taken some inspiration from the Rust tree-sitter implementation to modernise this project's structure too. Hope that's ok, please see the first commit for that work.

Let me know if you have any questions or comments 🙂

- Run tree-sitter init to generate modern bindings for various languages.
- Add ESLint configuration based on eslint-config-treesitter.
- Update Node version to v24.11.1 in .nvmrc
- Update README with npm commands, I have migrated to npm as it's what other
  similar projects seem to be using.

I have used https://github.com/tree-sitter/tree-sitter-rust/tree/master, as
an example for a number of the updates.
Implement string interpolation for both double-quoted and raw strings:
- $"{expr}" for double-quoted interpolated strings
- $`{expr}` for raw interpolated strings

Please see open-policy-agent/opa#8109 for the upstream
work on this same feature.

Other related merged PRs for other editors and projects:
- open-policy-agent/vscode-opa#375 (VS Code OPA ext)
- open-policy-agent/opa#8092 (OPA Docs)

@FallenAngel97 FallenAngel97 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hello @charlieegan3 !

Thank you for the PR.

I checked it locally, all good except of few minor things.

Comment thread .github/workflows/node.js.yml Outdated
Comment thread Package.swift
Comment thread README.md Outdated
@charlieegan3

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I will make the changes next week and get back to you then.

@charlieegan3

Copy link
Copy Markdown
Contributor Author

Hey, I have just updated this now, please see bc8b83c

@FallenAngel97

Copy link
Copy Markdown
Owner

Thank you, @charlieegan3 !

Merging

@FallenAngel97
FallenAngel97 merged commit ddd39af into FallenAngel97:master Jan 14, 2026
@charlieegan3
charlieegan3 deleted the string-interpolation branch January 15, 2026 10:08
@charlieegan3

Copy link
Copy Markdown
Contributor Author

Thanks @FallenAngel97 !

charlieegan3 added a commit to charlieegan3/nvim-treesitter that referenced this pull request Jan 15, 2026
We have released a new langauge feature for string interpolation and the
new grammar is available from this commit following PR
FallenAngel97/tree-sitter-rego#19
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