@@ -16,9 +16,9 @@ export function activate(context: ExtensionContext) {
16
16
extensionContext = context
17
17
outputChannel = vscode . window . createOutputChannel ( 'Dotty Language Client' ) ;
18
18
19
- const sbtArtifact = "org.scala-sbt:sbt-launch:1.1.5"
20
- const loadPluginArtifact = "ch.epfl.scala:load-plugin_2.12:0.1.0+2-496ac670"
19
+ const sbtArtifact = "org.scala-sbt:sbt-launch:1.2.0"
21
20
const buildSbtFile = `${ vscode . workspace . rootPath } /build.sbt`
21
+ const dottyPluginSbtFile = path . join ( extensionContext . extensionPath , './out/dotty-plugin.sbt' )
22
22
const languageServerArtifactFile = `${ vscode . workspace . rootPath } /.dotty-ide-artifact`
23
23
const languageServerDefaultConfigFile = path . join ( extensionContext . extensionPath , './out/default-dotty-ide-config' )
24
24
const coursierPath = path . join ( extensionContext . extensionPath , './out/coursier' ) ;
@@ -51,8 +51,8 @@ export function activate(context: ExtensionContext) {
51
51
fs . readFile ( languageServerDefaultConfigFile , ( err , data ) => {
52
52
if ( err ) throw err
53
53
else {
54
- const [ languageServerScalaVersion , sbtDottyVersion ] = data . toString ( ) . trim ( ) . split ( / \r ? \n / )
55
- fetchAndConfigure ( coursierPath , sbtArtifact , languageServerScalaVersion , sbtDottyVersion , loadPluginArtifact ) . then ( ( ) => {
54
+ const languageServerScalaVersion = data . toString ( ) . trim ( )
55
+ fetchAndConfigure ( coursierPath , sbtArtifact , languageServerScalaVersion , dottyPluginSbtFile ) . then ( ( ) => {
56
56
runLanguageServer ( coursierPath , languageServerArtifactFile )
57
57
} )
58
58
}
@@ -78,15 +78,10 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
78
78
} )
79
79
}
80
80
81
- function fetchAndConfigure ( coursierPath : string , sbtArtifact : string , languageServerScalaVersion : string , sbtDottyVersion : string , loadPluginArtifact : string ) {
82
- const sbtPromise = fetchWithCoursier ( coursierPath , sbtArtifact )
83
- const loadPluginPromise = fetchWithCoursier ( coursierPath , loadPluginArtifact )
84
-
85
- return Promise . all ( [ sbtPromise , loadPluginPromise ] ) . then ( ( results ) => {
86
- const [ sbtClasspath , loadPluginJar ] = results
87
- return configureIDE ( sbtClasspath , languageServerScalaVersion , sbtDottyVersion , loadPluginJar )
88
- } )
89
-
81
+ function fetchAndConfigure ( coursierPath : string , sbtArtifact : string , languageServerScalaVersion : string , dottyPluginSbtFile : string ) {
82
+ return fetchWithCoursier ( coursierPath , sbtArtifact ) . then ( ( sbtClasspath ) => {
83
+ return configureIDE ( sbtClasspath , languageServerScalaVersion , dottyPluginSbtFile )
84
+ } )
90
85
}
91
86
92
87
function fetchWithCoursier ( coursierPath : string , artifact : string , extra : string [ ] = [ ] ) {
@@ -108,10 +103,6 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
108
103
coursierProc . stdout . on ( 'data' , ( data : Buffer ) => {
109
104
classPath += data . toString ( ) . trim ( )
110
105
} )
111
- coursierProc . stderr . on ( 'data' , ( data : Buffer ) => {
112
- let msg = data . toString ( ) . trim ( )
113
- outputChannel . append ( msg )
114
- } )
115
106
116
107
coursierProc . on ( 'close' , ( code : number ) => {
117
108
if ( code != 0 ) {
@@ -124,27 +115,20 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
124
115
} )
125
116
}
126
117
127
- function configureIDE ( sbtClasspath : string , languageServerScalaVersion : string , sbtDottyVersion : string , loadPluginJar : string ) {
118
+ function configureIDE ( sbtClasspath : string , languageServerScalaVersion : string , dottyPluginSbtFile : string ) {
128
119
return vscode . window . withProgress ( {
129
120
location : vscode . ProgressLocation . Window ,
130
121
title : 'Configuring IDE...'
131
122
} , ( progress ) => {
132
- const applyLoadPlugin = `apply -cp ${ loadPluginJar } ch.epfl.scala.loadplugin.LoadPlugin`
133
- const ifAbsentCommands = [
134
- "if-absent dotty.tools.sbtplugin.DottyPlugin" ,
135
- "\"set every scalaVersion := \\\"" + languageServerScalaVersion + "\\\"\"" ,
136
- "\"load-plugin ch.epfl.lamp:sbt-dotty:" + sbtDottyVersion + " dotty.tools.sbtplugin.DottyPlugin\"" ,
137
- "\"load-plugin ch.epfl.lamp:sbt-dotty:" + sbtDottyVersion + " dotty.tools.sbtplugin.DottyIDEPlugin\""
138
- ] . join ( " " )
139
123
140
124
// Run sbt to configure the IDE. If the `DottyPlugin` is not present, dynamically load it and
141
125
// eventually run `configureIDE`.
142
126
const sbtPromise =
143
127
cpp . spawn ( "java" , [
144
128
"-classpath" , sbtClasspath ,
145
129
"xsbt.boot.Boot" ,
146
- applyLoadPlugin ,
147
- ifAbsentCommands ,
130
+ `--addPluginSbtFile= ${ dottyPluginSbtFile } ` ,
131
+ `set every scalaVersion := " ${ languageServerScalaVersion } "` ,
148
132
"configureIDE"
149
133
] )
150
134
@@ -157,7 +141,7 @@ function configureIDE(sbtClasspath: string, languageServerScalaVersion: string,
157
141
}
158
142
} )
159
143
160
- return sbtPromise
144
+ return sbtPromise
161
145
} )
162
146
}
163
147
0 commit comments