-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl status bar and optimize self highlight
- Loading branch information
Showing
8 changed files
with
132 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/kotlin/com/cppcxy/ide/editor/statusbar/StatusBarWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.cppcxy.ide.editor.statusbar | ||
|
||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.StatusBarWidget | ||
import com.intellij.openapi.wm.StatusBarWidget.WidgetPresentation | ||
import com.intellij.openapi.wm.StatusBarWidgetFactory | ||
|
||
|
||
class StatusBarWidgetFactory() : StatusBarWidgetFactory { | ||
override fun getId(): String { | ||
return ID | ||
} | ||
|
||
override fun getDisplayName(): String { | ||
return "Sumneko Lua" | ||
} | ||
|
||
override fun createWidget(project: Project): StatusBarWidget { | ||
return SumnekoBar() | ||
} | ||
|
||
override fun isEnabledByDefault(): Boolean { | ||
return true | ||
} | ||
|
||
override fun isAvailable(project: Project): Boolean { | ||
return true | ||
} | ||
|
||
class SumnekoBar() : StatusBarWidget, StatusBarWidget.TextPresentation { | ||
var toolTip = "Sumneko LSP" | ||
var message = "Lua" | ||
|
||
override fun ID(): String { | ||
return ID | ||
} | ||
|
||
override fun getPresentation(): WidgetPresentation { | ||
return this | ||
} | ||
|
||
override fun getAlignment(): Float { | ||
return 0.0f | ||
} | ||
|
||
override fun getText(): String { | ||
return message | ||
} | ||
|
||
override fun getTooltipText(): String { | ||
return toolTip | ||
} | ||
} | ||
|
||
companion object { | ||
private val ID: String = "SumnekoBar" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.cppcxy.ide.lsp | ||
|
||
data class StatusReport( | ||
val text: String, | ||
val tooltip: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.cppcxy.ide.lsp | ||
|
||
import com.cppcxy.ide.editor.statusbar.StatusBarWidgetFactory | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.wm.WindowManager | ||
import com.intellij.platform.lsp.api.Lsp4jClient | ||
import com.intellij.platform.lsp.api.LspServerNotificationsHandler | ||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification | ||
|
||
class SumnekoClient(private val serverNotificationsHandler: LspServerNotificationsHandler, val project: Project) : | ||
Lsp4jClient(serverNotificationsHandler) { | ||
|
||
@JsonNotification("$/status/show") | ||
fun statusShow() { | ||
} | ||
|
||
@JsonNotification("$/status/hide") | ||
fun statusHide() { | ||
} | ||
|
||
@JsonNotification("$/status/report") | ||
fun statusReport(report: StatusReport) { | ||
val statusBar = WindowManager.getInstance().getStatusBar(project) | ||
val widget = statusBar.getWidget("SumnekoBar") as StatusBarWidgetFactory.SumnekoBar? | ||
if (widget != null) { | ||
widget.message = report.text | ||
widget.toolTip = report.tooltip | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters