11package com.github.xepozz.phplsp
22
33import com.intellij.execution.configurations.GeneralCommandLine
4- import com.intellij.execution.process.OSProcessHandler
54import com.intellij.openapi.project.Project
65import com.intellij.openapi.vfs.VirtualFile
76import com.intellij.platform.lsp.api.LspCommunicationChannel
87import 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
139class 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}
0 commit comments