backport: 25.1.0

This commit is contained in:
FalsePattern 2025-04-17 11:45:42 +02:00
parent c726efc858
commit ce9692ecdb
Signed by: falsepattern
GPG key ID: E930CDEC50C50E23
12 changed files with 69 additions and 13 deletions

View file

@ -17,6 +17,15 @@ Changelog structure reference:
## [Unreleased]
## [25.1.0]
### Added
- IDEA 2025.1 support
- LSP
- Configurable inlay hints file size limit to reduce IDE lag
## [25.0.2]
### Fixed

View file

@ -15,6 +15,7 @@ through the built-in plugin browser:
1. Go to `Settings -> Plugins`
2. To the right of the `Installed` button at the top, click on the `...` dropdown menu, then select `Manage Plugin Repositories...`
3. Click the add button, and then enter the ZigBrains updater URL, based on your IDE version:
- `2025.1.*` or newer: https://falsepattern.com/zigbrains/updatePlugins-251.xml
- `2024.3.*`: https://falsepattern.com/zigbrains/updatePlugins-243.xml
- `2024.2.*`: https://falsepattern.com/zigbrains/updatePlugins-242.xml
- `2024.1.*`: https://falsepattern.com/zigbrains/updatePlugins-241.xml

View file

@ -14,7 +14,7 @@ plugins {
idea
`maven-publish`
}
val publishVersions = listOf("241", "242", "243")
val publishVersions = listOf("241", "242", "243", "251")
val pluginVersionFull get() = "$pluginVersion-$pluginSinceBuild"
val pluginVersion: String by project
val pluginSinceBuild: String by project

View file

@ -23,7 +23,7 @@
set -e
declare -a branches=("master" "242" "241")
declare -a branches=("master" "243" "242" "241")
DEFAULT_BRANCH="${branches[0]}"

View file

@ -9,12 +9,15 @@ plugins {
val ideaCommunityVersion: String by project
val useInstaller = property("useInstaller").toString().toBoolean()
val serializationVersion: String by project
dependencies {
intellijPlatform {
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaCommunityVersion, useInstaller = useInstaller)
}
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3")
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:$serializationVersion") {
isTransitive = false
}
}
//region grammars

View file

@ -1,7 +1,7 @@
pluginName=ZigBrains
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
pluginVersion=25.0.2
pluginVersion=25.1.0
pluginSinceBuild=241
pluginUntilBuild=241.*
@ -17,6 +17,8 @@ lsp4jVersion=0.21.1
lsp4ijVersion=0.12.0
lsp4ijNightly=false
serializationVersion=1.6.3
kotlin.stdlib.default.dependency=false
kotlin.code.style=official
org.gradle.configuration-cache=true

View file

@ -8,12 +8,15 @@ val lsp4ijVersion: String by project
val lsp4jVersion: String by project
val ideaCommunityVersion: String by project
val useInstaller = property("useInstaller").toString().toBoolean()
val serializationVersion: String by project
dependencies {
intellijPlatform {
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaCommunityVersion, useInstaller = useInstaller)
}
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3")
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:$serializationVersion") {
isTransitive = false
}
compileOnly("com.redhat.devtools.intellij:lsp4ij:$lsp4ijVersion")
compileOnly("org.eclipse.lsp4j:org.eclipse.lsp4j:$lsp4jVersion")
implementation(project(":core")) {

View file

@ -68,7 +68,14 @@ class ZigLanguageServerFactory: LanguageServerFactory, LanguageServerEnablementS
}
features.inlayHintFeature = object: LSPInlayHintFeature() {
override fun isEnabled(file: PsiFile): Boolean {
return project.zls?.settings?.inlayHints == true
val settings = project.zls?.settings ?: return false
if (!settings.inlayHints)
return false
val maxFileSizeKb = settings.inlayHintsMaxFileSizeKb
if (maxFileSizeKb == 0)
return true
val fileSizeKb = file.fileDocument.textLength / 1024
return fileSizeKb <= maxFileSizeKb
}
}
return features

View file

@ -30,6 +30,7 @@ import org.jetbrains.annotations.NonNls
data class ZLSSettings(
@JvmField @Attribute val zlsConfigPath: @NonNls String = "",
@JvmField @Attribute val inlayHints: Boolean = true,
@JvmField @Attribute val inlayHintsMaxFileSizeKb: Int = 128,
@JvmField @Attribute val enable_snippets: Boolean = true,
@JvmField @Attribute val enable_argument_placeholders: Boolean = true,
@JvmField @Attribute val completion_label_details: Boolean = true,

View file

@ -35,6 +35,9 @@ import com.intellij.ui.dsl.builder.AlignX
import com.intellij.ui.dsl.builder.Panel
import com.intellij.ui.dsl.builder.Row
import org.jetbrains.annotations.PropertyKey
import javax.swing.text.AttributeSet
import javax.swing.text.DocumentFilter
import javax.swing.text.PlainDocument
@Suppress("PrivatePropertyName")
class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
@ -44,6 +47,27 @@ class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()
).also { Disposer.register(this, it) }
private val inlayHints = JBCheckBox()
private val inlayHintsMaxFileSize = ExtendableTextField(5).also { (it.document as PlainDocument).documentFilter = object: DocumentFilter() {
override fun insertString(fb: FilterBypass?, offset: Int, string: String?, attr: AttributeSet?) {
if (string != null && !string.isEmpty() && string.toIntOrNull() == null) {
return
}
super.insertString(fb, offset, string, attr)
}
override fun replace(
fb: FilterBypass?,
offset: Int,
length: Int,
text: String?,
attrs: AttributeSet?
) {
if (text != null && !text.isEmpty() && text.toIntOrNull() == null) {
return
}
super.replace(fb, offset, length, text, attrs)
}
} }
private val enable_snippets = JBCheckBox()
private val enable_argument_placeholders = JBCheckBox()
private val completion_label_details = JBCheckBox()
@ -99,6 +123,13 @@ class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
"settings.inlay-hints-enable.label",
"settings.inlay-hints-enable.tooltip"
) { cell(inlayHints) }
fancyRow(
"settings.inlay-hints-max-size.label",
"settings.inlay-hints-max-size.tooltip",
) {
cell(inlayHintsMaxFileSize)
text(ZLSBundle.message("settings.inlay-hints-max-size.unit"))
}
fancyRow(
"settings.inlay_hints_show_variable_type_hints.label",
"settings.inlay_hints_show_variable_type_hints.tooltip"
@ -174,6 +205,7 @@ class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
get() = ZLSSettings(
zlsConfigPath.text,
inlayHints.isSelected,
inlayHintsMaxFileSize.text.toIntOrNull() ?: 128,
enable_snippets.isSelected,
enable_argument_placeholders.isSelected,
completion_label_details.isSelected,
@ -198,6 +230,7 @@ class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
set(value) {
zlsConfigPath.text = value.zlsConfigPath
inlayHints.isSelected = value.inlayHints
inlayHintsMaxFileSize.text = value.inlayHintsMaxFileSizeKb.toString()
enable_snippets.isSelected = value.enable_snippets
enable_argument_placeholders.isSelected = value.enable_argument_placeholders
completion_label_details.isSelected = value.completion_label_details

View file

@ -4,6 +4,9 @@ settings.zls-config-path.browse.title=Path to the Custom ZLS Config File (Option
settings.inlay-hints-group.label=Inlay Hints
settings.inlay-hints-enable.label=Enable
settings.inlay-hints-enable.tooltip=Toggle this to enable/disable all inlay hints
settings.inlay-hints-max-size.label=Maximum Size
settings.inlay-hints-max-size.tooltip=The maximum size of a zig file to show inlay hints for.\nInlay hints in very large files make the IDE lag.\nSet to 0 to disable.
settings.inlay-hints-max-size.unit=KB
settings.enable_snippets.label=Enable snippets
settings.enable_snippets.tooltip=Enables snippet completions when the client also supports them
settings.enable_argument_placeholders.label=Enable argument placeholders

View file

@ -23,8 +23,6 @@
set -e
declare -a branches=("dev" "master" "242" "241")
die () {
echo >&2 "$@"
exit 1
@ -32,8 +30,4 @@ die () {
[ "$#" -eq 1 ] || die "1 argument required, $# provided"
for i in "${branches[@]}"
do
echo "Pushing branch $i"
git push "$1" "$i"
done
git push --atomic "$1" "dev" "master" "243" "242" "241"