-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Configure IDE with sbt server #5160
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
Configure IDE with sbt server #5160
Conversation
vscode-dotty/src/extension.ts
Outdated
const sbtCheckIntervalMs = 10 * 1000 | ||
|
||
/** A command that we use to check that sbt is still alive. */ | ||
export const nopCommand = "nop" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the way to do things:
- If the connection with sbt is closed, we don't need this since we can have a callback on connection.onClose
- If sbt blocks while running something, then we will never get a response since there's no timeout for a response
- We can't add a timeout for the response, because an sbt command can take an arbitrarily long time to finish (e.g. running tests) and sbt cannot execute more than one command at once.
I think a real solution will require changes to sbt, but I don't know what exactly.
3f453b4
to
1601cda
Compare
Remove |
This commis adds a status bar that shows the status of sbt server, and a timer that periodically checks that sbt server is still alive, starting a new instance if necessary.
We use `connection.onClose` to automatically reconnect when the connection with sbt is closed.
1601cda
to
c1f0e75
Compare
@smarter Everything seems to work on Windows now! |
@@ -71,7 +71,7 @@ | |||
"scala-lang.scala" | |||
], | |||
"dependencies": { | |||
"child-process-promise": "^2.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove this then https://github.com/lampepfl/dotty/blob/786788b97800dd70841472e999c5f4a286426486/vscode-dotty/src/types.d.ts should be removed or updated too.
vscode-dotty/src/extension.ts
Outdated
@@ -3,7 +3,7 @@ | |||
import * as fs from 'fs'; | |||
import * as path from 'path'; | |||
|
|||
import * as cpp from 'child-process-promise'; | |||
import * as cpp from 'promisify-child-process'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be pcp instead of cpp, or childProcess if we want to be explicit.
vscode-dotty/src/extension.ts
Outdated
const sbtBuildSbtFile = path.join(workspaceRoot, "build.sbt") | ||
const languageServerArtifactFile = path.join(workspaceRoot, ".dotty-ide-artifact") | ||
|
||
function isUnconfiguredProject() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call this isConfiguredProject to avoid too many negations ?
vscode-dotty/src/extension.ts
Outdated
} | ||
}) | ||
} | ||
|
||
configuredProject | ||
.then(_ => connectToSbt(coursierPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since starting sbt and running configureIDE might be very slow, I suggest we do not do it if the project has already been configured once (i.e., .dotty-ide-artifact, .dotty-ide.json are present). In the future, the Dotty Language Server will decide itself if it should query the build tool for configuration options.
b7aa9fd
to
d57c16a
Compare
Right, I changed it.
Argh, thanks, I fixed it too. |
@@ -83,7 +82,7 @@ export function activate(context: ExtensionContext) { | |||
|
|||
} else { | |||
let configuredProject: Thenable<void> = Promise.resolve() | |||
if (isUnconfiguredProject()) { | |||
if (!isConfiguredProject()) { | |||
configuredProject = vscode.window.showInformationMessage( | |||
"This looks like an unconfigured Scala project. Would you like to start the Dotty IDE?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this message is still going to be shown if disableDottyIDEFile is present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
This commit changes the behavior of the IDE so that it runs `configureIDE` only if the project hasn't been configured yet. sbt will now be started only if necessary, and the server will not be kept alive longer than necessary.
d57c16a
to
d27f5a4
Compare
build.sbt
project/build.properties
project/plugins.sbt
configureIDE
usingsbt/exec