@@ -16,9 +16,9 @@ export function activate(context: ExtensionContext) {
1616 extensionContext = context
1717 outputChannel = vscode . window . createOutputChannel ( 'Dotty Language Client' ) ;
1818
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"
2120 const buildSbtFile = `${ vscode . workspace . rootPath } /build.sbt`
21+ const dottyPluginSbtFile = path . join ( extensionContext . extensionPath , './out/dotty-plugin.sbt' )
2222 const languageServerArtifactFile = `${ vscode . workspace . rootPath } /.dotty-ide-artifact`
2323 const languageServerDefaultConfigFile = path . join ( extensionContext . extensionPath , './out/default-dotty-ide-config' )
2424 const coursierPath = path . join ( extensionContext . extensionPath , './out/coursier' ) ;
@@ -51,8 +51,8 @@ export function activate(context: ExtensionContext) {
5151 fs . readFile ( languageServerDefaultConfigFile , ( err , data ) => {
5252 if ( err ) throw err
5353 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 ( ( ) => {
5656 runLanguageServer ( coursierPath , languageServerArtifactFile )
5757 } )
5858 }
@@ -78,15 +78,10 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
7878 } )
7979}
8080
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+ } )
9085}
9186
9287function fetchWithCoursier ( coursierPath : string , artifact : string , extra : string [ ] = [ ] ) {
@@ -108,10 +103,6 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
108103 coursierProc . stdout . on ( 'data' , ( data : Buffer ) => {
109104 classPath += data . toString ( ) . trim ( )
110105 } )
111- coursierProc . stderr . on ( 'data' , ( data : Buffer ) => {
112- let msg = data . toString ( ) . trim ( )
113- outputChannel . append ( msg )
114- } )
115106
116107 coursierProc . on ( 'close' , ( code : number ) => {
117108 if ( code != 0 ) {
@@ -124,27 +115,20 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
124115 } )
125116}
126117
127- function configureIDE ( sbtClasspath : string , languageServerScalaVersion : string , sbtDottyVersion : string , loadPluginJar : string ) {
118+ function configureIDE ( sbtClasspath : string , languageServerScalaVersion : string , dottyPluginSbtFile : string ) {
128119 return vscode . window . withProgress ( {
129120 location : vscode . ProgressLocation . Window ,
130121 title : 'Configuring IDE...'
131122 } , ( 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 ( " " )
139123
140124 // Run sbt to configure the IDE. If the `DottyPlugin` is not present, dynamically load it and
141125 // eventually run `configureIDE`.
142126 const sbtPromise =
143127 cpp . spawn ( "java" , [
144128 "-classpath" , sbtClasspath ,
145129 "xsbt.boot.Boot" ,
146- applyLoadPlugin ,
147- ifAbsentCommands ,
130+ `--addPluginSbtFile= ${ dottyPluginSbtFile } ` ,
131+ `set every scalaVersion := " ${ languageServerScalaVersion } "` ,
148132 "configureIDE"
149133 ] )
150134
@@ -157,7 +141,7 @@ function configureIDE(sbtClasspath: string, languageServerScalaVersion: string,
157141 }
158142 } )
159143
160- return sbtPromise
144+ return sbtPromise
161145 } )
162146}
163147
0 commit comments