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

Does it make sense to treat elements in a tuple/array literal as part of the @parameter object? #86

Open
IndianBoy42 opened this issue Jul 16, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@IndianBoy42
Copy link
Contributor

They are syntactically similar, and semantically not that different. I think there should be a text object for entries in lists/tuples/dictionaries, but the question is whether it should be in the parameter text object or another (@entry? @element)

@IndianBoy42 IndianBoy42 added the enhancement New feature or request label Jul 16, 2021
@IndianBoy42 IndianBoy42 changed the title Does it make sent to treat elements in a tuple/array literal as part of the @parameter object? Does it make sense to treat elements in a tuple/array literal as part of the @parameter object? Jul 16, 2021
@stsewd
Copy link
Member

stsewd commented Jul 18, 2021

@IndianBoy42 do you have a file we can use to test what you mean?

@snezhniylis
Copy link

snezhniylis commented Jul 18, 2021

This can be a problem for dynamically typed programming languages such as Python and Lua where dicts/arrays/... can be passed directly as arguments.

function_call(1, [8, 38, 2, 5])
function_call({
  value1 = true,
  some_number = 35,
  child_table = {
    something = "something"
  }
}, true)

I find it very convincing to be able to select such objects. This way, I can quickly swap arguments, move some to their own local variables, etc.

But I also frequently find it lacking that there's no selector for dict entries / table members out of the box. Maybe there should be a query that does exactly what you propose, but named different. To be able to select all the delimited objects, including function arguments.

@stsewd
Copy link
Member

stsewd commented Dec 21, 2021

This was already done in #87. But I agree that it makes sense to have those as a separate capture.

@IndianBoy42
Copy link
Contributor Author

IndianBoy42 commented Dec 21, 2021

I think arguments could be made either way.

Either you just want a 'smarter' select inside comma separated list, or you really want to be specific about the semantic element

One of the troubles is the sheer number of different text objects you could define semantically

@mawkler
Copy link
Contributor

mawkler commented Nov 3, 2022

I would also love to have a text object for comma separated items inside an array/list/table/dictionary. To me it makes sense to have a different capture group than @parameter, perhaps it could be called @field or @listItem?

@yochem
Copy link
Contributor

yochem commented Mar 6, 2023

I would go with @item or @element I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants