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/internal/lsp: snippet placeholders should include type as well #31547

Closed
muirdm opened this issue Apr 18, 2019 · 5 comments
Closed

x/tools/internal/lsp: snippet placeholders should include type as well #31547

muirdm opened this issue Apr 18, 2019 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@muirdm
Copy link

muirdm commented Apr 18, 2019

Currently the function call completion placeholder snippets only contain the function parameter names like "fmt.Errorf(format, a)". It would be useful if they also had the parameter type like "fmt.Errorf(format string, a ...interface{})"

@gopherbot gopherbot added this to the Unreleased milestone Apr 18, 2019
@stamblerre stamblerre added gopls Issues related to the Go language server, gopls. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Apr 18, 2019
@stamblerre
Copy link
Contributor

I'd be curious to get more feedback on people's preferences before making a decision here. Personally, I think that, when combined with signature help, it's not really necessary, but if it's useful then I'd be happy to add it.

I also had the idea that perhaps we could replace the placeholder with the nearest identifier in scope with the matching type, which could save people some extra typing, but that's probably a separate issue.

/cc @ianthehat

@muirdm
Copy link
Author

muirdm commented Apr 18, 2019

when combined with signature help, it's not really necessary

In emacs, the signature help doesn't show in this case because (in my example) "format" is not a valid identifier, so that LSP error hides the signature help. I have signature/hover popups disabled (they show up in the minibuffer only, which is shared with LSP error/warning output). Even if the signature help showed up properly in the minibuffer, it is still useful for me to have the placeholders show up properly under point, so I don't have to look around.

I also had the idea that perhaps we could replace the placeholder with the nearest identifier in scope with the matching type

I was thinking about that myself. I was also thinking that you often "pass along" variables/fields that have the same/similar name as the function argument. That could good be a good heuristic for picking between multiple in-scope identifiers with the same type.

@stamblerre
Copy link
Contributor

@muirrn, are you saying that the diagnostic errors cover up the signature help? This seems like it might be a bug in lsp-mode - I would think that the two would be independent. Anyway, in that case, I'm happy to add the types, or if you'd like to make that contribution, I can review it.

I filed #31548 to track improving the contents of the placeholders.

@muirdm
Copy link
Author

muirdm commented Apr 18, 2019

are you saying that the diagnostic errors cover up the signature help

Yes, but it is related to my config since I have all inline popups disabled. The diagnostic comes back after the signature help, so it overwrites it in the minibuffer. (The minibuffer is actually being updated by two separate modes: lsp-mode displays the signature help, but delegates to flycheck to handle the diagnostic errors.) If I configure the diagnostics to show up inline then I can see the signature help in the minibuffer. However, even with signature help visible, it would still be useful to have the name/type show up in the placeholder because it is under my cursor (and the signature help in the minibuffer is far away).

@stamblerre stamblerre removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Apr 18, 2019
@gopherbot
Copy link

Change https://golang.org/cl/172666 mentions this issue: internal/lsp: add type to placeholders in completion parameters

@golang golang locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

3 participants