Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Djot support #12562

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

mmibbetson
Copy link

@mmibbetson mmibbetson commented Jan 16, 2025

This change adds support for the Djot markup language. The grammar used is tree-sitter-djot and the highlights & injections have been adapted for Helix's scopes.

There are 4 highlight queries with TEMP comments above them as they are semantically significant but I don't feel they have appropriate existing scopes.

In preparation for #9458 I will be maintaining a version with inverse precedence.

Closes #12264
Closes treeman/tree-sitter-djot#10

@mmibbetson
Copy link
Author

mmibbetson commented Jan 17, 2025

If it would make the reviewing process easier for someone who is unfamiliar with djot, here is an example file. I've had to change the extension to upload it to GitHub so it will need to be changed back to .dj to test the highlights.

Additionally, here are some screenshots demonstrating the highlights:

image

image

Copy link
Contributor

@zetashift zetashift left a comment

Choose a reason for hiding this comment

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

Glad to see this, as I enjoy using Djot as well!

I was waiting for treeman/tree-sitter-djot#55 to be merged before starting this PR, but this already looks great to me!

(key_value "=" @operator)

; NOTE: Not perfectly semantically accurate, but a fair approximation.
(identifier) @string.special.symbol
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm personally okay with variable or variable.other

Copy link
Author

@mmibbetson mmibbetson Jan 18, 2025

Choose a reason for hiding this comment

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

I tried a few things for identifiers and found that using more accurate scopes like type or attribute often made them indistinct from classes. Looking at variable and variable.other, there are a few themes where this looks nice but many of them have variables un-highlighted which kind of buries the identifiers by making them look like everything else.

My reasoning for using string.special.symbol was to at least emphasise the idea that there is only one instance of this thing 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

My reasoning for using string.special.symbol was to at least emphasise the idea that there is only one instance of this thing

Understandable! However usually themes set the variable to a color because of their own specific reasons, and it's always a toss-up if somebody prefers semantics over UX.
I don't have any strong preference here, I'm already glad this PR is up!

(quotation_marks) @markup.quote

; INFO: `term` only matches on definition list items -- other list items won't be highlighted.
(list_item (term) @type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this is quite nice, I'd say constructor makes sense for me here as well...but either LGTM.

Copy link
Author

Choose a reason for hiding this comment

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

I really like the idea of using constructor for this! I'll quickly make that edit to this PR now 😄

@kirawi kirawi added the A-language-support Area: Support for programming/text languages label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Djot Add support to the Helix editor
3 participants