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

Show completions with and without params #699

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Show completions with and without params #699

wants to merge 6 commits into from

Conversation

muffinmad
Copy link
Contributor

In some cases I don't want completion with snippets:

class Foo(object):
    def __init__(self, a, b, c):
        pass

class Bar(Foo|
from datetime import date, datetime

if foo:
    fn = date|
else:
    fn = datetime|
def foo(a, b, c):
    pass

def bar(a, b, c):
    pass

z = foo(a, b, c)

# And now I need to replace `foo` with `bar`
z = bar|(a, b, c)

Assume cursor is at | and completions are invoked. Applying completion will insert snippet and I must delete it in order to have just class/function name.

IMO there are no way we can properly decide to include params or not.

My proposal is to include both candidates without and with params in completions list.

This PR add new option include_params_both. With include_params and include_params_both enabled completions list will include both variants.

There also side change: label is always equal to insertText in completion item. Is there any reason to completion label include all params?

@ccordoba12 ccordoba12 added this to the 0.31.1 milestone Nov 18, 2019
@ccordoba12
Copy link
Contributor

This is an interesting idea, thanks @muffinmad!

@andfoy, please review this one.

@ccordoba12 ccordoba12 removed this from the 0.31.1 milestone Nov 20, 2019
@mpanarin
Copy link
Contributor

This is why I disabled this completion snippets completely.

Is it worth creating a different variable completely for this? As it won't make any sense to enable include_params_both without the original one.
Maybe some kind of switch?
like:
falsy val - disabled
truthy val - enabled with only params (for backwards compat)
"both" string specifically - enable both

@muffinmad
Copy link
Contributor Author

Is it worth creating a different variable completely for this? As it won't make any sense to enable include_params_both without the original one.
Maybe some kind of switch?
like:
falsy val - disabled
truthy val - enabled with only params (for backwards compat)
"both" string specifically - enable both

At first I was going to use both value of the include_params variable for this. But in

"pyls.plugins.jedi_completion.include_params": {
include_params described as bool so I'm not sure if string is allowed.

Maybe int will fit? Like:

  • 0 - no snippets
  • 1 - snippets only
  • 2 - both

Or both variants of completion can be used if include_params is enabled. Having only snippets in completion is little annoying.

@muffinmad
Copy link
Contributor Author

Having only snippets in completion is little annoying indeed so both variants of completion is used now when include_params is set.

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.

3 participants