Skip to content

treesit.el Support #3

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

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

DevelopmentCool2449
Copy link
Contributor

@DevelopmentCool2449 DevelopmentCool2449 commented Jun 15, 2024

This adds real treesit.el support, also i've added a feature for unfold by clicking fold-replacement.

Some changes to consider:

  • I've added some -ts-mode modes to treesit-fold-range-alist
    There are some modes that still need to add such as vimscript-ts-mode and more
    that i think it can be added in separated PR.
  • some functions such as treesit-fold-2str treesit-fold-get-children and treesit-fold-get-children-traverse were replaced or removed (treesit-fold-get-children-traverse was unused so i commented out it).
  • Most tsc-* functions were replaced by their treesit counterpart.

I've tested it with lua, c/c++ and python and should work for the other languages.
Also i've added some temporal comments for review.

@DevelopmentCool2449 DevelopmentCool2449 mentioned this pull request Jun 15, 2024
@jcs090218
Copy link
Member

Can you solve the compile warnings? Thanks!

treesit-fold.el:287:2: Warning: docstring wider than 80 characters

In end of data:
treesit-fold.el:311:28: Warning: the function ‘treesit-fold--trigger’ is not known to be defined.

Compiling /home/runner/work/treesit-fold/treesit-fold/treesit-fold-indicators.el... done ✓

In global-treesit-fold-indicators-mode:
treesit-fold-indicators.el:151:2: Warning: docstring wider than 80 characters

Can you also update the Eask-file? Thank you!

@DevelopmentCool2449
Copy link
Contributor Author

Can you solve the compile warnings? Thanks!

treesit-fold.el:287:2: Warning: docstring wider than 80 characters

In end of data:
treesit-fold.el:311:28: Warning: the function ‘treesit-fold--trigger’ is not known to be defined.

Compiling /home/runner/work/treesit-fold/treesit-fold/treesit-fold-indicators.el... done ✓

In global-treesit-fold-indicators-mode:
treesit-fold-indicators.el:151:2: Warning: docstring wider than 80 characters

Can you also update the Eask-file? Thank you!

Done. About the docstring warning i'm not sure why it happens, i think it can be a false-positive.

@DevelopmentCool2449
Copy link
Contributor Author

As an aditional note i'm wondering if we can add a section in the README file for how allow folding non-ts modes by using their parsers, it's based in a @abougouffa comment, i've tested it for elisp evaling this code snippet and folding works well.

(when (and (treesit-available-p) (treesit-language-available-p 'elisp))
  (treesit-parser-create 'elisp))

or add an option for allow that.

@jcs090218
Copy link
Member

As an aditional note i'm wondering if we can add a section in the README file for how allow folding non-ts modes by using their parsers, it's based in a @abougouffa comment, i've tested it for elisp evaling this code snippet and folding works well.

I agreed. Let's add it to the README! :D

@DevelopmentCool2449
Copy link
Contributor Author

Done

@jcs090218
Copy link
Member

LGTM! Thank you so much! :D

@jcs090218 jcs090218 merged commit 9f82f1e into emacs-tree-sitter:master Jun 15, 2024
5 of 6 checks passed
@abougouffa
Copy link
Contributor

Excellent work @DevelopmentCool2449 !

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.

3 participants