Comments (8)
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.
Fair enough, thanks for your response.
from targets.vim.
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.
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.
+1 for function arguments operator. That would be really cool.
from targets.vim.
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.
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.
@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)
- [Bug Report] Why does targets.vim reset my filetype?
- targets.vim causing issue with macros HOT 6
- cin' not working with \
- Disabling mappings still causes health check warnings.
- Define argument source with longer separator (multiple characters). HOT 2
- cin" doesn't target next quotes properly HOT 1
- `ia` doesn't handle nested braces when arguments are put each on it's own line HOT 4
- Square brackets argument doesn't work HOT 1
- Supporting Other Plugins HOT 1
- Unable to select pair text object with other pair on the same line HOT 1
- Stops working with "set nomagic"
- dot-repeat echoes sometimes ':call targets#do()'
- README.md has Pathogen example that uses "git://" URL instead of "https://" or "ssh://" URL
- ci( doesn't seek forward
- repeat motion in visual mode does not extend selection
- Missing mapping for r
- How to install for Intellij's ideavim HOT 1
- Mess up with di"
- [feature-request] make it possible to disable one or more omap/vmap ?
- ia do not detect outer scope when an inner scope is present in the line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from targets.vim.