mickeynp / combobulate

Structured Editing and Navigation in Emacs with Tree-Sitter
GNU General Public License v3.0
889 stars 50 forks source link

Display syntax tree of current buffer in separate buffer. #72

Open m4xxed opened 8 months ago

m4xxed commented 8 months ago

This is an idea I had while reading through your documentation and trying out the package. I noticed that the echo area displays a subtree around the current node that is being walked over, and I loved it!

I would love to get more into structural editing and I think one possible way of aiding new users (of structural editing) would be a small "minimap" of the current syntax tree, either on the left like the minimap package, or maybe like a treemacs-buffer on the right.

If there is something in development currently, I'd love to find out, and if you have a good starting pointer for me on where I can get the current buffers syntax tree that is used by combobulate, I'd appreciate that, too. I would be willing to try to implement it myself, just looking for a good place to start.

mickeynp commented 8 months ago

It's definitely on the cards, but I'd love if someone worked on that. Give this function in combobulate-display.el a try: combobulate-display-draw-complete-tree.

You can try it out like so: M-: (combobulate-display-draw-complete-tree (combobulate-root-node) "*combobulate-tree*") then switch to *combobulate-tree* buffer.

For making a buffer appear on the right consistently you can use the side bar feature:

https://www.masteringemacs.org/article/demystifying-emacs-window-manager

mickeynp commented 8 months ago

Another thing on my todo list is to incorporate SVG elements into the tree for select node types.