scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.1k stars 332 forks source link

Metals + Coc shows three identical autosuggest/autcomplete entries #1263

Closed jsatk closed 4 years ago

jsatk commented 4 years ago

Describe the bug I see three of every auto-suggestion/complete when using Metals with Coc.

To Reproduce Steps to reproduce the behavior:

  1. Type literally anything into a Scala file that will have autocomplete suggestions.
  2. Observe that there are three identical suggestions rather than just one.

Expected behavior

  1. Type literally anything into a Scala file that will have autocomplete suggestions.
  2. Observe that there is only one suggestions.

Screenshots http://i.jsatk.us/62uvPy

ckipp01 commented 4 years ago

I'm not able to reproduce this locally. However, I have seen this sort of behavior once when I had metals both installed manually and as an extension.

@jsatk I'm not sure if you've also tried the coc-metals extension or not, but if you did, can you ensure you don't have metals registered both manually and the extension installed. If you do, that can lead to behavior like this since two engines will be feeding completion information to coc.

You can do a :CocConfig and :CocLocalConfig to check what you have under languageserver, and then a :CocList extensions to see the installed extensions. You want to make sure you don't have both existing at the same time.

jsatk commented 4 years ago

That might be it. I’ll check tomorrow and report back. Thanks for the prompt reply.

On Jan 6, 2020, at 10:13 PM, Chris Kipp notifications@github.com wrote:

 @jsatk I'm not sure if you've also tried the [coc-metals](https://github.com/ckipp01/coc-metals extension or not, but if you did, can you ensure you don't have metals registered both manually and the extension installed. If you do, that can lead to behavior like this since two engines will be feeding completion information to coc.

You can do a :CocConfig and :CocLocalConfig to check what you have under languageserver, and then a :CocList extensions to see the installed extensions. You want to make sure you don't have both existing at the same time.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

jsatk commented 4 years ago

@ckipp01 I do indeed have coc-metals extension installed as well as the following in my coc-settings.json:

    "metals": {
      "command": "metals-vim",
      "rootPatterns": [
        "build.sbt"
      ],
      "filetypes": [
        "scala",
        "sbt"
      ]
    }

Is this incorrect? Should I remove this snippet from the coc-settings.json?

jsatk commented 4 years ago

After removing the metals section from coc-settings.json, deleting the .metals & .bloop folder, and re-importing via Coc + Metals I am down to two duplicate recommendations rather than three. So improvement. But would love to get it down to only one.

Screen Shot 2020-01-07 at 10 41 32 AM
jsatk commented 4 years ago

It appears the installation instructions have changed here: https://scalameta.org/metals/docs/editors/vim.html#installing-coc-metals

I'd previously installed metals-vim via a coursier command.

./coursier bootstrap \
  --java-opt -Xss4m \
  --java-opt -Xms100m \
  --java-opt -Dmetals.client=coc.nvim \
  org.scalameta:metals_2.12:0.7.6 \
  -r bintray:scalacenter/releases \
  -r sonatype:snapshots \
  -o /usr/local/bin/metals-vim -f

After I manually rm -f /usr/local/bin/metals-vim I'm only getting one LSP suggestion via Coc's autosuggest.

~Gonna do a bit more testing and then close this issue if doing these two things fixes it.~

It appears to have fixed it. Thank you!

ckipp01 commented 4 years ago

I'm glad you seem to have gotten it figured out @jsatk! What you did was exactly what I would have recommended. By having both the coc-metals extension installed and it manually in your coc.settings.json it was starting two different instances of Metals when you opened a project.

The docs were hugely updated a couple of weeks ago when coc-metals was released. If you have any other questions, don't hesitate to ask.