@@ -18,6 +18,7 @@ export function activate(context: ExtensionContext) {
18
18
19
19
const sbtArtifact = "org.scala-sbt:sbt-launch:1.1.5"
20
20
const loadPluginArtifact = "ch.epfl.scala:load-plugin_2.12:0.1.0+2-496ac670"
21
+ const buildSbtFile = `${ vscode . workspace . rootPath } /build.sbt`
21
22
const languageServerArtifactFile = `${ vscode . workspace . rootPath } /.dotty-ide-artifact`
22
23
const languageServerDefaultConfigFile = path . join ( extensionContext . extensionPath , './out/default-dotty-ide-config' )
23
24
const coursierPath = path . join ( extensionContext . extensionPath , './out/coursier' ) ;
@@ -37,21 +38,20 @@ export function activate(context: ExtensionContext) {
37
38
} )
38
39
39
40
} 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 ) ) {
44
46
fs . readFile ( languageServerDefaultConfigFile , ( err , data ) => {
45
47
if ( err ) throw err
46
48
else {
47
49
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
+ } )
51
53
}
52
54
} )
53
- } else {
54
- runLanguageServer ( coursierPath , languageServerArtifactFile )
55
55
}
56
56
}
57
57
}
0 commit comments