Skip to content

Commit 4d21551

Browse files
committed
switched to phpstorm target, refactor configuration page
1 parent cd1cd28 commit 4d21551

5 files changed

Lines changed: 80 additions & 68 deletions

File tree

gradle.properties

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
22

33
pluginGroup = com.github.xepozz.phplsp
4-
pluginName = php-lsp
4+
pluginName = PHP Language Server
55
pluginRepositoryUrl = https://github.com/xepozz/php-lsp
66
# SemVer format -> https://semver.org
7-
pluginVersion = 0.0.1
7+
pluginVersion = 2025.0.5
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
10-
pluginSinceBuild = 233
11-
pluginUntilBuild = 243.*
10+
pluginSinceBuild = 232
11+
pluginUntilBuild = 244.*
1212

1313
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
14-
platformType = IU
15-
platformVersion = 2024.3.1.1
14+
platformType = PS
15+
platformVersion = 2024.2.1
1616

1717
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
1818
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
@@ -21,7 +21,7 @@ platformPlugins =
2121
platformBundledPlugins =
2222

2323
# Gradle Releases -> https://github.com/gradle/gradle/releases
24-
gradleVersion = 8.10.2
24+
gradleVersion = 8.11
2525

2626
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
2727
kotlin.stdlib.default.dependency = false
@@ -31,3 +31,5 @@ org.gradle.configuration-cache = true
3131

3232
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
3333
org.gradle.caching = true
34+
35+
org.gradle.build.scan.toggle=false
Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,47 @@
11
package com.github.xepozz.phplsp
22

33
import com.intellij.execution.configurations.GeneralCommandLine
4-
import com.intellij.execution.process.OSProcessHandler
54
import com.intellij.openapi.project.Project
65
import com.intellij.openapi.vfs.VirtualFile
76
import com.intellij.platform.lsp.api.LspCommunicationChannel
87
import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor
9-
import com.intellij.util.io.BaseDataReader
10-
import com.intellij.util.io.BaseOutputReader
11-
import com.intellij.util.io.BaseOutputReader.Options.forMostlySilentProcess
128

139
class PhpLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "PHP Language") {
14-
val settings = LspServiceSettings.getInstance(project)
10+
val settings = PhpLspServiceSettings.getInstance(project)
1511

1612
override fun isSupportedFile(file: VirtualFile) =
17-
settings.serviceMode == LspServiceMode.ENABLED && file.extension == "php"
13+
settings.enabled && file.extension == "php"
14+
15+
// the following supported only in IDEA Ultimate:
16+
// override val lspDocumentColorSupport = super.lspDocumentColorSupport
17+
// override val lspSemanticTokensSupport = super.lspSemanticTokensSupport
18+
// override val lspGoToTypeDefinitionSupport = true
1819

19-
override val lspDocumentColorSupport = super.lspDocumentColorSupport
2020
override val lspCodeActionsSupport = super.lspCodeActionsSupport
2121
override val lspCommandsSupport = super.lspCommandsSupport
2222
override val lspDiagnosticsSupport = super.lspDiagnosticsSupport
2323
override val lspFindReferencesSupport = super.lspFindReferencesSupport
2424
override val lspFormattingSupport = super.lspFormattingSupport
25-
26-
override val lspSemanticTokensSupport = super.lspSemanticTokensSupport
27-
override val lspGoToDefinitionSupport = true
28-
override val lspGoToTypeDefinitionSupport = true
2925
override val lspCompletionSupport = super.lspCompletionSupport
26+
override val lspGoToDefinitionSupport = true
3027
override val lspHoverSupport = true
3128

32-
override val lspCommunicationChannel = LspCommunicationChannel.Socket(settings.port, false)
33-
34-
override fun startServerProcess(): OSProcessHandler {
35-
// Thread.sleep(1)
36-
val startingCommandLine = createCommandLine().withCharset(Charsets.UTF_8)
37-
// LOG.info("$this: starting LSP server: $startingCommandLine")
38-
return object : OSProcessHandler(startingCommandLine) {
39-
override fun readerOptions(): BaseOutputReader.Options = object : BaseOutputReader.Options() {
40-
override fun policy(): BaseDataReader.SleepingPolicy = BaseDataReader.SleepingPolicy.BLOCKING
41-
42-
// Must not loose '\r' in "\r\n" line endings. They affect char count, which must match `Content-Length`
43-
override fun splitToLines(): Boolean = true
44-
}
45-
}
46-
}
29+
override val lspCommunicationChannel = LspCommunicationChannel.Socket(settings.port, settings.runCommand)
4730
override fun createCommandLine() = GeneralCommandLine(
4831
settings.binary,
49-
"serve",
50-
"App\\Application",
51-
"--port=%d".format(settings.port),
32+
*settings.command
33+
.replace("%port%", settings.port.toString())
34+
.split(' ')
35+
.toTypedArray(),
5236
)
37+
// "serve",
38+
// "App\\Application",
39+
// "--port=%d"
40+
41+
// override val lspCommunicationChannel = LspCommunicationChannel.Socket(settings.port, true)
42+
// override fun createCommandLine() = GeneralCommandLine(
43+
// "phpactor",
44+
// "language-server",
45+
// "--address=127.0.0.1:%d".format(settings.port),
46+
// )
5347
}

src/main/kotlin/com/github/xepozz/phplsp/LspServiceSettings.kt renamed to src/main/kotlin/com/github/xepozz/phplsp/PhpLspServiceSettings.kt

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ import com.intellij.openapi.project.Project
77
import com.intellij.platform.lsp.api.LspServerManager
88

99
@Service(Service.Level.PROJECT)
10-
@State(name = "PrismaServiceSettings", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
11-
class LspServiceSettings(val project: Project) :
10+
@State(name = "PhpLspServiceSettings", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
11+
class PhpLspServiceSettings(val project: Project) :
1212
SimplePersistentStateComponent<LspServiceState>(LspServiceState()) {
13-
var serviceMode
14-
get() = state.serviceMode
13+
var enabled
14+
get() = state.enabled
1515
set(value) {
16-
val changed = state.serviceMode != value
17-
state.serviceMode = value
16+
val changed = state.enabled != value
17+
state.enabled = value
18+
if (changed) {
19+
restartPhpLspServerAsync(project)
20+
}
21+
}
22+
23+
var runCommand
24+
get() = state.runCommand
25+
set(value) {
26+
val changed = state.runCommand != value
27+
state.runCommand = value
1828
if (changed) {
1929
restartPhpLspServerAsync(project)
2030
}
@@ -51,18 +61,19 @@ class LspServiceSettings(val project: Project) :
5161
}
5262

5363
companion object {
54-
fun getInstance(project: Project) = project.service<LspServiceSettings>()
64+
fun getInstance(project: Project) = project.service<PhpLspServiceSettings>()
5565
}
5666
}
5767

5868
class LspServiceState : BaseState() {
59-
var serviceMode by enum(LspServiceMode.ENABLED)
69+
var runCommand by property(true)
70+
var enabled by property(true)
6071
var binary by string("/bin/lsp")
61-
var command by string("serve App\\\\Application --port=%d")
72+
var command by string("serve App\\\\Application --port=%port%")
6273
var port by property(5007)
6374
}
6475

65-
enum class LspServiceMode {
76+
enum class BooleanOption {
6677
ENABLED,
6778
DISABLED
6879
}

src/main/kotlin/com/github/xepozz/phplsp/PhpLspSettingsConfigurable.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,46 @@ package com.github.xepozz.phplsp
44
import com.intellij.openapi.options.Configurable
55
import com.intellij.openapi.options.UiDslUnnamedConfigurable
66
import com.intellij.openapi.project.Project
7+
import com.intellij.ui.dsl.builder.Align
78
import com.intellij.ui.dsl.builder.Panel
8-
import com.intellij.ui.dsl.builder.bind
99
import com.intellij.ui.dsl.builder.bindIntText
10+
import com.intellij.ui.dsl.builder.bindSelected
1011
import com.intellij.ui.dsl.builder.bindText
1112

1213
class PhpLspSettingsConfigurable(project: Project) : UiDslUnnamedConfigurable.Simple(), Configurable {
13-
private val settings = LspServiceSettings.getInstance(project)
14+
private val settings = PhpLspServiceSettings.getInstance(project)
1415

1516
override fun Panel.createContent() {
1617
group("Language Server Configuration") {
17-
buttonsGroup {
18-
row {
19-
radioButton("Enabled", LspServiceMode.ENABLED)
20-
}
21-
row {
22-
radioButton("Disabled", LspServiceMode.DISABLED)
23-
}
24-
}.apply {
25-
bind(settings::serviceMode)
18+
row {
19+
checkBox("Enabled").bindSelected(settings::enabled)
20+
}
21+
22+
row {
23+
checkBox("Run language server automatically").bindSelected(settings::runCommand)
2624
}
2725

2826
separator()
2927

3028
row {
31-
textFieldWithBrowseButton()
32-
.label("Binary")
29+
textFieldWithBrowseButton(project = settings.project)
30+
.label("Binary:")
31+
.align(Align.FILL)
3332
.bindText(settings::binary)
3433
}
35-
// row {
36-
// textField()
37-
// .label("Command")
38-
// .bindText(settings::command)
39-
// }
34+
4035
row {
4136
textField()
42-
.label("Port")
37+
.label("Command:")
38+
.align(Align.FILL)
39+
.bindText(settings::command)
40+
41+
comment("Use %port% to substitute the port number. All special symbols will be escaped automatically.")
42+
}
43+
44+
row {
45+
intTextField(range = IntRange(1, 65535), keyboardStep = 1)
46+
.label("Port:")
4347
.bindIntText(settings::port)
4448
}
4549

src/main/resources/META-INF/plugin.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
22
<idea-plugin>
33
<id>com.github.xepozz.phplsp</id>
4-
<name>PHP LSP</name>
5-
<vendor>xepozz</vendor>
4+
<name>PHP Language Server</name>
5+
<vendor email="xepozz@list.ru" url="https://github.com/xepozz">Dmitrii Derepko (@xepozz)</vendor>
66

7+
<depends>com.jetbrains.php</depends>
78
<depends>com.intellij.modules.platform</depends>
8-
<depends>com.intellij.modules.ultimate</depends>
9+
<!-- <depends>com.intellij.modules.ultimate</depends>-->
910

1011
<resource-bundle>messages.MyBundle</resource-bundle>
1112

0 commit comments

Comments
 (0)