-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allowing remote LSP connection in vscode API #102
Conversation
@Stevendeo we you say "remote", do you mean the LSP has no longer access to the file-system where the project source code is? If that's the case, I think quite a bit of work is needed, and we should schedule for a much later milestone. In particular, we should first handle some of the workspace-related requests. |
We discussed this particular issue with Fabrice the other day, so I was making a few tests. This PR is still in draft and should not have impact on the project anyway. |
Oh, and no I am just talking about the lsp being accessible through a specific address & port. I think this step is necessary before having the whole project in remote. |
c21f493
to
cd5208f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok now I start seeing what development with jsoo looks like ;-)
Very minor comments to address, and we can merge.
src/vscode/vscode-languageclient-js-stubs/vscode_languageclient.ml
Outdated
Show resolved
Hide resolved
To be fair, it should and could probably be cleaner. The problem is here that I did not find the interface between js of ocaml and the library used in the project, nor a module for websockets. I'm pretty sure there is one, but for testing I don't need it and I can do dirty things (until it breaks, because it will). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to merge. BTW do you just test it with nc
?
I did not test it yet, I did not manage to find the proper combination to make it work, as superbol expects to receive something directly from stdin and not as an argument. Is there a way to call something like EDIT: nevermind, by writing this message I found how to. |
Okay, so it manages to establish a connection, but I think something is wrong when actually sending the data. |
I added a script to simulate a remote LSP in local. For now it only allows to receive data and give it to the LSP, which seems |
REMOTE_TEST.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could just
mkfifo /tmp/somewhere # possibly in a directory resulting from `mktemp -d`
nc -l 8000 < /tmp/somewhere | superbol-free lsp > /tmp/somewhere
(as suggested here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely can't make nc work properly with the lsp server... I'll try something else I spend too much time on that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, the protocol used is HTTP/1.1 with chunk transfer encoding, which I believe is not handled by the current lsp server...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the websocket layer uses that protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, perhaps that is the protocol used by VSCode when communicating through a remote server.
src/vscode/vscode-languageclient-js-stubs/vscode_languageclient.ml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the REMOTE_TEST.md
still needs some changes. Also, I think for the moment its contents would better fit in the sphinx docs, maybe in a new file sphinx/remote-lsp.rst
.
So this "just" needs a move + adjustment of the docs + rebase to be merged? |
Doc updated & branch rebased! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see that revived ;-)
I think there's a point remaining about the documentation for testing that feature.
LanguageClient.make_stream | ||
~id | ||
~name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LanguageClient.make_stream | |
~id | |
~name | |
LanguageClient.make_stream ~id ~name |
Promise.return ( | ||
Vscode_languageclient.StreamInfo.create | ||
~writer:njs_stream | ||
~reader:njs_stream | ||
() | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise.return ( | |
Vscode_languageclient.StreamInfo.create | |
~writer:njs_stream | |
~reader:njs_stream | |
() | |
) | |
) | |
Promise.return @@ | |
Vscode_languageclient.StreamInfo.create () | |
~writer:njs_stream | |
~reader:njs_stream) |
LanguageClient.make () | ||
~id | ||
~name | ||
~serverOptions | ||
~clientOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LanguageClient.make () | |
~id | |
~name | |
~serverOptions | |
~clientOptions | |
LanguageClient.make () ~id ~name ~serverOptions ~clientOptions |
(We don't go that vertical in this project.)
~clientOptions:(Superbol_languageclient.client_options ()) | ||
let cmd = Executable.command serverOptions in | ||
if String.starts_with ~prefix:"ws://" cmd then | ||
LanguageClient.make_stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I right if I observe that options given to "usual" servers are ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what is the string that needs to be put in the command for testing? Is it just something like ws://localhost:<some port>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This PR is a bit old even for me, I'll try to answer as I remeber)
Am I right if I observe that options given to "usual" servers are ignored?
For now yes, I just added the bare minimum.
what is the string that needs to be put in the command for testing
ws://
is the prefix to add to the VSCode URL in its configuration. For testing with the cmd, just start the lsp and use this command
sphinx/remote-lsp.rst
Outdated
and call it with `test.nc`. | ||
|
||
TODO: this script only receives information, but does not send it back to | ||
VSCODE; it only writes it in superbol.log. It should answer to the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's quite a big TODO. What happens when you try this suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's quite a big TODO.
The thing was, when I started this PR, the LSP did not have a HTTP server (compatible with VSCode) , hence neither these script actually make it work. This PR was initially only to provide the base before starting the actual server
I'd say there is a missing dependency somewhere, I don't have any error EDIT : |
Yes I think that should be a dependency to declare in Edit: What version of |
ws@8.14.2 (probably not the latest version, I did not update anything since a looooong time) |
Ok thanks. Note, though: you need to |
Ouch…
|
src/vendor/vscode-ocaml-platform/src-bindings/vscode_languageclient/vscode_languageclient.ml
Outdated
Show resolved
Hide resolved
@nberth Is there anything missing apart from the Changelog entry? |
I think a better error reporting might be relevant still. At the moment if the TCP connection fails VSCode reports a lot of errors to the user, none of which seeming to indicate the root cause of the issue. Fixing that may be delayed though, as otherwise remote connection over TCP is operational (a more secure option, e.g with TLS, could be better — but that's definitely for later). @Stevendeo I think parts of the new code is not in the proper module. I have a commit ready to move it (did it when I tried to fix error reporting … to no avail alas) ; may I push directly on your branch? |
Yes of course; tell me when you're done so I can push a few last updates (Changelog + doc) |
Actually I opened a PR on your repository so you can see the changes first. |
Some additions for the remote LSP connection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great many thanks! We can merge after the forgotten comment has been removed.
Done and ready to merge! |
This PR adds the required utils for connecting vscode editor to a remote LSP.