scalameta / coc-metals

Deprecated in favor of scalameta/nvim-metals
http://scalameta.org/metals/
Apache License 2.0
167 stars 24 forks source link

How to use CLASSPATH for completion without build tools? #422

Closed qwqawawow closed 3 years ago

qwqawawow commented 3 years ago

Like this?(Sorry for my poor English) https://github.com/neoclide/coc-java/issues/162

ckipp01 commented 3 years ago

Hi @eihqnh, looking at the linked issue I'm not fully sure what you're asking. Could you explain a bit more of what you're trying to achieve?

qwqawawow commented 3 years ago

Hi @eihqnh, looking at the linked issue I'm not fully sure what you're asking. Could you explain a bit more of what you're trying to achieve?

Hi,@ckipp01 I'm sorry for my carelessness I hope coc-metals can complete the dependency relationship according to the classpath. For example: I'm in a project without a build tool, and export classpath=/opt/library.jar, then start nvim, and coc-metals will parse the library.jar Does this function exist? I don't seem to find it

ckipp01 commented 3 years ago

So unfortunately this really isn't possible. Metals will work with a standalone Scala file btw, but it won't take into account you passing in a classpath or anything. The only way to get access to a classpath is once you start having build targets, which you'll need a build tool for.

In what scenario are you not using a build tool, but instead just a classpath? I'm not really familiar with a situation in Scala where this is common practice or recommended as I can imagine it's quite fragile to work with.

qwqawawow commented 3 years ago

So unfortunately this really isn't possible. Metals will work with a standalone Scala file btw, but it won't take into account you passing in a classpath or anything. The only way to get access to a classpath is once you start having build targets, which you'll need a build tool for.

In what scenario are you not using a build tool, but instead just a classpath? I'm not really familiar with a situation in Scala where this is common practice or recommended as I can imagine it's quite fragile to work with.

I want to code Scala without other tools like sbt,bloop beacuse my program is too simple to use these tools.(Just like a simple testing) Using classpath to develop Is really a bad idea. Thank you very much

ckipp01 commented 3 years ago

One thing that might be helpful for you @eihqnh is depending on how simple your application is, you can also write it as an Ammonite script, which doesn't need a build tool, you can include imports, and run it. This might be a way for you to get what you want without needing a buildtool.

qwqawawow commented 3 years ago

One thing that might be helpful for you @eihqnh is depending on how simple your application is, you can also write it as an Ammonite script, which doesn't need a build tool, you can include imports, and run it. This might be a way for you to get what you want without needing a buildtool.

Thank you very much. I will try it😉