chore: Add lang for ZLS management
This commit is contained in:
parent
520167414a
commit
bd47cb201f
5 changed files with 29 additions and 25 deletions
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.lsp.zls
|
package com.falsepattern.zigbrains.lsp.zls
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
||||||
import com.falsepattern.zigbrains.lsp.settings.ZLSSettingsPanel
|
import com.falsepattern.zigbrains.lsp.settings.ZLSSettingsPanel
|
||||||
import com.falsepattern.zigbrains.project.toolchain.local.LocalZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.local.LocalZigToolchain
|
||||||
import com.falsepattern.zigbrains.project.toolchain.ui.ImmutableNamedElementPanelBase
|
import com.falsepattern.zigbrains.project.toolchain.ui.ImmutableNamedElementPanelBase
|
||||||
|
@ -49,7 +50,7 @@ import kotlin.io.path.pathString
|
||||||
class ZLSPanel() : ImmutableNamedElementPanelBase<ZLSVersion>() {
|
class ZLSPanel() : ImmutableNamedElementPanelBase<ZLSVersion>() {
|
||||||
private val pathToZLS = textFieldWithBrowseButton(
|
private val pathToZLS = textFieldWithBrowseButton(
|
||||||
null,
|
null,
|
||||||
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle("Path to the zls executable")
|
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle(ZLSBundle.message("dialog.title.zls"))
|
||||||
).also {
|
).also {
|
||||||
it.textField.document.addDocumentListener(object : DocumentAdapter() {
|
it.textField.document.addDocumentListener(object : DocumentAdapter() {
|
||||||
override fun textChanged(e: DocumentEvent) {
|
override fun textChanged(e: DocumentEvent) {
|
||||||
|
@ -64,14 +65,14 @@ class ZLSPanel() : ImmutableNamedElementPanelBase<ZLSVersion>() {
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(p: Panel): Unit = with(p) {
|
||||||
super.attach(p)
|
super.attach(p)
|
||||||
row("Path:") {
|
row(ZLSBundle.message("settings.panel.path.label")) {
|
||||||
cell(pathToZLS).resizableColumn().align(AlignX.FILL)
|
cell(pathToZLS).resizableColumn().align(AlignX.FILL)
|
||||||
}
|
}
|
||||||
row("Version:") {
|
row(ZLSBundle.message("settings.panel.version.label")) {
|
||||||
cell(zlsVersion)
|
cell(zlsVersion)
|
||||||
}
|
}
|
||||||
val sp = ZLSSettingsPanel()
|
val sp = ZLSSettingsPanel()
|
||||||
p.collapsibleGroup("Settings", indent = false) {
|
p.collapsibleGroup(ZLSBundle.message("settings.panel.settings.group.label"), indent = false) {
|
||||||
sp.attach(this@collapsibleGroup)
|
sp.attach(this@collapsibleGroup)
|
||||||
}
|
}
|
||||||
settingsPanel = sp
|
settingsPanel = sp
|
||||||
|
|
|
@ -22,22 +22,19 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.lsp.zls.downloader
|
package com.falsepattern.zigbrains.lsp.zls.downloader
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
||||||
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
||||||
import com.falsepattern.zigbrains.lsp.zls.ui.getSuggestedZLSPath
|
import com.falsepattern.zigbrains.lsp.zls.ui.getSuggestedZLSPath
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider.IUserDataBridge
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider.IUserDataBridge
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
||||||
import com.falsepattern.zigbrains.shared.downloader.Downloader
|
import com.falsepattern.zigbrains.shared.downloader.Downloader
|
||||||
import com.intellij.openapi.util.io.toNioPathOrNull
|
|
||||||
import com.intellij.util.system.OS
|
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
import java.nio.file.Path
|
|
||||||
import kotlin.io.path.isDirectory
|
|
||||||
|
|
||||||
class ZLSDownloader(component: Component, private val data: IUserDataBridge?) : Downloader<ZLSVersion, ZLSVersionInfo>(component) {
|
class ZLSDownloader(component: Component, private val data: IUserDataBridge?) : Downloader<ZLSVersion, ZLSVersionInfo>(component) {
|
||||||
override val windowTitle get() = "Install ZLS"
|
override val windowTitle get() = ZLSBundle.message("settings.downloader.title")
|
||||||
override val versionInfoFetchTitle get() = "Fetching zls version information"
|
override val versionInfoFetchTitle get() = ZLSBundle.message("settings.downloader.progress.fetch")
|
||||||
override fun downloadProgressTitle(version: ZLSVersionInfo) = "Installing ZLS ${version.version.rawVersion}"
|
override fun downloadProgressTitle(version: ZLSVersionInfo) = ZLSBundle.message("settings.downloader.progress.install", version.version.rawVersion)
|
||||||
override fun localSelector() = ZLSLocalSelector(component)
|
override fun localSelector() = ZLSLocalSelector(component)
|
||||||
override suspend fun downloadVersionList(): List<ZLSVersionInfo> {
|
override suspend fun downloadVersionList(): List<ZLSVersionInfo> {
|
||||||
val toolchain = data?.getUserData(ZigToolchainConfigurable.TOOLCHAIN_KEY)?.get()
|
val toolchain = data?.getUserData(ZigToolchainConfigurable.TOOLCHAIN_KEY)?.get()
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.lsp.zls.downloader
|
package com.falsepattern.zigbrains.lsp.zls.downloader
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
||||||
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
||||||
import com.falsepattern.zigbrains.lsp.zls.zlsInstallations
|
import com.falsepattern.zigbrains.lsp.zls.zlsInstallations
|
||||||
import com.falsepattern.zigbrains.shared.downloader.LocalSelector
|
import com.falsepattern.zigbrains.shared.downloader.LocalSelector
|
||||||
|
@ -36,9 +37,9 @@ import kotlin.io.path.isDirectory
|
||||||
|
|
||||||
class ZLSLocalSelector(component: Component) : LocalSelector<ZLSVersion>(component) {
|
class ZLSLocalSelector(component: Component) : LocalSelector<ZLSVersion>(component) {
|
||||||
override val windowTitle: String
|
override val windowTitle: String
|
||||||
get() = "Select ZLS from disk"
|
get() = ZLSBundle.message("settings.local-selector.title")
|
||||||
override val descriptor: FileChooserDescriptor
|
override val descriptor: FileChooserDescriptor
|
||||||
get() = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle("ZLS binary")
|
get() = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle(ZLSBundle.message("settings.local-selector.chooser.title"))
|
||||||
|
|
||||||
override suspend fun browse(preSelected: Path?): ZLSVersion? {
|
override suspend fun browse(preSelected: Path?): ZLSVersion? {
|
||||||
if (preSelected?.isDirectory() == true) {
|
if (preSelected?.isDirectory() == true) {
|
||||||
|
@ -54,12 +55,12 @@ class ZLSLocalSelector(component: Component) : LocalSelector<ZLSVersion>(compone
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
AllIcons.General.Error,
|
AllIcons.General.Error,
|
||||||
"Invalid ZLS path",
|
ZLSBundle.message("settings.local-selector.state.invalid"),
|
||||||
) else VerifyResult(
|
) else VerifyResult(
|
||||||
null,
|
null,
|
||||||
true,
|
true,
|
||||||
AllIcons.General.Information,
|
AllIcons.General.Information,
|
||||||
"ZLS path OK"
|
ZLSBundle.message("settings.local-selector.state.ok")
|
||||||
)
|
)
|
||||||
if (zls != null) {
|
if (zls != null) {
|
||||||
zls = zlsInstallations.withUniqueName(zls)
|
zls = zlsInstallations.withUniqueName(zls)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.lsp.zls.downloader
|
package com.falsepattern.zigbrains.lsp.zls.downloader
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchain
|
||||||
import com.falsepattern.zigbrains.project.toolchain.downloader.ZigVersionInfo
|
import com.falsepattern.zigbrains.project.toolchain.downloader.ZigVersionInfo
|
||||||
import com.falsepattern.zigbrains.shared.downloader.VersionInfo
|
import com.falsepattern.zigbrains.shared.downloader.VersionInfo
|
||||||
|
@ -64,7 +65,7 @@ data class ZLSVersionInfo(
|
||||||
val service = DownloadableFileService.getInstance()
|
val service = DownloadableFileService.getInstance()
|
||||||
val tempFile = FileUtil.createTempFile(tempPluginDir, "zls_version_info", ".json", false, false)
|
val tempFile = FileUtil.createTempFile(tempPluginDir, "zls_version_info", ".json", false, false)
|
||||||
val desc = service.createFileDescription(url, tempFile.name)
|
val desc = service.createFileDescription(url, tempFile.name)
|
||||||
val downloader = service.createDownloader(listOf(desc), "ZLS version information")
|
val downloader = service.createDownloader(listOf(desc), ZLSBundle.message("settings.downloader.service.index"))
|
||||||
val downloadResults = coroutineToIndicator {
|
val downloadResults = coroutineToIndicator {
|
||||||
downloader.download(tempPluginDir)
|
downloader.download(tempPluginDir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
settings.group.title=ZLS Settings
|
|
||||||
settings.zls-path.label=Executable path
|
|
||||||
settings.zls-path.tooltip=Path to the ZLS Binary
|
|
||||||
settings.zls-path.browse.title=Path to the ZLS Binary
|
|
||||||
settings.zls-version.label=Detected ZLS version
|
|
||||||
settings.zls-config-path.label=Config path
|
settings.zls-config-path.label=Config path
|
||||||
settings.zls-config-path.tooltip=Leave empty to use built-in config generated from the settings below
|
settings.zls-config-path.tooltip=Leave empty to use built-in config generated from the settings below
|
||||||
settings.zls-config-path.browse.title=Path to the Custom ZLS Config File (Optional)
|
settings.zls-config-path.browse.title=Path to the Custom ZLS Config File (Optional)
|
||||||
|
@ -50,8 +45,6 @@ settings.build_runner_path.tooltip=Specify a custom build runner to resolve buil
|
||||||
settings.global_cache_path.label=Global cache path
|
settings.global_cache_path.label=Global cache path
|
||||||
settings.global_cache_path.tooltip=Path to a directory that will be used as zig's cache. Will default to `${KnownFolders.Cache}/zls`.
|
settings.global_cache_path.tooltip=Path to a directory that will be used as zig's cache. Will default to `${KnownFolders.Cache}/zls`.
|
||||||
notification.group.zigbrains-lsp=ZigBrains LSP Integration
|
notification.group.zigbrains-lsp=ZigBrains LSP Integration
|
||||||
notification.message.could-not-detect.content=Could not detect ZLS binary, please configure it
|
|
||||||
notification.message.zls-exe-path-invalid.content=ZLS executable path could not be parsed: {0}
|
|
||||||
notification.message.zls-exe-not-exists.content=ZLS executable does not exist: {0}
|
notification.message.zls-exe-not-exists.content=ZLS executable does not exist: {0}
|
||||||
notification.message.zls-exe-not-executable.content=ZLS executable is not an executable file: {0}
|
notification.message.zls-exe-not-executable.content=ZLS executable is not an executable file: {0}
|
||||||
notification.message.zls-config-not-exists.content=ZLS config file does not exist: {0}
|
notification.message.zls-config-not-exists.content=ZLS config file does not exist: {0}
|
||||||
|
@ -61,7 +54,6 @@ notification.message.zls-config-autogen-failed.content=Failed to autogenerate ZL
|
||||||
notification.banner.zls-not-running=Zig Language Server is not running. Check the [Language Servers] tool menu!
|
notification.banner.zls-not-running=Zig Language Server is not running. Check the [Language Servers] tool menu!
|
||||||
notification.banner.zls-bad-config=Zig Language Server is misconfigured. Check [Settings | Languages \\& Frameworks | Zig]!
|
notification.banner.zls-bad-config=Zig Language Server is misconfigured. Check [Settings | Languages \\& Frameworks | Zig]!
|
||||||
progress.title.create-connection-provider=Creating ZLS connection provider
|
progress.title.create-connection-provider=Creating ZLS connection provider
|
||||||
progress.title.validate=Validating ZLS
|
|
||||||
# suppress inspection "UnusedProperty"
|
# suppress inspection "UnusedProperty"
|
||||||
lsp.zls.name=Zig Language Server
|
lsp.zls.name=Zig Language Server
|
||||||
# suppress inspection "UnusedProperty"
|
# suppress inspection "UnusedProperty"
|
||||||
|
@ -73,3 +65,15 @@ settings.model.none.text=<No ZLS>
|
||||||
settings.model.loading.text=Loading\u2026
|
settings.model.loading.text=Loading\u2026
|
||||||
settings.model.from-disk.text=Add ZLS from disk\u2026
|
settings.model.from-disk.text=Add ZLS from disk\u2026
|
||||||
settings.model.download.text=Download ZLS\u2026
|
settings.model.download.text=Download ZLS\u2026
|
||||||
|
settings.downloader.title=Install ZLS
|
||||||
|
settings.downloader.progress.fetch=Fetching ZLS version information
|
||||||
|
settings.downloader.progress.install=Installing ZLS {}
|
||||||
|
settings.downloader.service.index=ZLS version information
|
||||||
|
settings.local-selector.title=Select ZLS from disk
|
||||||
|
settings.local-selector.chooser.title=ZLS Binary
|
||||||
|
settings.local-selector.state.invalid=Invalid ZLS path
|
||||||
|
settings.local-selector.state.ok=ZLS path OK
|
||||||
|
dialog.title.zls=Path to the ZLS Executable
|
||||||
|
settings.panel.path.label=Path:
|
||||||
|
settings.panel.version.label=Version:
|
||||||
|
settings.panel.settings.group.label=Settings:
|
Loading…
Add table
Reference in a new issue