Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

feat: improved TSHighlightCapturesUnderCursor #38

Merged
merged 3 commits into from
Apr 30, 2021

Conversation

folke
Copy link
Contributor

@folke folke commented Apr 18, 2021

Fixes #37

Added the following improvements:

  • use the active highlighter captures instead of reparsing the file:
  • uses all active treesitter queries. For a lua file for example, this will also include comment queries
  • active queries also includes any user queries
  • when the treesitter highlight module is not enabled in the buffer, we show the syntax highlight groups instead
  • prettier formatting of the popup window using a border and markdown
  • shows original and linked highlight groups

Treesitter Captures

image

Lua Comment Captures

image

Syntax Highlight Groups when treesitter highlight is disabled

image

Copy link
Member

@theHamsta theHamsta left a comment

Choose a reason for hiding this comment

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

Nice work! Using the highlighter directly will help a lot to show its bugs 😄 (btw there was no reparse before :parse does incremental parsing which will be NOOP when highlighting is used and the parsing result is already up-to-date)

Copy link
Member

@theHamsta theHamsta left a comment

Choose a reason for hiding this comment

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

@steelsojka could you have a look on this? You know more about the highlighter

@folke
Copy link
Contributor Author

folke commented Apr 29, 2021

Hi, sorry, was busy with another plugin :)

I actually based most of the code on the Treesitter highlighter in the Neovim runtime

@folke
Copy link
Contributor Author

folke commented Apr 29, 2021

Nice work! Using the highlighter directly will help a lot to show its bugs 😄 (btw there was no reparse before :parse does incremental parsing which will be NOOP when highlighting is used and the parsing result is already up-to-date)

right, good point. Wasn't aware of this 😄

@folke folke requested a review from theHamsta April 29, 2021 19:17
@theHamsta theHamsta merged commit 86d3ec6 into nvim-treesitter:master Apr 30, 2021
@theHamsta
Copy link
Member

Thanks for the contribution!

@folke
Copy link
Contributor Author

folke commented Apr 30, 2021

You're welcome and thank you for all the great work on the playground!

table.insert(lines, "# Treesitter")
matches = M.get_treesitter_hl()
else
table.insert(lines, "# Syntax")
Copy link
Member

Choose a reason for hiding this comment

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

One change that could maybe be done is to handle the the case where you have tree-sitter and set syntax st the same time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSHighlightCaptureUnderCursor improvements
2 participants