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: new :tree-sitter-tree command #12207

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

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Dec 6, 2024

Using % to select entire file and then using :tree-sitter-subtree which opens in a tiny window makes it difficult to inspect the entire tree.

This PR adds a new command, :tree-sitter-tree

This command displays the entire tree sitter tree and updates it live as you type. Additionally, it highlights syntax nodes

image

Closes #12149

@nik-rev nik-rev changed the title feat: :tree-sitter-tree command feat: new :tree-sitter-tree command Dec 6, 2024
@uncenter
Copy link
Contributor

uncenter commented Dec 6, 2024

For now - as the panel doesn't auto update - would it be possible for subsequent :ts-tree invocations to replace the existing (if it still exists) ts-tree buffer instead of creating a new one?

@nik-rev
Copy link
Contributor Author

nik-rev commented Dec 6, 2024

For now - as the panel doesn't auto update - would it be possible for subsequent :ts-tree invocations to replace the existing (if it still exists) ts-tree buffer instead of creating a new one?

Ok, I just pushed a commit. it will replace the existing buffer now.

@uncenter
Copy link
Contributor

uncenter commented Dec 6, 2024

And is it possible to prevent writing to the syntax tree buffer? Nvim's impl prevents modifying it, and I think especially now that we replace the buffer with a new one we should expect users not to edit it - and enforce that.

@nik-rev
Copy link
Contributor Author

nik-rev commented Dec 6, 2024

And is it possible to prevent writing to the syntax tree buffer? Nvim's impl prevents modifying it, and I think especially now that we replace the buffer with a new one we should expect users not to edit it - and enforce that.

It's not possible to make a file unwritable from what I can tell (readonly will still allow editing, but not saving).

See also this comment by @the-mikedavis : #7128 (comment)

uncenter added a commit to uncenter/helix that referenced this pull request Jan 6, 2025
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests.

Check it out here: https://github.com/NikitaRevenco/patchy
@nik-rev nik-rev force-pushed the tree-sitter-tree branch 2 times, most recently from ca6940e to 5fff598 Compare January 7, 2025 08:01
@kirawi kirawi added S-waiting-on-review Status: Awaiting review from a maintainer. A-command Area: Commands labels Jan 19, 2025
@nik-rev
Copy link
Contributor Author

nik-rev commented Jan 31, 2025

And is it possible to prevent writing to the syntax tree buffer? Nvim's impl prevents modifying it, and I think especially now that we replace the buffer with a new one we should expect users not to edit it - and enforce that.

I've actually ended up implementing this. Buffers can now be non-modifiable, which prevents running any commands like going into insert mode, delete, paste etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add full :tree-sitter-tree in addition to existing :tree-sitter-subtree
4 participants