Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 4b07c41

Browse files
authored
Update for Metals v0.6 (#81)
* Add custom metals/windowStateDidChange notification
1 parent 5eb3b93 commit 4b07c41

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/scala/servers/Metals.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class HtmlView(title: String) extends js.Object {
2626
object Metals extends ScalaLanguageServer { server =>
2727
val name: String = "metals"
2828
val description: String = "Metals"
29-
val defaultVersion: String = "0.5.2"
29+
val defaultVersion: String = "0.6.1"
3030

3131
def trigger(projectPath: String): Boolean = {
3232
(projectPath / ".metals").isDirectory
@@ -109,6 +109,21 @@ object Metals extends ScalaLanguageServer { server =>
109109
}
110110
})
111111

112+
// Send windowStateDidChange notification to Metals every time window is in/out of focus
113+
Atom.asInstanceOf[js.Dynamic].getCurrentWindow()
114+
.on("focus", { _: js.Any =>
115+
connection.sendCustomNotification(
116+
"metals/windowStateDidChange",
117+
js.Dynamic.literal("focused" -> true)
118+
)
119+
})
120+
.on("blur", { _: js.Any =>
121+
connection.sendCustomNotification(
122+
"metals/windowStateDidChange",
123+
js.Dynamic.literal("focused" -> false)
124+
)
125+
})
126+
112127
Atom.workspace.onDidChangeActiveTextEditor { editorOrUndef =>
113128
for {
114129
editor <- editorOrUndef

0 commit comments

Comments
 (0)