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

x/tools/gopls: completion should also provide just the function name #64469

Open
pjweinb opened this issue Nov 30, 2023 · 7 comments
Open

x/tools/gopls: completion should also provide just the function name #64469

pjweinb opened this issue Nov 30, 2023 · 7 comments
Labels
FeatureRequest gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@pjweinb
Copy link

pjweinb commented Nov 30, 2023

gopls version

v0.14.2

go env

irrelevant

What did you do?

I have an existing expression f(a), and I would like to replace it with f(protocol.FWithLongName(a)). After typing protocol.F, the only useful completion offered is the function snippet, which would complete as
f(protocol.FWithLongName(x protocol.TypeWithLongName, y TypeOfSecondArg)(a))
which requires too much editing.

What did you expect to see?

I would like to have seen both the function snippet and just the function names as suggested completions.

What did you see instead?

The unsyntactic completion described above. gopls is not looking at the context when it proposed a snippet where there is already an argument.

Editor and settings

No response

Logs

No response

@pjweinb pjweinb added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Nov 30, 2023
@gopherbot gopherbot added this to the Unreleased milestone Nov 30, 2023
@adonovan adonovan added gopls/completion Issues related to auto-completion in gopls. FeatureRequest labels Nov 30, 2023
@findleyr
Copy link
Contributor

Does "completeFunctionCalls": false do what you want?

@pjweinb
Copy link
Author

pjweinb commented Nov 30, 2023 via email

@hyangah hyangah modified the milestones: Unreleased, gopls/backlog Dec 7, 2023
@hyangah
Copy link
Contributor

hyangah commented Dec 7, 2023

I have an existing expression f(a), and I would like to replace it with f(protocol.FWithLongName(a)). After typing protocol.F, the only useful completion offered is the function snippet, which would complete as
f(protocol.FWithLongName(x protocol.TypeWithLongName, y TypeOfSecondArg)(a))
which requires too much editing.

I agree that the completion logic needs to be smarter in this case.

Can you share your gopls setting? I disabled usePlaceholder for the similar issue at some point in the past.

@pjweinb
Copy link
Author

pjweinb commented Dec 7, 2023 via email

@hyangah
Copy link
Contributor

hyangah commented Dec 7, 2023

@pjweinb i am not suggesting users have to turn on/off the settings while editing. I meant usePlaceholder setting became counter-productive due to this problem and I personally don't use that setting any more. Giving both option will be confusing unless we figure out good presentation, and make the suggestion list longer.

@pjweinb
Copy link
Author

pjweinb commented Dec 7, 2023 via email

@muirdm
Copy link

muirdm commented Dec 19, 2023

I wonder if we could try to make the snippet smarter. In f(a) where you want f(other(a, ...)), if a can be passed to other, maybe we could see that and offer other(a, <nextArg>) as the completion. Or maybe that is too specific.

Anyway, in cases where there is a trailing identifier after the cursor, I feel it is reasonable to also offer the naked function call as a completion candidate since it is hard to tell what the user wants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants