emacs-tree-sitter / treesit-fold

Code folding using treesit.el
GNU General Public License v3.0
74 stars 9 forks source link

Cursor position #17

Open marcantonio opened 1 month ago

marcantonio commented 1 month ago

Thanks for this package.

Is it possible to select the block based only on the line the cursor is on, vs now the cursor needs to be in the block. For example:

class foo {
 *  fn bar() {|
    }
}

Now it seems that to fold bar the cursor must be at |. Folding at * folds foo. I'd like to be able to fold bar from *.

Hopefully that makes sense!

If not available now, would you be interested in a PR?

jcs090218 commented 1 month ago

treesit-fold is designed to provide only the basic folding functionality. I recommend you wrap the folding logic yourself. 🤔

This is what I used, and it has similar functionality you have described:

https://github.com/emacs-vs/vs-edit-mode/blob/d800bd246107af657027b95e83229a74309d0a2c/vs-edit-mode.el#L401-L470