-
Notifications
You must be signed in to change notification settings - Fork 195
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
feat(roc): add roc queries #593
base: master
Are you sure you want to change the base?
Conversation
queries/roc/textobjects.scm
Outdated
) @function.outer | ||
|
||
(argument_patterns | ||
((_) @parameter.inner . ","? @parameter.outer) @parameter.outer |
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.
This query makes it so that @parameter.outer
only matches the comma sometimes (maybe every time?). Can you change this to only have the second outer query which captures everything? Or if that doesn't work you may need #make-range!
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.
I don't understand what the problem is here. A Roc function looks like this:
\x -> x
or with multiple params:
\x, y -> x
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.
Yes; if you try it yourself, you'll find that operating on @parameter.outer
selects only the comma itself, when it should be the entirety of, say, x,
(with or without trailing whitespace). This is why you may need #make-range!
. You can see some examples of other textobject files doing this if you need, this type of query is pretty common across different languages.
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 explaining. this is my first foreay into tree-sitter
queries/roc/textobjects.scm
Outdated
) | ||
|
||
(function_type | ||
((_) @parameter.inner . ","? @parameter.outer) @parameter.outer(#not-eq? @parameter.inner "->") |
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.
Same as above I believe. Also we don't enforce style (yet?) on this repo but would you mind putting the predicate on a new line, just some easier reading?
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.
We should add the query linter from nvim-treesitter
; I don't think we should support a different style here. (You can just download/copy the file from that repo; it's a standalone script.)
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.
I added the query linter and ran it. I am still not sure what the issue is with this query though. If someone can explain to me in more detail I will make whatever change necessary.
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.
Oh, thank you for doing that! Sorry I should have mentioned this was done by me a few days ago; but I think your issue is that the linter expects the output to match the main
branch formatter: I am guessing the one you added is from master
? (I also did this at first!) You can just remove that file from this PR and then run your original queries through the main
branch's formatter if you get any CI complaints :) (if it doesn't complain, then it doesn't even matter)
32cdbb1
to
e2e1e88
Compare
|
||
(apply_type_arg) @parameter.inner | ||
|
||
((#offset! line_comment 0 1 0 -1)) @comment.inner |
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.
This results in an error: try looking here for an example of how this should be done
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.
Also, if you happen to be using lazy, you can just put your textobject queries in ~/.local/share/nvim/lazy/nvim-treesitter-textobjects/queries/roc/textobjects.scm
and restart your neovim instance and they should apply locally, if you'd like to be able to do some quick debugging.
@clason I made a new clean PR