Skip to content

Conversation

@klukaszek
Copy link

@klukaszek klukaszek commented Jan 24, 2026

Problem

I've recently been messing around with the Penrose diagramming language, but I've decided that I wanted to edit my files locally (with highlighting) without their proprietary editor, Vim, Sublime, or Emacs.

Solution

I've implemented a tree-sitter grammar with queries that seem to work with the majority of .style, .domain, and .substance files (verified on official Penrose examples).

These have been added to runtime/queries/penrose/ and languages.toml.

Future

I might consider attempting a simple LSP using tower, but for the time being this is enough for me and matches their proprietary editor.


.style

image

.domain

image

.substance

image

Thanks for the awesome editor!

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

From the CI it looks like the repo fails to clone on Windows somehow?

languages.toml Outdated

[[grammar]]
name = "penrose"
source = {git="https://github.com/klukaszek/tree-sitter-penrose/", rev="dedf9e775d086f8912c5282234cbaefed0c5f8dc"}
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a license file to the repo and update the rev here when it is included?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed it up! I honestly thought tree-sitter cli had already produced the license file because of the init process.

languages.toml Outdated

[[language]]
name = "penrose"
scope = "source.{domain, substance, style}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
scope = "source.{domain, substance, style}"
scope = "source.penrose"

This key is currently not used for anything. It's meant to be more about the language (name) rather than file extensions though

Copy link
Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Member

Choose a reason for hiding this comment

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

We use different captures for textobjects queries than Neovim, see https://docs.helix-editor.com/master/guides/textobject.html

Copy link
Author

Choose a reason for hiding this comment

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

Ah thank you! Should be fixed now. Same goes for below.

Copy link
Member

Choose a reason for hiding this comment

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

We also use different captures for highlighting, see https://docs.helix-editor.com/master/themes.html#syntax-highlighting

For example @number should be @constant.numeric, @boolean can be @constant.builtin.boolean, etc..

Copy link
Author

Choose a reason for hiding this comment

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

^^

…te Helix captures. Updated rev in languages.toml after adding a LICENSE to the tree-sitter-penrose repo.
@klukaszek
Copy link
Author

As for the Windows problem, it seems that the Penrose examples contained some SVG ZoneIdentifiers that should not have been there.

Should be resolved on next run.

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