Skip to content

Commit 80f6278

Browse files
committed
Use load-plugin only when there's no build.sbt
1 parent bc19afe commit 80f6278

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

vscode-dotty/src/extension.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function activate(context: ExtensionContext) {
1818

1919
const sbtArtifact = "org.scala-sbt:sbt-launch:1.1.5"
2020
const loadPluginArtifact = "ch.epfl.scala:load-plugin_2.12:0.1.0+2-496ac670"
21+
const buildSbtFile = `${vscode.workspace.rootPath}/build.sbt`
2122
const languageServerArtifactFile = `${vscode.workspace.rootPath}/.dotty-ide-artifact`
2223
const languageServerDefaultConfigFile = path.join(extensionContext.extensionPath, './out/default-dotty-ide-config')
2324
const coursierPath = path.join(extensionContext.extensionPath, './out/coursier');
@@ -37,21 +38,20 @@ export function activate(context: ExtensionContext) {
3738
})
3839

3940
} else {
40-
41-
// Check whether `.dotty-ide-artifact` exists to know whether the IDE has been already
42-
// configured (via `configureIDE` for instance). If not, start sbt and run `configureIDE`.
43-
if (!fs.existsSync(languageServerArtifactFile)) {
41+
// Check whether `.dotty-ide-artifact` exists. If it does, start the language server,
42+
// otherwise, try to auto-configure it if there's no build.sbt
43+
if (fs.existsSync(languageServerArtifactFile)) {
44+
runLanguageServer(coursierPath, languageServerArtifactFile)
45+
} else if (!fs.existsSync(buildSbtFile)) {
4446
fs.readFile(languageServerDefaultConfigFile, (err, data) => {
4547
if (err) throw err
4648
else {
4749
const [languageServerScalaVersion, sbtDottyVersion] = data.toString().trim().split(/\r?\n/)
48-
fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, sbtDottyVersion, loadPluginArtifact).then(() => {
49-
runLanguageServer(coursierPath, languageServerArtifactFile)
50-
})
50+
fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, sbtDottyVersion, loadPluginArtifact).then(() => {
51+
runLanguageServer(coursierPath, languageServerArtifactFile)
52+
})
5153
}
5254
})
53-
} else {
54-
runLanguageServer(coursierPath, languageServerArtifactFile)
5555
}
5656
}
5757
}

0 commit comments

Comments
 (0)