HaxeFoundation / HaxeManual

The official Haxe manual
https://haxe.org/manual/
Creative Commons Attribution 4.0 International
220 stars 155 forks source link

Document JSON-RPC display protocol #422

Open garrett-hopper opened 5 years ago

garrett-hopper commented 5 years ago

I've begun looking into https://github.com/vshaxe/haxe-language-server to try to implement the new IDE features in a new Emacs mode, however I can't make heads or tails of how the JSON-RPC works. Some additional documentation to https://haxe.org/manual/cr-completion-overview.html regarding its usage would be great.

Gama11 commented 5 years ago

Unrelated, but have you considered using the language server / language server protocol directly?

garrett-hopper commented 5 years ago

I have; it works well. It feels like it's tied pretty tightly to the vshaxe plugin, and I'd like something more lightweight.

Gama11 commented 5 years ago

Tied tightly to the plugin in what way?

Anyway:

I can't make heads or tails of how the JSON-RPC works

What part are you having trouble with? I'd think it's mostly about looking at the type definitions for the available requests, their parameters and their responses (https://github.com/vshaxe/haxe-language-server/tree/master/src/haxeLanguageServer/protocol).

garrett-hopper commented 5 years ago

Perhaps that's not a fair assessment. It's been a while since I've built the lsp server. The only thing I can thing of at the moment is the need to use https://github.com/vshaxe/vshaxe-build in order to build it. (Though I'm sure there are ways around that.) Overall it just didn't seem very simple to implement with non-VSCode editor.

At the end of the day, I guess I just don't like the idea of having Emacs talk to a node server which is running on top of Haxe's compilation server. It just feels like overkill.

At the moment I'm having trouble figuring out what exactly needs to be sent to the command. I've figured out the haxe --wait stdio, but I'm not sure how that interacts with -D display-stdin. I'm also unclear on the formatting around haxe --wait stdio; I know there is some message length stuff and weird characters that need to be sent, but I can't seem to figure them out.

I'm trying to figure this out from the terminal at the moment before I move to an elisp implementation.

So if I wanted to get a response for hovering over some class name, I'd need to do something like:

I'm going to read some documentation on JSON-RPC; maybe that's what I'm missing. Once the server is running and listening on stdin, it just accepts normal JSON-RPC requests, right?

Gama11 commented 5 years ago

--wait stdio / display-stdin isn't really related to JSON-RPC / required for it. In fact, it may be better to use a regular socket connection since it's less error-prone. That's probably going to change at some point in haxe-language-server too: https://github.com/vshaxe/vshaxe/issues/217