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

feat(treesitter): follow upstream captures #630

Merged
merged 5 commits into from
Jan 19, 2024

Conversation

ofseed
Copy link
Contributor

@ofseed ofseed commented Dec 18, 2023

nvim-treesitter may be updated soon, still in discussion but it is planned, see nvim-treesitter/nvim-treesitter#4799 (comment). The purpose is to follow the treesitter common core to share queries, so some captures will be redefined.

I created this PR to follow upstream changes to avoid highlights break by the breaking change.

There are some highlights defined in treesitter common core but not mentioned in nvim-treesitter

  • @carriage-return
  • @comment.documentation
  • @embedded
  • @escape
  • @markup.link
  • @markup.quote
  • @property.builtin
  • @variable.member

And not sure all helix captures will be applied. This PR only follow the common core, need to continue to follow the implementation.

@wookayin
Copy link

For the legacy highlights, instead of setting a separate highlight, highlight link would be a better idea.

@ofseed
Copy link
Contributor Author

ofseed commented Dec 19, 2023

I think If the upstream does not do this, the downstream should not add it either, and for the legacy branch users, the highlights be linked to mean nothing because they should not exist yet.

For me recording a macro to assign again is simpler than linking them. :D

However, I will consider it carefully again before the PR gets merged.

@ofseed ofseed force-pushed the follow-treesitter branch 2 times, most recently from 421da4a to 06a04be Compare December 26, 2023 10:12
@ofseed
Copy link
Contributor Author

ofseed commented Dec 26, 2023

There are two extra highlight groups added:

  • @markup.list, to reduce abuse of @punctuation.special
  • @diff.delta, even not used in queries, I link it to diffChanged like the convention

One highlights group was split:

  • @text.uri is now @markup.link.uri in markup links and @string.special.url outside of markup. I assigned the value of @text.uri to @markup.link.url.

@lucario387
Copy link

lucario387 commented Dec 27, 2023

Updates here :)
@text.reference -> @markup.link and @field -> @variable.member, @markup.quote is now also added

Edit:
@comment.documentation is not mentioned because it's been supported for 6 to 8 months now 😄, so no need to convert/align with other consumers once again, when it's done in nvim-treesitter the same time as tree-sitter upstream.

@ofseed ofseed marked this pull request as ready for review January 2, 2024 05:05
@ofseed
Copy link
Contributor Author

ofseed commented Jan 2, 2024

The refactor is merged into nvim-treesitter experimental branch main. I followed it up and it is ready to merge now.

@ofseed
Copy link
Contributor Author

ofseed commented Jan 2, 2024

Some of the plugins I often use rely on the nvim-treesitter module system, so I cannot use this branch in daily use, it may need some review.

@lucario387
Copy link

nvim-treesitter/nvim-treesitter#5895 is the PR that will backport the changes to master. So you can test it there.

@ofseed
Copy link
Contributor Author

ofseed commented Jan 19, 2024

LGTM.

["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
["comment.error"] = { fg = C.base, bg = C.red },
["comment.warning"] = { fg = C.base, bg = C.yellow },
["comment.note"] = { fg = C.base, bg = C.blue },

Choose a reason for hiding this comment

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

missing comment.todo. Also they should be @comment.*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The former @text.todo has two different meanings,

  • one for todo in comments, now @comment.warning
  • one for todo lists, now @markup.list.checked/@markup.list.unchecked

So the comment.todo is a new capture, I think it's better not to add new highlights for now, especially since this highlight hasn't been utilized.(it's not exists in nvim-treesitter now)

Copy link

@lucario387 lucario387 Jan 19, 2024

Choose a reason for hiding this comment

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

It is used though. text.todo in comments is replaced with comment.todo. As of now it's current a subset of the old text.todo, so it should get some highlighting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Continue on #645

@nullchilly nullchilly merged commit f288876 into catppuccin:main Jan 19, 2024
9 checks passed
@nullchilly
Copy link
Contributor

Thank you so much for the PR!

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.

4 participants