zobo / php-language-server

PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
ISC License
55 stars 12 forks source link

Only Symbols works, All other commands gives no response #80

Open mtangoo opened 1 month ago

mtangoo commented 1 month ago

I have this problem that I have no idea what am doing wrong. I have this editor (closed source) that works fine with Serenata, but only symbols (textDocument/documentSymbol) works with this LS. If anyone can figure out what am doing wrong, I will be grateful. Hover for example, does not work

here is the hover command which works with Serenata but not with this Lang Server

{
    "id": 7,
    "jsonrpc": "2.0",
    "method": "textDocument/hover",
    "params": {
        "textDocument": {
            "uri": "file:///Users/hosanna/Projects/ProjectFolder/Controller.php"
        },
        "position": {
            "line": 568,
            "character": 26
        }
    }
}

Here is my initialize JSON-RPC.

{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
        "processId": 49731,
        "rootUri": "file:///Users/me/Projects/ProjectFolder",
        "rootPath": "/Users/me/Projects/ProjectFolder",
        "capabilities": {
            "workspace": {
                "applyEdit": true,
                "workspaceEdit": {
                    "documentChanges": true,
                    "resourceOperations": [
                        "create",
                        "rename",
                        "delete"
                    ],
                    "normalizesLineEndings": true,
                    "failureHandling": "textOnlyTransactional"
                },
                "didChangeConfiguration": {
                    "dynamicRegistration": true
                },
                "symbol": {
                    "dynamicRegistration": true,
                    "symbolKind": {
                        "valueSet": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12,
                            13,
                            14,
                            15,
                            16,
                            17,
                            18,
                            19,
                            20,
                            21,
                            22,
                            23,
                            24,
                            25,
                            26
                        ]
                    },
                    "configuration": true,
                    "workspaceFolders": true
                },
                "executeCommand": {
                    "dynamicRegistration": true
                }
            },
            "textDocument": {
                "synchronization": {
                    "dynamicRegistration": true,
                    "willSave": true,
                    "willSaveWaitUntil": true,
                    "didSave": true
                },
                "completion": {
                    "dynamicRegistration": true,
                    "completionItemKind": {
                        "valueSet": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12,
                            13,
                            14,
                            15,
                            16,
                            17,
                            18,
                            19,
                            20,
                            21,
                            22,
                            23,
                            24,
                            25
                        ]
                    }
                },
                "hover": {
                    "dynamicRegistration": true,
                    "contentFormat": [
                        "markdown",
                        "plaintext"
                    ]
                },
                "definition": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                }
            }
        },
        "trace": "verbose",
        "locale": "en"
    }
}
zobo commented 1 month ago

It looks ok. What php version are you running this with? How is the IDE talking to the LS? stdio or tcp? Are there any errors on the console? I need to check how to run it verbosely. Did the LS attempt to index the root?

Since I don't have much time to develop this project anymore, I suggest you also look at phpactor.

mtangoo commented 1 month ago
php -v                                                                                                            ✹master
PHP 8.3.9 (cli) (built: Jul  2 2024 14:10:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies

IDE is talking to LS via Sockets so it is TCP/IP. I don't know much about stdio for IPC (would love a good reference if you know any).

Did the LS attempt to index the root?

Can you point a bit how it should be done?

Since I don't have much time to develop this project anymore, I suggest you also look at phpactor.

The LSP seems to be working since your VSCode Plugin works fine. I tried to compare am sending same command for hover as an example but for VS Code it returns response, for mine it doesn't.

Have any idea on how I can debug it at code level? Am not that bad at PHP if I can get starting point.

Thanks for your time

zobo commented 1 month ago

First thing that comes to mind is that the IDE (client) needs to send the initialized notification to LS for LS to start indexing: commit. I don't know how compliant your IDE is, or this LS for that matter...

Regarding debugging. I'm assuming you have control over how php-language-server.php is started and can influence its ENV.

First you need to allow LS to run with Xdebug.

I'll leave the IDE setup to you, but you can also use vscode-php-debug (that I also maintain). One thing, I would suggest that you use a different debug port as you will be running other PHP processes and the same time and you don't what them to conflict with debugging the LS.

mtangoo commented 1 month ago

Thanks @zobo for your advice and time. I will check initialized and see if that might be an issue. I will also check XDebug to see how it can help.

One more request, If you have leisure of little bit time, can you point me to file(s) that sends LSP requests (I refer vscode intellisense extension) ? I have little idea on JS/TS, and would like to glean some insights.

Again, thank you for your generosity!