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 tree-sitter-regex #1362

Merged
merged 12 commits into from
Jan 6, 2022
Merged

Conversation

the-mikedavis
Copy link
Member

Example injected into elixir

regex

it's a pretty subtle improvement; I'm not too impressed yet. Let me dig into the grammar and see if we can write some more interesting queries beyond brackets and quantifiers.

@the-mikedavis
Copy link
Member Author

the-mikedavis commented Dec 29, 2021

getting closer...

regex3

the grammar actually parses some cool stuff, I'm surprised the captures in the upstream repo are so thin 😄

@the-mikedavis the-mikedavis force-pushed the md-tree-sitter-regex branch 2 times, most recently from 827d110 to 4d1009b Compare December 29, 2021 14:40
@kirawi
Copy link
Member

kirawi commented Dec 29, 2021

Maybe you can upstream the queries :P

@the-mikedavis the-mikedavis force-pushed the md-tree-sitter-regex branch 2 times, most recently from bc6e246 to 978f5fb Compare December 31, 2021 17:53
@the-mikedavis
Copy link
Member Author

Maybe you can upstream the queries :P

tree-sitter-regex is looking a bit in need of maintenance in general, I'll see if I can fixup some of the open issues and clean up queries and testing before opening up this PR for review 👍

@the-mikedavis
Copy link
Member Author

ok I dusted off the repo and upstreamed the queries

it's starting to look pretty good now:

I didn't look around too much for other languages to inject regex into. Seems like rust would be a good idea but I don't think there's a syntactic construct that is always a regex like /foo/ in js or sigil-r in elixir? Maybe we can inject regex into any raw string argument to Regex::new?

@the-mikedavis the-mikedavis marked this pull request as ready for review January 4, 2022 03:24
@pickfire
Copy link
Contributor

pickfire commented Jan 4, 2022

Are you looking into doing this in rust?

(call_expression
  function: (scoped_identifier
    path: (identifier) @_regex (#eq? @_regex "Regex")
    name: (identifier) @_new (#eq? @_new "new"))
  arguments: (arguments
    (raw_string_literal) @regex))

(call_expression
  function: (scoped_identifier
    path: (scoped_identifier (identifier) @_regex (#eq? @_regex "Regex").)
    name: (identifier) @_new (#eq? @_new "new"))
  arguments: (arguments
    (raw_string_literal) @regex))

@the-mikedavis
Copy link
Member Author

rust-regex

Beautiful 🎉

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

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

Nice, looks good to me. \o/

@pickfire pickfire merged commit a8fd33a into helix-editor:master Jan 6, 2022
@the-mikedavis the-mikedavis deleted the md-tree-sitter-regex branch January 6, 2022 15:01
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