From 8209e688fcbb968d479c756e1fd5eeaf7b38e18b Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Thu, 17 Apr 2025 13:45:42 +0200 Subject: [PATCH] backport: 25.1.0 --- CHANGELOG.md | 9 +++++ README.md | 1 + build.gradle.kts | 2 +- build.sh | 2 +- core/build.gradle.kts | 5 ++- gradle.properties | 4 ++- lsp/build.gradle.kts | 5 ++- .../zigbrains/lsp/ZigLanguageServerFactory.kt | 9 ++++- .../zigbrains/lsp/settings/ZLSSettings.kt | 1 + .../lsp/settings/ZLSSettingsPanel.kt | 33 +++++++++++++++++++ .../resources/zigbrains/lsp/Bundle.properties | 3 ++ push.sh | 8 +---- 12 files changed, 69 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc49a4b3..91ab75c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 289a7aa2..73a9ebea 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.gradle.kts b/build.gradle.kts index 9f120e29..5af8ceb7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 diff --git a/build.sh b/build.sh index f91f693d..9c12ede7 100644 --- a/build.sh +++ b/build.sh @@ -23,7 +23,7 @@ set -e -declare -a branches=("master" "242" "241") +declare -a branches=("master" "243" "242" "241") DEFAULT_BRANCH="${branches[0]}" diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 32259f17..8f06a8b0 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -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.7.3") + compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:$serializationVersion") { + isTransitive = false + } } //region grammars diff --git a/gradle.properties b/gradle.properties index eaa917b3..7e557df9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ pluginName=ZigBrains pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains -pluginVersion=25.0.2 +pluginVersion=25.1.0 pluginSinceBuild=243 pluginUntilBuild=243.* @@ -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 diff --git a/lsp/build.gradle.kts b/lsp/build.gradle.kts index a8cad36d..fb902561 100644 --- a/lsp/build.gradle.kts +++ b/lsp/build.gradle.kts @@ -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.7.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")) { diff --git a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/ZigLanguageServerFactory.kt b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/ZigLanguageServerFactory.kt index 8cc3b328..08f226b0 100644 --- a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/ZigLanguageServerFactory.kt +++ b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/ZigLanguageServerFactory.kt @@ -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 diff --git a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettings.kt b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettings.kt index 1c462864..e9ae1eb8 100644 --- a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettings.kt +++ b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettings.kt @@ -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, diff --git a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettingsPanel.kt b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettingsPanel.kt index 5daeb419..a70f5539 100644 --- a/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettingsPanel.kt +++ b/lsp/src/main/kotlin/com/falsepattern/zigbrains/lsp/settings/ZLSSettingsPanel.kt @@ -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 { @@ -44,6 +47,27 @@ class ZLSSettingsPanel() : ImmutableElementPanel { .withTitle(ZLSBundle.message("settings.zls-config-path.browse.title")) ).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 { "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 { 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 { 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 diff --git a/lsp/src/main/resources/zigbrains/lsp/Bundle.properties b/lsp/src/main/resources/zigbrains/lsp/Bundle.properties index 8a680305..33cdd251 100644 --- a/lsp/src/main/resources/zigbrains/lsp/Bundle.properties +++ b/lsp/src/main/resources/zigbrains/lsp/Bundle.properties @@ -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 diff --git a/push.sh b/push.sh index 79d73c3a..c2832d5a 100755 --- a/push.sh +++ b/push.sh @@ -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 \ No newline at end of file +git push --atomic "$1" "dev" "master" "243" "242" "241" \ No newline at end of file