Skip to content

Let VSCode start the language server #4304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use load-plugin only when there's no build.sbt
  • Loading branch information
Duhemm committed Sep 14, 2018
commit 993ef22e5f8d0f0aa1081aef350096266a496b09
18 changes: 9 additions & 9 deletions vscode-dotty/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function activate(context: ExtensionContext) {

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

} else {

// Check whether `.dotty-ide-artifact` exists to know whether the IDE has been already
// configured (via `configureIDE` for instance). If not, start sbt and run `configureIDE`.
if (!fs.existsSync(languageServerArtifactFile)) {
// Check whether `.dotty-ide-artifact` exists. If it does, start the language server,
// otherwise, try to auto-configure it if there's no build.sbt
if (fs.existsSync(languageServerArtifactFile)) {
runLanguageServer(coursierPath, languageServerArtifactFile)
} else if (!fs.existsSync(buildSbtFile)) {
fs.readFile(languageServerDefaultConfigFile, (err, data) => {
if (err) throw err
else {
const [languageServerScalaVersion, sbtDottyVersion] = data.toString().trim().split(/\r?\n/)
fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, sbtDottyVersion, loadPluginArtifact).then(() => {
runLanguageServer(coursierPath, languageServerArtifactFile)
})
fetchAndConfigure(coursierPath, sbtArtifact, languageServerScalaVersion, sbtDottyVersion, loadPluginArtifact).then(() => {
runLanguageServer(coursierPath, languageServerArtifactFile)
})
}
})
} else {
runLanguageServer(coursierPath, languageServerArtifactFile)
}
}
}
Expand Down