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

Added support for Rust #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

marcolgl
Copy link

Hi,
i wrote two functions to support folding in Rust.
In particular the following tree-sitter-node-types are folded:

  • struct_item
  • enum_item
  • function_item
  • impl_item
  • mod_item
  • match_expression
    match in Rust is a ExpressionWithBlock, it can be followed by a
    semicolon or not depending on what we want to do with its return value.
    Then semicolon is not folded to make it explicit its presence and role
    even when then match item is folded
  • macro_definition
    this required its own function because the nodes to match
    have a slightly different pattern in the grammar

I added two entries in tree-sitter-foldable-node-alist and
tree-sitter-fold-range-alist because there are currently
(as far as i know) two major mode for rust: rust-mode and
rustic-mode . That is redundant but makes folding work in
both cases.

I am very new to elisp, so corrections and suggestions are welcome.
Thanks for reading and for the work on this package

Introduced folding functions for Rust items:
struct_item, enum_item, function_item, impl_item, mod_item,
match_expression, macro_definition.
Added two entries in the tree-sitter-foldable-node-alist for those
tree-sitter-node-type and the major modes "rustic" and "rust".
Added the mappings in tree-sitter-fold-range-alist.
@junyi-hou
Copy link
Owner

sorry I was slow to respond, let me check it this week and hopefully merge this. Thanks!

Support for folding the Rust items:
trait_item, macro_invocation.
Added them to the tree-sitter-foldable-node alist and
tree-sitter-fold-range-alist for Rust.
@marcolgl
Copy link
Author

marcolgl commented Oct 2, 2021

No worries, take all the time you need.
In the last commit I added two other node-types:

  • trait_item
  • macro_invocation

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.

2 participants