autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Omni completion in Scala with Metals includes return type #856

Closed reidrac closed 5 years ago

reidrac commented 5 years ago

I'm running latest release with nvim.

When I use omni completion, the suggestions include the return type. Not sure if this is desirable or not, but I guess making it configurable would be great. I've seen Metals LSP used in other editors and when autocompletion is used, the result won't include the return type.

For example:

scala.util.Try(false).
// then CTRL-X XTRL-O and select failed
scala.util.Try(false).failed: Try[Throwable]

I don't know if this is a bug. The code compiles, but I don't want to specify the return type of every method (specially if this only happens when I use the omni completion).

I've checked the documentation but I failed to find how this behaviour can be changed.

Thanks a lot for this project!

dimbleby commented 5 years ago

The client's responsibility is to present whatever completions the server offers it. If you don't like the completions, you surely need to take this to the server.

reidrac commented 5 years ago

OK, thanks!

So I guess this is a problem with metals (the server); although when other editors use metals, this doesn't happen.

KillTheMule commented 5 years ago

It's not that clear cut, at least from a user's perspective. The response to a CompletionRequest is pretty complex and contains much more than just the text to be inserted. It would be entirely feasible for a client to mishandle it and insert the wrong text. Note e.g. the distinction between "label" and "insertText".

That said, I have no idea what's going on here, just wanted to point out that it's not "surely" the server's fault.

reidrac commented 5 years ago

From my point of view this makes LC-neovim unusable with metals; whether LC-neovim or metals is to blame is irrelevant because I can use them together. I may be doing somwthing wrong, but I can't see how this can be used by anyone.

val logger = org.log4s.getLogger
// automcomplete from logger. to logger.debug
logger.debug(t: Throwable)(msg: String): Unit

This is not what I would expect, and it is definitely not useful.

If the maitainers change their mind, this isssue is easy to reproduce. They can reopen this issue or make a new one.

KillTheMule commented 5 years ago

Well, if you're interested in solving this, you should see if lcn offers logging, and then check out the CompletionList response metals sends.

dimbleby commented 5 years ago

g:LanguageClient_completionPreferTextEdit might be relevant, you could try setting that.