Search code examples
scalavisual-studio-codesbtscala-metals

Visual Studio Code: how can I import the `sbt`-changes


After adding another dependency in build.sbt - how can I import the sbt-changes?

With the Command Reload Window it works but it reloads everything (like bloob).

Is there a way just to just import the sbt-changes?


Solution

  • Metals extension supports natively importing sbt changes

    When you change build.sbt or sources under project/, you will be prompted to re-import the build.

    enter image description here

    We can also manually import the changes by executing Metals: Import Build command.


    Without Metals perhaps try Send text from a keybinding to terminal which executes sbt reload; update by navigating to View | Command Palette | Preferences: Open Keyboard Shortcuts (JSON) and defining the following, say, cmd+shift+R shortcut:

    [
        {
            "key": "cmd+shift+R",
            "command": "workbench.action.terminal.sendSequence",
            "args": {
              "text": ";reload; update\u000D"
            }
          }
    ]
    

    cmd+shift+R should now just reload sbt changes instead of reloading whole Visual Studio Code window.