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

Automatically expand python parameters #214

Closed
wants to merge 1 commit into from

Conversation

fbergroth
Copy link

Hi, this is a first stab to automatically expand the parameters of a python callable when invoked. Basically, whenever the opening parenthesis of a call is typed, like object.some_method(_, the expansion snippet is triggered.

By using the opening parenthesis as a trigger, parameter expansion will not get in the way when passing functions as parameters, such as in map(object.some_method, [1, 2, 3]).

For this to work in languages where overloading methods is possible, I guess the completer needs to know which index was selected in the popup menu.

Anyway, let me know what you think about this approach.

Whenever a python callable is invoked, Jedi is used to find its
parameters. UltiSnips will then expand them as an anonymous snippet.
@Valloric
Copy link
Member

Thanks for working on this. I need to take a closer look at it but I sadly don't have time right now. Probably this weekend.

@JazzCore
Copy link
Contributor

This is nice. But here are a few bugs:

  1. If you will try to delete a selected text after expanding, it will not be deleted and will make an extra ')' bracket
  2. Currently it doesnt play well with plugins like delimitMate, because it automatically inserts closing bracket

@fbergroth
Copy link
Author

Yeah, there are a couple of issues. I think inserting a closing bracket is fine if it plays well with other plugins. Otherwise, the whole parameter list could be wrapped in a placeholder, but that would require pressing tab one extra time. The snippet can probably be improved quite a bit with some python interpolation.

Also, this should probably be made async before being merged in. I will continue working on this next week.

@johntyree
Copy link

Please make the auto-insertion of the closing bracket optional somehow.

@Valloric
Copy link
Member

Valloric commented Apr 8, 2013

Thanks for working on this.

This pull request only implements the feature for Python; YCM needs a way to provide that feature in a language-agnostic way. It would have to be accessible to all completers through YCM's Completer API.

I've been thinking of various approaches to the problem and will start working on a generic solution soon. Issue #234 has recently been created that will be updated when the situation changes. I've also posted about a different approach to the same problem there, along the lines of what jedi-vim does.

Again, thanks for the pull request. I like the UltiSnips approach. Something like this will probably be my "plan B" if the jedi-vim approach does not pan out.

@Valloric Valloric closed this Apr 8, 2013
@Valloric
Copy link
Member

Valloric commented Apr 8, 2013

Oh, and apologies for taking so long to review this.

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

Successfully merging this pull request may close these issues.

None yet

4 participants