-
-
Notifications
You must be signed in to change notification settings - Fork 77
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Support Elm Programming Language #2222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It would be great if you could migrate these patterns to the new scm query syntax, as we're in the process of removing the old pattern language completely. See the docs, other example PRs, eg json and java, and feel free to drop into a meet-up!
I added most of the scm queries that I understood. Currently I am struggling with scopes - many of the previously recorded tests are now failing because of "NoContainingScopeError"s. For reference, here is what I thought should work:
Can you give me some hints? I've tried looking at other languages, but most have a mixed bag of scm and ts queries. |
I think |
@anmolitor I think you're running into tree-sitter/tree-sitter#2984. You can work around it as follows: (function_declaration_left (_) @argumentOrParameter (#not-type? @argumentOrParameter lower_case_identifier)) |
also, be sure to use andreas's extension to format your code |
@anmolitor I forked this PR to see if I could help. I couldn't get far, but I did manage to the linked formatter going. It took a while to run on the entire repo but it seems like all it needed to format was the steps:
The PR seems to be working though, (without being able to run tests for some reason). I'd love to have support for Based on how All the ones in this PR seem to work great (save for |
Wow thanks for the help everyone! |
@anmolitor if you don't think you'll have capacity to bring this one home, maybe @tankorsmash should open a new PR so that the formatting changes can be incorporated and push things forward? (assuming @tankorsmash has time) |
I'll take another stab at this this weekend, if @anmolitor is busy! |
Sorry for the delay. I think I'm currently too busy to complete this PR so I'll close this for now. @tankorsmash feel free to use my code as a starting point :) |
I've messed around with Treesitter more in the meantime, hopefully I can put something together. Thank you for all the work so far! |
What
Adds support for the Elm programming language.
I have tried to bring #891 up to date.
Is there a good way to unit test the generated tree sitter queries?
I am currently struggling to extend the functionality - Elm is quite different in its syntax from most currently supported languages. For example,
record_expr[field][expression]
forchange value
inside of a map/struct { a = 1, b = 2 } currently always results in { a = , b = 2 }, even if the cursor/target is on "b".I read https://www.cursorless.org/docs/contributing/parse-tree-patterns/ and set up tree-sitter-node locally with tree-sitter-elm to easily inspect the trees, but there are a lot of utility functions in use in the cursorless codebase regarding NodeMatchers that I do not fully understand. Is there some additional documentation/examples that I haven't found yet?
EDIT:
I have looked at the open Haskell MR which has a similar syntax. Scm Queries seem to be easier to debug to I will be trying that for now.
Checklist
"change"
/"clear"
instead of"take"
for selection tests to make recorded tests easier to read"chuck"
instead of"change"
to test removal behaviour when it's interesting, especially:"chuck arg"
with single argument in list"chuck arg"
with multiple arguments in list"chuck item"
with single argument in list"chuck item"
with multiple arguments in list@textFragment
captures. Usually you want to put these on comment and string nodes. This enables"take round"
to work within comments and strings."change round"
inside a string, eg"hello (there)"
"type"
both for type annotations (egfoo: string
) and declarations (eginterface Foo {}
) (and added tests for this behaviour 馃槉)"item"
both for map pairs and list entries (with tests of course)