-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: Selection cursor does not begin at the top of the list of completion items #61533
Comments
I don't see this problem from vscode and the completion order shown in the video doesn't seem to match what gopls is sending. @anthony-S93 can you please capture the lsp trace (esp |
Thank you for the quick response. So I've dug thorugh my LSP logs and managed to isolate the logs that were produced right after I activated the completion feature shown in the video above. Here are the logs for the different language servers I re-tested: I also tested Please note that logs I sent were for when the language servers were running in "single-file" mode, which simplifies the logs. In any case, Thank you for your time. And please let me know if there is any additional information you need. Update: normal_behavior_when_using_completion_on_fmt.mp4The correct behavior did not produce any logs. For completeness' sake, here is a video showing the autocompletion behavior when I typed the entire string "fmt" manually. abnormal_behavior_when_typing_fmt_manually.mp4 |
Hi, in the logs you shared (https://pastebin.com/raw/Wm4j0FPG), I can see that 'preselect' is only set for the first item in the list. So this looks like a bug in your LSP client. I also can't reproduce in either VS Code or coc.nvim. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
I looked deeper into this and discovered what's causing the issue. As it turns out, the completion engine I'm currently using will choose the ordering of the items in the completion list dynamically—based on the occurence of the completion item within the document itself. Here's a brief video to demonstrate this behavior: golang-completion-solution.mp4However, this dynamic reordering of the completion list by the completion engine does not work well with The Workaround: local cmp = require("cmp")
cmp.setup({
-- Your own cmp config is here...
-- Add the following config to turn off preselect
preselect = cmp.PreselectMode.None
}) What this does is that it instructs |
gopls version
go env
What did you do?
mkdir test
cd test ; touch test.go
test.go
with a text editor (e.g:nvim test.go
)What did you expect to see?
The selection cursor should start at the top of the autocompletion list.
What did you see instead?
Whenever the autocompletion list pops up, the selection cursor automatically jumps to the list item that is first in alphabetical order, not the item that is actually displayed at the top of the list. Like so:
gopls_cmp_bug.mp4
This behavior is counter-intuitive and inconsistent with all other language servers I've used. If this is by design, I would like to know how to turn it off because it's too different from how other language servers handle completions and I prefer to have a uniform completion experience across all language servers.
Editor and settings
I can consistently reproduce this behavior in Neovim with
nvim-cmp
as the completion engine (https://github.com/hrsh7th/nvim-cmp). The language server is launched mostly with the defaults provided bynvim-lspconfig
. No additional settings except for the server capabilities required to enable completion are used.Please note that I have tested other language servers (pyright, tsserver, bashls, jdtls, ccls, lua_ls, etc.) using the same editor and same completion engine. gopls is the only language server to exibit this strange behavior, so it's quite unlikely for the editor or the completion engine to be the cause of this issue.
Additional Info
Operating system
Editor version
The text was updated successfully, but these errors were encountered: