Code Monkey home page Code Monkey logo

Comments (8)

wellle avatar wellle commented on May 16, 2024

I definitely agree that it would be useful to have a text object for function arguments. Right now this is not supported. Separator text objects use a very simple mechanic and all actions seen in your screencast are working as expected.

It might be possible to use a more complex logic to account for the use case you mentioned, but that could have implications regarding seeking. Also just ignoring any parentheses might not be enough. In this example I would have to handle matching pairs and skip over separators:

foo(a, 4 + bar(c[0], x), d)

I would like to make handling of arguments possible with targets.vim, but at the moment I don't have a clear idea about what would be reasonable.

If you have any more input on this, please let me know!

I also commented on this topic in #14 (comment):

To be fair, separator text objects can't target the first and last arguments because they are surrounded by different delimiters. I had many thoughts about some special argument text objects because it would be really useful in combination with next and last text objects. An easy way might be to introduce separator classes so that different characters could be used as separators for one text objects. For example dana could delete the next element in a list separated by either of these characters: ,(). But this would not handle nested function calls properly. Doing it right would be much more complicated.

from targets.vim.

elzibubble avatar elzibubble commented on May 16, 2024

Fair enough, thanks for your response.

from targets.vim.

wellle avatar wellle commented on May 16, 2024

Just wanting to let you know that I started working on this. It would be a new text objects a that selects an argument. An argument is text between a pair ((), {}, []), separators (,,, ;;) or a mix of them ((,, ;], ...). It also includes matching pairs inside of an argument, like in the example I gave above.

Besides (), I'd also expect a comma list to end at [], {}, "", '', colon, semicolon and almost certainly others.

I disagree on ", ' and :, because they should be included in an arguments in cases like these:

foo(a, b + "bar", c)
foo(a, b + 'x', c)
foo(a, std::bar, c)

Do you agree on the separators I listed and the behavior I described?

from targets.vim.

elzibubble avatar elzibubble commented on May 16, 2024

Fantastic news, I hope it goes well!

Re: quotes, I mostly agree on your cases. std::bar is a corner case because
in normal English a colon terminates a list, I don't suppose you want to
get into tailoring separators per file-type though. If you do, you might
want to think about Haskell/Lisps where arguments are space-delimited while
respecting matching pairs. Maybe existing filetype plugins offer some
clues? Ideally clues available at runtime.

The case where there's a parenthetical end-of-line comment is hard to
distinguish from a parenthetical on the last item; suggest you ignore EOL
comments :)

How will you handle a, b, "c, d", e? On c, ia should select just c. Could
aoa be on the cards ('a' object, 'o' outer, 'a' argument) to select "c, d"?
Maybe up to aoooooa? AIUI it's hard to provide an arbitrary length.

Watching my screencast again, I'm not sure why from foo(aaa, bbb, ccc),
da, on aaa deletes bbb? That seems wrong even given separator objects are
very simple. In fact this fails just on aaa, bbb, ccc.

On 6 May 2014 00:25, Christian Wellenbrock [email protected] wrote:

Just wanting to let you know that I started working on this. It would be a
new text objects a that selects an argument. An argument is text between
a pair ((), {}, []), separators (,,, ;;) or a mix of them ((,, ;], ...).
It also includes matching pairs inside of an argument, like in the example
I gave above.

Besides (), I'd also expect a comma list to end at [], {}, "", '', colon,
semicolon and almost certainly others.

I disagree on ", ' and :, because they should be included in an arguments
in cases like these:

foo(a, b + "bar", c)foo(a, b + 'x', c)foo(a, std::bar, c)

Do you agree on the separators I listed and the behavior I described?


Reply to this email directly or view it on GitHubhttps://github.com//issues/56#issuecomment-42252737
.

Cheers,
Alexis

from targets.vim.

bentomas avatar bentomas commented on May 16, 2024

+1 for function arguments operator. That would be really cool.

from targets.vim.

UnrealQuester avatar UnrealQuester commented on May 16, 2024

For function arguments there is already PeterRincker/vim-argumentative. Incorporating this functionality in targets.vim might be difficult. I suggest staying true to the 'Do one thing and do it well' philosophy.

from targets.vim.

elzibubble avatar elzibubble commented on May 16, 2024

I agree - let's close this?

On 29 May 2014 17:13, UnrealQuester [email protected] wrote:

For function arguments there is already PeterRincker/vim-argumentative.
Incorporating this functionality in targets.vim might be difficult. I
suggest staying true to the 'Do one thing and do it well' philosophy.


Reply to this email directly or view it on GitHub
#56 (comment).

Cheers,
Alexis

from targets.vim.

wellle avatar wellle commented on May 16, 2024

@UnrealQuester @lxsli In general I agree. But I think that next and last argument text objects are really useful. I am making good progress in implementing them.

from targets.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.