onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.35k stars 299 forks source link

Support PHP language server #647

Open azzsh opened 7 years ago

azzsh commented 7 years ago

Why isn't there any support for PHP in Roadmap?

bryphe commented 7 years ago

Ah, sorry if that wasn't clear! Issue #504 is tracking having a generalized language server integratoin.

Once this is in, it'd be easy to integrate Oni with one of the PHP language servers listed at http://langserver.org:

By using a configuration setting. I'll leave this open to track validating that generalized solution works against one of those PHP servers. Thanks for the question, @azzsh !

felmab commented 6 years ago

I installed felixfbecker/php-language-server and added this configuration:

`"language.php.languageServer": {
        "command": "php",
        "arguments": ["/path/to/home/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php"],`

When I open a PHP file with oni, there's a lightning sign in the status bar, and a language server process is launched, however nothing seems to happen: no completion, impossible to go to definition... What went wrong?

Sydney-o9 commented 6 years ago

@bryphe Awesome IDE(a) and we cannot wait to have PHP running with it. How can we help, what can we do to get php language support? Currently using just neovim but the features provided by oni is exactly what one wants.. Beautiful GUI with the power of vim/neovim..

When do you think we will have the chance to run php lang with it?

bryphe commented 6 years ago

@bryphe Awesome IDE(a) and we cannot wait to have PHP running with it.

Cheers, thanks!

How can we help, what can we do to get php language support?

Unfortunately I don't have a PHP environment set up at the moment to test with. But if you're up for debugging, that would be great!

This configuration looks like a good start:

`"language.php.languageServer": {
        "command": "php",
        "arguments": ["/path/to/home/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php"],`

But I believe there may be a bug where it only accepts the string form right now, so collapsing the configuration options is worth a shot:

"language.php.languageServer.command": "php",     
"language.php.languageServer.arguments": ["/path/to/home/.composer/vendor/felixfbecker/language-server/bin/php-language-server.php"],

The next step would be to grab the debug output from our console - I'm interested if there are any errors. You can do that by:

Once the dev tools are open, please enable debug logging: image by running Oni.log.enableDebugLogging() in the console

Then, if you could navigate to a php file and share the output, that would be able to help us see if the server is being initialized, and if there are any errors.

Thanks @felmab & @Sydney-o9 for your help & interest in the project!

felmab commented 6 years ago

Actually, I could not make it work with the string form. Apparently it does make requests to the language server, either there is no answer or Oni cannot deal with it... I do not know how one is supposed to debug a language server, though.

1512123026383.log 1512123494432.log

wxactly commented 6 years ago

Hey everyone - new user here. So excited to have discovered Oni, and this thread! Wanted to drop a note here to say that the latest version of php-language-server seems to be working great with Oni.

I installed php-language-server per the instructions here: https://github.com/felixfbecker/php-language-server#installation

cd /your/composer/path
composer require felixfbecker/language-server
composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs

And this oni config:

export const configuration = {
    //...

    "language.php.languageServer.command": "php",
    "language.php.languageServer.arguments": [
      "/your/composer/path/vendor/felixfbecker/language-server/bin/php-language-server.php"
    ],
}

@bryphe - here's the log output I'm seeing. Like I said, the server is working for me. But I do see a couple errors in there, in case those are helpful for debugging. Thanks all!

php-language-server-20180423.log

bryphe commented 6 years ago

Thanks for the update @wxactly ! That's great news that it's working with the latest version of php-language-server! 🎉 Really appreciate you sharing the config and settings that worked.

The log output is very helpful. It looks like in general it's working - but I do see one issue in particular:


bundle.js:1 Error: Method completionItem/resolve is not implemented
    at new ResponseError (/Applications/Oni.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/messages.js:46)
    at handleResponse (/Applications/Oni.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/main.js:430)
    at processMessageQueue (/Applications/Oni.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/main.js:258)
    at Immediate._onImmediate (/Applications/Oni.app/Contents/Resources/app/node_modules/vscode-jsonrpc/lib/main.js:242)
    at runCallback (timers.js:781)
    at tryOnImmediate (timers.js:743)
    at processImmediate [as _immediateCallback] (timers.js:714)
t.error @ bundle.js:1
r._currentPromise.the

It seems we are always sending a completionItem/resolve request, even in the case where the language server doesn't support it. If the language server does not specify support for this in the initialize call, then we should respect that.

The other issue I saw in the logs is not being able to find a specialized textmate grammar for syntax highlighting - this is harmless, but it will actually be resolved in the next release, as @Akin909 added support for it in #2068 💯

So these are the outstanding issues I see remaining: