From 37635ba083ee8679ff80ae890c995d865c7f26df Mon Sep 17 00:00:00 2001 From: Oleg Kizeev Date: Sun, 24 Mar 2024 05:01:56 +0700 Subject: [PATCH] Fixed starting of lsp-server --- CHANGELOG.md | 1 + build.gradle.kts | 22 +++++++++++++++-- gradle.properties | 2 ++ gradle/libs.versions.toml | 9 ++----- .../ideaplugin/ide/lsp/CommandLineHandler.kt | 24 +++++++++++++++---- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01679ff..8dc1908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Fixed - Fixed ternary expressions again +- Fixed starting of lsp-server ## [1.0.1] - 2024-03-20 diff --git a/build.gradle.kts b/build.gradle.kts index 40106e0..fd1a08f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.intellij.tasks.PatchPluginXmlTask import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML +import de.undercouch.gradle.tasks.download.Download fun properties(key: String) = providers.gradleProperty(key) fun environment(key: String) = providers.environmentVariable(key) @@ -12,11 +13,14 @@ plugins { alias(libs.plugins.intellij) alias(libs.plugins.grammarkit) alias(libs.plugins.changelog) + alias(libs.plugins.download) } group = properties("pluginGroup").get() version = properties("pluginVersion").get() +val slintLspVersion = properties("slintLspVersion").get() + idea { module { generatedSourceDirs.add(file("src/gen")) @@ -133,9 +137,23 @@ tasks { channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) } } + task("downloadSlintLspVscodePlugin", type = Download::class) { + src("https://Slint.gallery.vsassets.io/_apis/public/gallery/publisher/Slint/extension/slint/${slintLspVersion}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage") + dest("${project.buildDir}/tmp/slint-${slintLspVersion}-vscode-plugin.zip") + onlyIfModified(true) + } + + task("extractSlintLspVscodePlugin", type = Copy::class) { + dependsOn("downloadSlintLspVscodePlugin") + from(zipTree("${project.buildDir}/tmp/slint-${slintLspVersion}-vscode-plugin.zip")) { + destinationDir = file("${project.buildDir}/tmp/slint-vscode-plugin") + } + } + prepareSandbox { - from("${project.projectDir}/language-server") { - into("${intellij.pluginName.get()}/language-server/") + dependsOn("extractSlintLspVscodePlugin") + from("${project.buildDir}/tmp/slint-vscode-plugin/extension/bin") { + into("${intellij.pluginName.get()}/language-server/bin") } } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3100021..d2f1b7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,3 +17,5 @@ pluginSinceBuild = 232 pluginUntilBuild = platformPlugins = jvmVersion = 17 + +slintLspVersion = 1.5.1 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 784f63a..7d7f27e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ kotlin = "1.9.10" changelog = "2.2.0" intellij = "1.16.0" grammarkit = "2022.3.1" +download = "5.6.0" #gradleIntelliJPlugin = "1.15.0" #qodana = "0.1.13" @@ -20,10 +21,4 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } intellij = { id = "org.jetbrains.intellij", version.ref = "intellij" } grammarkit = { id = "org.jetbrains.grammarkit", version.ref = "grammarkit" } - - -# gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } - -#kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -#kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } -#qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } \ No newline at end of file +download = { id = "de.undercouch.download", version.ref = "download"} \ No newline at end of file diff --git a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/CommandLineHandler.kt b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/CommandLineHandler.kt index 36da42e..73d1931 100644 --- a/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/CommandLineHandler.kt +++ b/src/main/kotlin/dev/slint/ideaplugin/ide/lsp/CommandLineHandler.kt @@ -8,6 +8,10 @@ import dev.slint.ideaplugin.ide.settings.SlintBackend import dev.slint.ideaplugin.ide.settings.SlintSettingsState import dev.slint.ideaplugin.ide.settings.SlintStyle import java.nio.file.Path +import java.nio.file.attribute.PosixFilePermission +import kotlin.io.path.getPosixFilePermissions +import kotlin.io.path.isExecutable +import kotlin.io.path.setPosixFilePermissions object CommandLineHandler { fun createCommandLine(): GeneralCommandLine { @@ -54,10 +58,10 @@ object CommandLineHandler { } private fun getEmbeddedLspPath(): Path? { - val pluginPath = PluginManager + val pluginManager = PluginManager .getInstance() .findEnabledPlugin(PluginId.getId(dev.slint.ideaplugin.SLINT_PLUGIN_ID)) - ?.pluginPath + ?: return null val programName: String @@ -87,8 +91,18 @@ object CommandLineHandler { return null } - return pluginPath - ?.resolve("language-server/bin") - ?.resolve(programName) + val lspPath = pluginManager + .pluginPath + .resolve("language-server/bin") + .resolve(programName) + + if (!lspPath.isExecutable()) { + lspPath.setPosixFilePermissions( + lspPath.getPosixFilePermissions() + .plus(PosixFilePermission.OWNER_EXECUTE) + ) + } + + return lspPath } }