scalameta / metals

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

Scala CLI dependency completions disabled by double colon #5300

Closed keynmol closed 1 year ago

keynmol commented 1 year ago

Describe the bug

If you use double colon (in the last position) in the dependency spec, it disables the completions

//> using lib com.outr::scribe-cats:@@ works
//> using lib com.outr::scribe-cats::@@ doesn't work

2023-06-02 09 39 30

Expected behavior

Dependency is completed regardless.

Discussion point: should Metals always complete using :: to always work with cross-platform scripts? Is there any risk in defaulting to ::?

Operating system

macOS

Editor/Extension

Nvim (nvim-metals)

Version of Metals

v0.11.12+89-6dc03ef0-SNAPSHOT

Extra context or search terms

completions, scala-cli, dependency, colon

jkciesluk commented 1 year ago

I wasn't aware this syntax is correct, it should be an easy fix. It looks like complete from coursier returns empty completions, so maybe we can just remove last : for completion, and then add it back. Are all versions allowed after ::?

jkciesluk commented 1 year ago

If we can show the same completions in both cases (after : and ::), then I have a fix ready, but I would wait for merging https://github.com/scalameta/metals/pull/5206 first

keynmol commented 1 year ago

The way I see it, there are two ways of doing it:

  1. (more work) If the current file/build target has an explicit using platform directive, then we can limit coursier completions to only those with _sjs1/_native0.4 suffix - meaning you only get completions for versions that are published for your target.
  2. (less work) Always suggest ::, don't take platform into account. This should limit the number of times my website needs to be mentioned :D

:: will work on jvm,js,native : only works on jvm

SBT out of the box doesn't have %%% operator, so the docs cannot recommend to always use %%% for all dependencies.

Scala CLI understands : and :: out of the box, and there is no harm to using :: even if your project is purely JVM.

tgodzik commented 1 year ago

@jkciesluk you were looking into this last time we spoke, right?

jkciesluk commented 1 year ago

solved by https://github.com/scalameta/metals/pull/5373