Open EmranMR opened 11 months ago
Got me wondering if this LSP requires phpactor
to be an active LSP for php
files as a prerequisite? 🤔
Hey EmranMR,
It does should not require phpactor to be active.
Not too sure about the error you are getting, what if you disable hover capabilities?
Hey @haringsrob! Sorry for the late reply. So I decided to try the bare phpactor LSP itself for comparison to see if that would also give the similar error, returning the wrong types JSON-RPC response.
The phpactor implementation worked really fine, In fact far more superior than the intelephense I had before so will be looking into porting that as well in the future as an extension!
I checked the logs Phpactor and all the capabilities were returned correctly such as bool
object
etc.
Now I did a quick search in your source code, not sure but might be related to registerCapabilties??
To give you an example phpactor returns bool
for hoverProvider: true
but the laravel-dev-tools return the following:
"hoverProvider" : "Phpactor\\LanguageServerProtocol\\HoverClientCapabilities",
"definitionProvider" : "Phpactor\\LanguageServerProtocol\\DefinitionClientCapabilities",
"documentSymbolProvider" : "Phpactor\\LanguageServerProtocol\\DocumentSymbolClientCapabilities",
This response is just returning the Phpactor
class as is for some reason rather than the values.
If we look at registerCapabilties className
as strings are returned? I could be very well wrong. I might fork and hardcode the values such as true for hoverProvider
and see what happens after the build. 🤔
public function registerCapabiltiies(ServerCapabilities $capabilities): void
{
$options = new CompletionOptions();
$options->triggerCharacters = ['<', ':', '@'];
$capabilities->completionProvider = $options;
$capabilities->definitionProvider = DefinitionClientCapabilities::class;
$capabilities->hoverProvider = HoverClientCapabilities::class;
$capabilities->documentSymbolProvider = DocumentSymbolClientCapabilities::class;
}
I just hardcoded the hoverProvider
in registerCapabilties as true
and that error got cleared.
"hoverProvider" : true,
"definitionProvider" : "Phpactor\\LanguageServerProtocol\\DefinitionClientCapabilities",
"documentSymbolProvider" : "Phpactor\\LanguageServerProtocol\\DocumentSymbolClientCapabilities",
so registerCapabilties worth having a look at.
Although now I am getting errors such as:
Example Language Server connection closed unexpectedly: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "result", intValue: nil), CodingKeys(stringValue: "capabilities", intValue: nil), CodingKeys(stringValue: "definitionProvider", intValue: nil)], debugDescription: "Expected Bool or DefinitionOptions", underlyingError: nil))
I reckon VsCode prob has better error handling that is why it is working in VScode?
Thanks Emran!
Hello @haringsrob. I am very keen to try your LSP however I hit some roadblocks. I was wondering if you could help. I should also mention I am not an expert in LSP by any means. I am just trying to port this LSP into Nova by following the documentations 😊
I am writing an extension for the Nova editor. Please checkout the branch named
LSP
if you need to.You can check out the documentation by Nova about their language-client. Here is a summary of installation:
./laravel-dev-tools app:build
and copied into the extension root.builds/
folder of your repo inside my extension.LanguageClient
to your executable viastdio
Based on the docs on Nova and your repo that should be it. In fact it seemed to have worked fine in sublime, neovim and vsCode looking at the other issues. But I get errors in return for some reason.
Once I initiate the LSP I get the following error in debug mode:
To summerise Nova is moaning about the
hoverProvider
not havingExpected Bool or HoverOptions
as the value because the value isPhpactor\\LanguageServerProtocol\\HoverClientCapabilities
, see below 👇1. Error Messages
2. Nova's Request to the LSP
3. Laravel-dev-tools Response