-
Notifications
You must be signed in to change notification settings - Fork 33
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
Question: expand for
and struct
grammar with headers?
#142
Comments
if True:
pass
elif False:
pass
else:
pass
whereas in julia all "consequence" lines are siblings of the condition: if true
1
1
elseif false
1
else
1
end
|
There's two seperate issues here, so I'll address them separately. Querying inner blocksThe block rule used in the grammar is not visible (see #73). There's no technical limitation here, but making it visible is a breaking change that would require updating almost all tests. Querying "headers"If blocks were visible, querying headers would be really simple, since they're always "the thing before the block". For now, I can only think of a couple of workarounds:
In the case of structs... The way they're currently parsed is awful. I took a much simpler approach for the lezer-julia grammar, and that should probably get ported here. |
@savq thanks for the reply! I prepared a PR nvim-treesitter/nvim-treesitter-textobjects#639, any comments would be greatly appreciated!
Yes, this would really help a lot. For
I tested this and it selects only one |
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)No response
Describe the bug
This is not a bug, but more like a question/feature request.
I'm trying to update / fix julia queries for neovim and I'm having a very hard time with
for
loops and alsostructs
.This python example
is parsed as follows:
and this julia example
is parsed as
Because the two
for_binding
nodes are not grouped together in any way and are siblings of thecall_expression
, I couldn't write any query that would correctly select the loop "header" (regardless of the number of variables iterated over), and neither any query that would select the body without the "header". This might be due to the fact that I'm no expert in TS queries, but for Python such queries are really simple.Similar situation is with struct definitions:
is parsed as
Again, struct header nodes
type_parameter_list
andtype_clause
are siblings of the struct body.Is there a reason not to group struct and loop "headers" together similarly to how python is parsed?
The text was updated successfully, but these errors were encountered: