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 show_subtree command for viewing tree-sitter subtree in Popup #1453

Merged
merged 3 commits into from
Jan 16, 2022

Conversation

the-mikedavis
Copy link
Member

show-subtree.mp4

I have this setup for testing but I'm not sure this command really deserves a default binding in the space+<command> submap:

diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 49f8469..3050315 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -677,6 +677,7 @@ impl Default for Keymaps {
                 "R" => replace_selections_with_clipboard,
                 "/" => global_search,
                 "k" => hover,
+                "t" => show_subtree,
                 "r" => rename_symbol,
             },
             "z" => { "View"

I kinda just did whatever the rust compiler told me to do, there's probably some wacky stuff in here 😅. In particular the two nested levels of if let Some(...) feel a little clumsy, no? Please feel free to pile on the rust style/nitpick reviews 👍

Also I think it'd be ideal to run the sexp through a pretty printer, but I left that off in this PR.

What do you think?

@the-mikedavis the-mikedavis marked this pull request as draft January 6, 2022 16:53
@the-mikedavis
Copy link
Member Author

the-mikedavis commented Jan 6, 2022

oh whoops looks like if you do hover and then show_tree, the contents of the popup overlap. I'll see if I can fix that

edit: it's not particularly elegant but renaming both the docs and subtree Popups to be the same in the compositor fixes that behavior. Maybe I'm abusing that system in the compositor by naming them the same though?

helix-term/src/commands.rs Outdated Show resolved Hide resolved
@the-mikedavis the-mikedavis marked this pull request as ready for review January 10, 2022 15:32
@pickfire
Copy link
Contributor

pickfire commented Jan 15, 2022

@the-mikedavis This seemed like something for debugging and not that useful for general users, I guess in cases like this since it is only useful for developers, maybe we should not put it as a normal keymap? But current one should be fine, I don't think it is worth having a key by default for this, but if you want, can keep it commented out or something, maybe note somewhere that this is useful for debugging.

@the-mikedavis
Copy link
Member Author

I think I'll probably rebind it in my config to something like A-t anyways, I'm ok with leaving it out of the keymap even as a comment

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍🏻

Perhaps it would be useful as a binding though, in case users have highlighting issues with a grammar they'd be able to dump the subtree for including in the bug report?

@archseer archseer merged commit 64d3e7b into helix-editor:master Jan 16, 2022
@the-mikedavis the-mikedavis deleted the md-show-subtree branch January 16, 2022 01:33
@the-mikedavis
Copy link
Member Author

I'll make a follow-up PR to hash out a default keybinding 👍

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