Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp client error when working with phpactor language server #2214

Open
lalanikarim opened this issue Apr 21, 2022 · 3 comments
Open

lsp client error when working with phpactor language server #2214

lalanikarim opened this issue Apr 21, 2022 · 3 comments
Labels
C-bug Category: This is a bug upstream

Comments

@lalanikarim
Copy link

lalanikarim commented Apr 21, 2022

Summary

Unable to use phpactor language server for php.

Attempting to connect results in the below error:

helix_lsp [ERROR] failed to initialize language server: failed to parse: data did not match any variant of untagged enum OneOf

Reproduction Steps

  1. create a bash script as phpactor.sh and make it executable and add it path.
#!/bin/bash
nc 127.0.0.1 8888
  1. change language-server for PHP in languages.toml
[[language]]
name = "php"
scope = "source.php"
injection-regex = "php"
file-types = ["php"]
shebangs = ["php"]
roots = ["composer.json", "index.php"]
language-server = { command = "phpactor.sh" }
indent = { tab-width = 4, unit = "    " }
  1. launch language server using command phpactor language-server --address=127.0.0.1:8888 -vvv
  2. launch hx and open a PHP file.
  3. Invoke code_action using <space>+a

Expected behavior:
LSP client connects with server

Actual behavior:
Status line says: "Language server not active for current buffer"

Helix log

❯ tail -f ~/.cache/helix/helix.log 
2022-04-20T16:14:58.088 helix_lsp::transport [ERROR] err <- "note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.\n"
2022-04-20T16:18:11.224 helix_lsp::transport [INFO] Language server not initialized, delaying request
2022-04-20T16:18:11.726 helix_term::application [ERROR] Timed out waiting for language servers to shutdown
2022-04-20T16:18:12.941 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false}},"window":{"workDoneProgress":true},"workspace":{"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"workspaceFolders":true}},"processId":193232,"rootPath":"/home/karim/Projects/IIPlatform/git/resource-server","rootUri":"file:///home/karim/Projects/IIPlatform/git/resource-server","workspaceFolders":[{"name":"resource-server","uri":"file:///home/karim/Projects/IIPlatform/git/resource-server"}]},"id":0}
2022-04-20T16:18:13.068 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"triggerCharacters":[":",">","$"]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":[],"documentSymbolProvider":[],"codeActionProvider":{"codeActionKinds":["quickfix.import_class","quickfix.complete_constructor","quickfix.complete_constructor_public","quickfix.create_class","quickfix.add_missing_properties","quickfix.implement_contracts","quickfix.fix_namespace_class_name","quickfix.generate_method","refactor.extract.method","refactor.extract.constant","quickfix.generate_accessors","refactor.extract.expression"]},"workspaceSymbolProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"executeCommandProvider":{"commands":["name_import","transform","create_class","generate_method","extract_method","extract_constant","generate_accessors","import_all_unresolved_names","extract_expression"]},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**\/*.php"}}]}}}},"serverInfo":[]}}
2022-04-20T16:18:13.068 helix_lsp::transport [INFO] <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix.import_class","quickfix.complete_constructor","quickfix.complete_constructor_public","quickfix.create_class","quickfix.add_missing_properties","quickfix.implement_contracts","quickfix.fix_namespace_class_name","quickfix.generate_method","refactor.extract.method","refactor.extract.constant","quickfix.generate_accessors","refactor.extract.expression"]},"completionProvider":{"triggerCharacters":[":",">","$"]},"definitionProvider":true,"documentHighlightProvider":[],"documentSymbolProvider":[],"executeCommandProvider":{"commands":["name_import","transform","create_class","generate_method","extract_method","extract_constant","generate_accessors","import_all_unresolved_names","extract_expression"]},"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":1,"typeDefinitionProvider":true,"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.php"}}]}}},"workspaceSymbolProvider":true},"serverInfo":[]}
2022-04-20T16:18:13.068 helix_lsp [ERROR] failed to initialize language server: failed to parse: data did not match any variant of untagged enum OneOf
2022-04-20T20:30:39.471 helix_lsp::transport [INFO] Language server not initialized, delaying request
2022-04-20T20:30:39.973 helix_term::application [ERROR] Timed out waiting for language servers to shutdown
2022-04-21T12:46:27.731 helix_lsp [ERROR] failed to initialize language server: failed to parse: data did not match any variant of untagged enum OneOf

Language Server Log

Here is the output from phpactor language-server:

❯ phpactor language-server --address=127.0.0.1:8888 -vvv
Starting language server, use -vvv for verbose output
[INFO][563120.948654] Listening on 127.0.0.1:8888[]
[INFO][563130.657278] Accepted connection from "127.0.0.1:36658"[]
[INFO][563138.279262] Accepted connection from "127.0.0.1:36660"[]
[INFO][563187.615276] Accepted connection from "127.0.0.1:36662"[]
[INFO][563187.615943] IN:{
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
        "capabilities": {
            "textDocument": {
                "codeAction": {
                    "codeActionLiteralSupport": {
                        "codeActionKind": {
                            "valueSet": [
                                "",
                                "quickfix",
                                "refactor",
                                "refactor.extract",
                                "refactor.inline",
                                "refactor.rewrite",
                                "source",
                                "source.organizeImports"
                            ]
                        }
                    }
                },
                "completion": {
                    "completionItem": {
                        "resolveSupport": {
                            "properties": [
                                "documentation",
                                "detail",
                                "additionalTextEdits"
                            ]
                        },
                        "snippetSupport": false
                    },
                    "completionItemKind": []
                },
                "hover": {
                    "contentFormat": [
                        "markdown"
                    ]
                },
                "rename": {
                    "dynamicRegistration": false,
                    "honorsChangeAnnotations": false,
                    "prepareSupport": false
                }
            },
            "window": {
                "workDoneProgress": true
            },
            "workspace": {
                "configuration": true,
                "didChangeConfiguration": {
                    "dynamicRegistration": false
                },
                "workspaceFolders": true
            }
        },
        "processId": 92025,
        "rootPath": "\/home\/karim\/Projects\/IIPlatform\/git\/resource-server",
        "rootUri": "file:\/\/\/home\/karim\/Projects\/IIPlatform\/git\/resource-server",
        "workspaceFolders": [
            {
                "name": "resource-server",
                "uri": "file:\/\/\/home\/karim\/Projects\/IIPlatform\/git\/resource-server"
            }
        ]
    },
    "id": 0
}
[INFO][563187.729657] OUT: {
    "jsonrpc": "2.0",
    "id": 0,
    "result": {
        "capabilities": {
            "textDocumentSync": 1,
            "completionProvider": {
                "workDoneProgress": null,
                "triggerCharacters": [
                    ":",
                    ">",
                    "$"
                ],
                "allCommitCharacters": null,
                "resolveProvider": null
            },
            "hoverProvider": true,
            "signatureHelpProvider": {
                "workDoneProgress": null,
                "triggerCharacters": [
                    "(",
                    ","
                ],
                "retriggerCharacters": null
            },
            "declarationProvider": null,
            "definitionProvider": true,
            "typeDefinitionProvider": true,
            "implementationProvider": true,
            "referencesProvider": true,
            "documentHighlightProvider": {
                "workDoneProgress": null
            },
            "documentSymbolProvider": {
                "workDoneProgress": null
            },
            "codeActionProvider": {
                "workDoneProgress": null,
                "codeActionKinds": [
                    "quickfix.import_class",
                    "quickfix.complete_constructor",
                    "quickfix.complete_constructor_public",
                    "quickfix.create_class",
                    "quickfix.add_missing_properties",
                    "quickfix.implement_contracts",
                    "quickfix.fix_namespace_class_name",
                    "quickfix.generate_method",
                    "refactor.extract.method",
                    "refactor.extract.constant",
                    "quickfix.generate_accessors",
                    "refactor.extract.expression"
                ]
            },
            "codeLensProvider": null,
            "documentLinkProvider": null,
            "colorProvider": null,
            "workspaceSymbolProvider": true,
            "documentFormattingProvider": null,
            "documentRangeFormattingProvider": null,
            "documentOnTypeFormattingProvider": null,
            "renameProvider": {
                "workDoneProgress": null,
                "prepareProvider": true
            },
            "foldingRangeProvider": null,
            "selectionRangeProvider": true,
            "executeCommandProvider": {
                "workDoneProgress": null,
                "commands": [
                    "name_import",
                    "transform",
                    "create_class",
                    "generate_method",
                    "extract_method",
                    "extract_constant",
                    "generate_accessors",
                    "import_all_unresolved_names",
                    "extract_expression"
                ]
            },
            "experimental": null,
            "workspace": {
                "fileOperations": {
                    "willRename": {
                        "filters": [
                            {
                                "scheme": null,
                                "pattern": {
                                    "glob": "**\/*.php",
                                    "matches": null,
                                    "options": null
                                }
                            }
                        ]
                    }
                }
            }
        },
        "serverInfo": []
    },
    "error": null
}

Platform

Linux 5.16.19-76051619-generic x86_64

Terminal Emulator

tmux-256color

Helix Version

22.03-118-gb0bceb56

@lalanikarim lalanikarim added the C-bug Category: This is a bug label Apr 21, 2022
@the-mikedavis
Copy link
Member

That error in the log is coming from here:

#[error("failed to parse: {0}")]

The server seems to be sending a message that breaks the LSP spec. I'm not sure what about the message is failing to parse though. You may need to compare the messages to the lsp spec

@lalanikarim
Copy link
Author

That error in the log is coming from here:

#[error("failed to parse: {0}")]

The server seems to be sending a message that breaks the LSP spec. I'm not sure what about the message is failing to parse though. You may need to compare the messages to the lsp spec

Thanks. I'll look into it.

@lalanikarim
Copy link
Author

The issue seems to stem more than likely from phpactor returning an empty array for serverInfo.
Based on the LSP spec, serverInfo was introduced in 3.15 and is optional.
LSP Spec: Initialize Result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug upstream
Projects
None yet
Development

No branches or pull requests

3 participants