Skip to content

Commit

Permalink
Fixed starting of lsp-server
Browse files Browse the repository at this point in the history
  • Loading branch information
kizeevov committed Mar 23, 2024
1 parent d347f3a commit 37635ba
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixed

- Fixed ternary expressions again
- Fixed starting of lsp-server

## [1.0.1] - 2024-03-20

Expand Down
22 changes: 20 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"))
Expand Down Expand Up @@ -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")
}
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ pluginSinceBuild = 232
pluginUntilBuild =
platformPlugins =
jvmVersion = 17

slintLspVersion = 1.5.1
9 changes: 2 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" }
download = { id = "de.undercouch.download", version.ref = "download"}
24 changes: 19 additions & 5 deletions src/main/kotlin/dev/slint/ideaplugin/ide/lsp/CommandLineHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
}

0 comments on commit 37635ba

Please sign in to comment.