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

Add php-language-server #653

Closed
wants to merge 2 commits into from
Closed

Add php-language-server #653

wants to merge 2 commits into from

Conversation

mjlbach
Copy link
Contributor

@mjlbach mjlbach commented Jan 9, 2021

Request from reddit, I can't test because I can't get composer to install php language server.

CONFIG.md Outdated

To use `php-language-server`, you must define `cmd` when you setup the language server:
```lua
require'lspconfig'.sumneko_lua.setup {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be php_language_server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we use the official name in the docs. Substitute underscores is just a lua thing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not clear. It requires sumneko_lua for php server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's a typo

@mjlbach
Copy link
Contributor Author

mjlbach commented Jan 10, 2021

@sunzoje did you try this? Does it work?

@sunzoje
Copy link

sunzoje commented Jan 10, 2021

I don't use php that much. Let me test and report back to you.

@sunzoje
Copy link

sunzoje commented Jan 10, 2021

:lua print(vim.inspect(vim.lsp.buf_get_clients())) returns {}.
Log from the lsp:

[ INFO ] 2021-01-10T09:12:14+0545 ] ...ovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp/rpc.lua:311 ]	"Starting RPC client"	{  args = { "./vendor/felixfbecker/language-server/bin/php-language-server.php" },  cmd = "php",  extra = {}}
[ DEBUG ] 2021-01-10T09:12:14+0545 ] ...r/neovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp.lua:627 ]	"LSP[php_language_server]"	"initialize_params"	{  capabilities = {    callHierarchy = {      dynamicRegistration = false,      <metatable> = <1>{        __tostring = <function 1>      }    },    textDocument = {      codeAction = {        codeActionLiteralSupport = {          codeActionKind = {            valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        dynamicRegistration = false,        <metatable> = <table 1>      },      completion = {        completionItem = {          commitCharactersSupport = false,          deprecatedSupport = false,          documentationFormat = { "markdown", "plaintext" },          preselectSupport = false,          snippetSupport = false,          <metatable> = <table 1>        },        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 },          <metatable> = <table 1>        },        contextSupport = false,        dynamicRegistration = false,        <metatable> = <table 1>      },      declaration = {        linkSupport = true,        <metatable> = <table 1>      },      definition = {        linkSupport = true,        <metatable> = <table 1>      },      documentHighlight = {        dynamicRegistration = false,        <metatable> = <table 1>      },      documentSymbol = {        dynamicRegistration = false,        hierarchicalDocumentSymbolSupport = 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 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      hover = {        contentFormat = { "markdown", "plaintext" },        dynamicRegistration = false,        <metatable> = <table 1>      },      implementation = {        linkSupport = true,        <metatable> = <table 1>      },      publishDiagnostics = {        relatedInformation = true,        tagSupport = {          valueSet = { 1, 2 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      references = {        dynamicRegistration = false,        <metatable> = <table 1>      },      rename = {        dynamicRegistration = false,        prepareSupport = true,        <metatable> = <table 1>      },      signatureHelp = {        dynamicRegistration = false,        signatureInformation = {          documentationFormat = { "markdown", "plaintext" },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      synchronization = {        didSave = true,        dynamicRegistration = false,        willSave = false,        willSaveWaitUntil = false,        <metatable> = <table 1>      },      typeDefinition = {        linkSupport = true,        <metatable> = <table 1>      },      <metatable> = <table 1>    },    window = {      showDocument = {        support = false,        <metatable> = <table 1>      },      showMessage = {        messageActionItem = {          additionalPropertiesSupport = false,          <metatable> = <table 1>        },        <metatable> = <table 1>      },      workDoneProgress = true,      <metatable> = <table 1>    },    workspace = {      applyEdit = true,      configuration = true,      symbol = {        dynamicRegistration = false,        hierarchicalWorkspaceSymbolSupport = 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 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      workspaceFolders = true,      <metatable> = <table 1>    }  },  initializationOptions = vim.empty_dict(),  processId = 71561,  rootPath = "/private/tmp/phptest",  rootUri = "file:///private/tmp/phptest",  trace = "off",  workspaceFolders = { {      name = "/private/tmp/phptest",      uri = "file:///private/tmp/phptest"    } }}
[ DEBUG ] 2021-01-10T09:12:14+0545 ] ...ovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp/rpc.lua:388 ]	"rpc.send.payload"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      callHierarchy = {        dynamicRegistration = false,        <metatable> = <1>{          __tostring = <function 1>        }      },      textDocument = {        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          dynamicRegistration = false,          <metatable> = <table 1>        },        completion = {          completionItem = {            commitCharactersSupport = false,            deprecatedSupport = false,            documentationFormat = { "markdown", "plaintext" },            preselectSupport = false,            snippetSupport = false,            <metatable> = <table 1>          },          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 },            <metatable> = <table 1>          },          contextSupport = false,          dynamicRegistration = false,          <metatable> = <table 1>        },        declaration = {          linkSupport = true,          <metatable> = <table 1>        },        definition = {          linkSupport = true,          <metatable> = <table 1>        },        documentHighlight = {          dynamicRegistration = false,          <metatable> = <table 1>        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = 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 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false,          <metatable> = <table 1>        },        implementation = {          linkSupport = true,          <metatable> = <table 1>        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        references = {          dynamicRegistration = false,          <metatable> = <table 1>        },        rename = {          dynamicRegistration = false,          prepareSupport = true,          <metatable> = <table 1>        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            documentationFormat = { "markdown", "plaintext" },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = false,          willSaveWaitUntil = false,          <metatable> = <table 1>        },        typeDefinition = {          linkSupport = true,          <metatable> = <table 1>        },        <metatable> = <table 1>      },      window = {        showDocument = {          support = false,          <metatable> = <table 1>        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false,            <metatable> = <table 1>          },          <metatable> = <table 1>        },        workDoneProgress = true,        <metatable> = <table 1>      },      workspace = {        applyEdit = true,        configuration = true,        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = 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 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        workspaceFolders = true,        <metatable> = <table 1>      }    },    initializationOptions = vim.empty_dict(),    processId = 71561,    rootPath = "/private/tmp/phptest",    rootUri = "file:///private/tmp/phptest",    trace = "off",    workspaceFolders = { {        name = "/private/tmp/phptest",        uri = "file:///private/tmp/phptest"      } }  }}
[ ERROR ] 2021-01-10T09:12:14+0545 ] ...ovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ]	"rpc"	"php"	"stderr"	"DEBUG     Checking PHPLS_ALLOW_XDEBUG\nDEBUG     The Xdebug extension is not loaded\nDEBUG     Listening on STDIN\n"
[ DEBUG ] 2021-01-10T09:12:18+0545 ] ...ovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp/rpc.lua:489 ]	"decoded"	{  error = {    code = -32603,    data = vim.NIL,    message = "ErrorException: file_get_contents(/private/tmp/phptest/vendor/felixfbecker/language-server/src/Index/../../stubs): failed to open stream: No such file or directory in /private/tmp/phptest/vendor/felixfbecker/language-server/src/Index/StubsIndex.php:15\nStack trace:\n#0 [internal function]: {closure}(2, 'file_get_conten...', '/private/tmp/ph...', 15, Array)\n#1 /private/tmp/phptest/vendor/felixfbecker/language-server/src/Index/StubsIndex.php(15): file_get_contents('/private/tmp/ph...')\n#2 /private/tmp/phptest/vendor/felixfbecker/language-server/src/LanguageServer.php(190): LanguageServer\\Index\\StubsIndex::read()\n#3 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#4 /private/tmp/phptest/vendor/sabre/event/lib/coroutine.php(70): Generator->valid()\n#5 /private/tmp/phptest/vendor/sabre/event/lib/coroutine.php(117): Sabre\\Event\\{closure}()\n#6 /private/tmp/phptest/vendor/felixfbecker/language-server/src/LanguageServer.php(292): Sabre\\Event\\coroutine(Object(Closure))\n#7 /private/tmp/phptest/vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php(169): LanguageServer\\LanguageServer->initialize(Object(LanguageServerProtocol\\ClientCapabilities), '/private/tmp/ph...', 71561, 'file:///private...')\n#8 /private/tmp/phptest/vendor/felixfbecker/language-server/src/LanguageServer.php(131): AdvancedJsonRpc\\Dispatcher->dispatch(Object(AdvancedJsonRpc\\Request))\n#9 [internal function]: LanguageServer\\LanguageServer->LanguageServer\\{closure}()\n#10 /private/tmp/phptest/vendor/sabre/event/lib/coroutine.php(70): Generator->valid()\n#11 /private/tmp/phptest/vendor/sabre/event/lib/coroutine.php(117): Sabre\\Event\\{closure}()\n#12 /private/tmp/phptest/vendor/felixfbecker/language-server/src/LanguageServer.php(154): Sabre\\Event\\coroutine(Object(Closure))\n#13 /private/tmp/phptest/vendor/sabre/event/lib/EmitterTrait.php(80): LanguageServer\\LanguageServer->LanguageServer\\{closure}(Object(LanguageServer\\Message))\n#14 /private/tmp/phptest/vendor/felixfbecker/language-server/src/ProtocolStreamReader.php(56): Sabre\\Event\\Emitter->emit('message', Array)\n#15 /private/tmp/phptest/vendor/sabre/event/lib/Loop/Loop.php(281): LanguageServer\\ProtocolStreamReader->LanguageServer\\{closure}()\n#16 /private/tmp/phptest/vendor/sabre/event/lib/Loop/Loop.php(210): Sabre\\Event\\Loop\\Loop->runStreams(NULL)\n#17 /private/tmp/phptest/vendor/sabre/event/lib/Loop/Loop.php(173): Sabre\\Event\\Loop\\Loop->tick(true)\n#18 /private/tmp/phptest/vendor/sabre/event/lib/Loop/functions.php(102): Sabre\\Event\\Loop\\Loop->run()\n#19 /private/tmp/phptest/vendor/felixfbecker/language-server/bin/php-language-server.php(109): Sabre\\Event\\Loop\\run()\n#20 {main}"  },  id = 1,  jsonrpc = "2.0"}
[ INFO ] 2021-01-10T09:13:55+0545 ] ...r/neovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp.lua:999 ]	"exit_handler"	{}

[ INFO ] 2021-01-10T09:15:05+0545 ] ...r/neovim/HEAD-b535575/share/nvim/runtime/lua/vim/lsp.lua:999 ]	"exit_handler"	{}

@mjlbach
Copy link
Contributor Author

mjlbach commented Jan 10, 2021

Did you generate stubs like in the installation instructions?

failed to open stream: No such file or directory in /private/tmp/phptest/vendor/felixfbecker/language-server/src/Index/StubsIndex.php

@sunzoje
Copy link

sunzoje commented Jan 10, 2021

I missed that part. I thought that part is optional.

@sunzoje
Copy link

sunzoje commented Jan 10, 2021

I'm not able to generate stubs; getting following error:

Parsing file:///private/tmp/phptest/vendor/jetbrains/phpstorm-stubs/standard/standard_8.php
Script LanguageServer\ComposerScripts::parseStubs handling the parse-stubs event terminated with an exception
  [RuntimeException]
  A type is missing before a type separator

This issue is documented in felixfbecker/php-language-server#795.
Once rectifying the issue, the addition of this server is working.

@Mte90
Copy link

Mte90 commented Jan 12, 2021

It seems that to use that php LSP it is required a local patched version or that someone does a fork.

Very sad as it is seems that is abandoned. At the same time is the most used and famous language server for php -.-'

@mjlbach mjlbach closed this Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants