Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ólafur Páll Geirsson
    @olafurpg
    metals can be distributed an an offline app by running the provided main method that downloads dependencies. As long as you cache the coursier directory then metals can run without accessing the internet. My observation is that demand for offline-only usage is in decline.
    As for providing a library API, you are free to poke into internal interfaces but they are subject to breaking changes on every release. Some components inside metals are more stable than others.
    It’s not too different from the Scala 2 presentation compiler API. One difference is that the Metals implementations are explicitly inside “internal” packages to document expectations about stability
    Ólafur Páll Geirsson
    @olafurpg
    As for semantic highlighting, i think the hard parts are already implemented to support this feature. Nobody has pushed hard enough to implement it yet
    Hanns Holger Rutz
    @Sciss
    thanks ólafur for the various explanations! I will try first with coursier auto management and not directly include metals in published jars
    Ólafur Páll Geirsson
    @olafurpg
    @Sciss you can pupulate the download cache by calling this dedicated main method https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/metals/DownloadDependencies.scala
    heksesang
    @heksenlied:matrix.org
    [m]
    It seems that vscode gets stuck indexing when I try to import projects with a large number of modules. Is this a known problem?
    (The import works fine, but then it just says "Indexing..." in the bottom right corner forever after that.)
    Ólafur Páll Geirsson
    @olafurpg
    @heksenlied:matrix.org are you using the latest version of your JVM? There was a bug in an older JVM 11 version that caused an infinte loop
    Could you try to run async-profiler on the metals process to see what it’s doing? https://github.com/jvm-profiling-tools/async-profiler
    heksesang
    @heksenlied:matrix.org
    [m]
    Hmmm... Thought I was running the latest, but according to the output panel I am using Java 11.
    I'll try with a later version and see if that solves it.
    heksesang
    @heksenlied:matrix.org
    [m]
    Seems the problem goes away if I use Java 16.
    Ólafur Páll Geirsson
    @olafurpg
    @heksenlied:matrix.org you might be able to use a newer version of JVM 11
    Markus Appel
    @markusa380
    Quick question, is there any way that I can stop Metals on Visual Studio Code from starting SBT when using SBT as language server? I'd rather start SBT manually and have it connect, but it's always faster than me.
    sbt --client works but still has bugs with autocompletion and disconnects on Mac so
    Andreas Flierl
    @asflierl
    That's something I wish for as well – especially since the implicitly started SBT server does not utilize the flags given in .jvmopts 🤕
    Chris Kipp
    @ckipp:matrix.org
    [m]
    @asflierl: I believe it should, as when we compose the args to create the actual bsp file args, we do look at them https://github.com/scalameta/metals/blob/6fd19300ed684410875db340e329cb85a42c58f2/metals/src/main/scala/scala/meta/internal/builds/SbtBuildTool.scala#L83-L84
    this could be that when that file is generated by sbt and not metals, it doesn't take them into account
    it's worth filing an issue
    @markusa380: could you elaborate a bit more? sbt server needs to be started in order for it to function as a BSP server
    an alternative would be to start sbt --client first in the workspace, then open the project in Metals if you've chose sbt as a BSP server
    then it'd just connect to the already running server
    Markus Appel
    @markusa380
    @ckipp:matrix.org of course Metals needs SBT to function as BSP, but it would be a bit more ergonomic to "wait" for an SBT instance instead of starting one unasked. It is after all a tool that integrates with SBT less than SBT being a tool integrating with Metals.
    To rephrase, I need to use SBT and Metals, and Metals depends on SBT, so Metals should not start SBT, because I also need SBT. So I should start SBT and Metals should pick that up, as it already does when starting SBT itself and waiting for it to boot up
    It should at least be a flag one can set in the preferences that make Metals wait for a server instead of starting one.
    Or, what would also work, and might solve more than just this issue, is if the command to start SBT is configurable.
    Chris Kipp
    @ckipp:matrix.org
    [m]
    well both Metals and sbt are implementing BSP here, and according to BSP discover, if a .bsp/<server>.json file exists, that's an indication that it should be started. So in this situation when you've chosen to use sbt as a build server at some point in time and open the project, metals remembers that, follows BSP discovery rules and starts the server since it needs that in order to function
    Markus Appel
    @markusa380

    There's this setting already:

    Sbt Script
    Optional absolute path to an sbt executable to use for running sbt bloopInstall.
    By default, Metals uses java -jar sbt-launch.jar with an embedded launcher while respecting .jvmopts and .sbtopts.
    Update this setting if your sbt script requires more customizations like using environment variables.

    But this is not honored.

    4 replies
    Chris Kipp
    @ckipp:matrix.org
    [m]

    It should at least be a flag one can set in the preferences that make Metals wait for a server instead of starting one.

    But metals would sort of be unusable until that happened

    Markus Appel
    @markusa380
    We unfortunately have the special case here that SBT cannot run twice on the same project without severe problems
    Yes of course it wouldn't be usable until that
    Chris Kipp
    @ckipp:matrix.org
    [m]
    but when sbt server is running for a workspace, it only runs once right? So does starting sbt server first and then vs code work in this scenario?
    because even then, only one sbt instance would be running
    Markus Appel
    @markusa380
    But currently it's making my life harder because I need to hard kill the implicitly started SBT instance to start my explicit SBT instance so I can run SBT commands and force clean/recompile on demand

    So does starting sbt server first and then vs code work in this scenario?

    Yes, it would, but I want to of course use the integrated terminal to avoid alt-tabbing between the windows. Most people prefer that I think.

    Chris Kipp
    @ckipp:matrix.org
    [m]
    well the way that it's launched is actually defined in your .bsp/sbt.json file
    Markus Appel
    @markusa380
    Would it be up to BSP spec to start an instance of SBT explicitly in the integrated terminal? That would make sense in more than one way.
    Chris Kipp
    @ckipp:matrix.org
    [m]
    when looking in there, I'm assuming you don't see the env variables you're looking for?
    if that's the case please do submit an issue with a reproduction
    Markus Appel
    @markusa380
    I don't even know what this JSON file contains as info, can I just "hack" it to not start SBT somehow?
    Again, I'm completely okay with not having functionality until SBT is started. I just want to be able to use SBT at the same time as using Metals.
    Chris Kipp
    @ckipp:matrix.org
    [m]
    I'm still not sure I understand why you can't. Even after metals starts sbt, you should still be able to open your terminal, connect to the running server and issue commands
    Markus Appel
    @markusa380
    With SBT being more important as it tells me when it's done with compilation, while Metals leaves me to guess depending on how many seconds ago the list of errors has changed.
    Because SBTN is a buggy mess.
    Chris Kipp
    @ckipp:matrix.org
    [m]
    also, are you issueing compile command via sbt in this scenario?
    Markus Appel
    @markusa380
    It randomly disconnects, and selecting recent commands with [Arrow Up] or pressing tab for autocomplete bugs out if SBT is busy
    Sometimes
    Chris Kipp
    @ckipp:matrix.org
    [m]
    I mean if sbt is your build server then compiling manually via sbt is redundant as a save in VS Code will also trigger the same compile
    Markus Appel
    @markusa380
    Metals leaves me to guess [when compile is done] depending on how many seconds ago the list of errors has changed.