-
Notifications
You must be signed in to change notification settings - Fork 60
Add --stdio switch #88
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
Conversation
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.
Thanks! Whether we merge this or not, thanks for the PR =)
Yeah I'm a little worried about supporting important codepaths when we don't actively use or recommend them. In particular, providing an upfront disclaimer doesn't work at community scale because folks still get frustrated even with the warning and/or there ends up being folks who adopt this setup from someone's ill-guided recommendation without knowing about the disclaimer.
However we can make exceptions when the ROI is big enough... so that's a maybe. Let's see how clean this PR gets first.
server/src/server.ts
Outdated
}; | ||
|
||
let argv = process.argv.slice(2); | ||
for (let i = 0; i < argv.length; i++) { |
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.
Why are we looping over the args? Is it because you're catering to having the server opened with extra arguments from the debugging mode (does it do that...? I forgot)
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.
Thanks for looking at the PR!
It's not because of debug mode: I wasn't aware of that until now and I'm not yet familiar with whatever debugging facilities are provided by either VS code or LSP.
I think I haven't understood your question correctly. Are you just saying it would be nicer to use something like process.argv.includes("--stdio")
instead of a loop?
If not: I think you understand all this already, but I'll state the context explicitly. Some editors, emacs included, want to talk LSP over standard in / standard out (stdio). Currently rescript-vscode's server.ts, if I've understood right, is only able to talk over "node IPC", which is only intended for use by node programs (i.e. programs like emacs shouldn't try to use that).
I don't know another way for the server process to know it should use stdio than looking at process.argv? I believe this is standard in LSP servers. I think I lifted this loop from vscode-languageserver-node:
https://github.com/microsoft/vscode-languageserver-node/blob/53d122831050088171296dc02b57257f5178f0b6/server/src/node/main.ts#L203
Or are you maybe thinking that vscode-languageclient should be used to tell the server to use stdio, even for editors other than VSCode? If so: I think 1. vscode-languageclient is indended only for use by VSCode clients, not servers 2. All it does other than arranging to use stdin/stdout on the client end is to pass "--stdio" to the server it's starting -- so it's still up to server.ts to test whether "--stdio" is present in the args and implement using that channel.
But as I say I I've probably misunderstood what you're asking, sorry!
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.
Nah I mean why not just check the third argument =)
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.
lol
OK, only because: 1. I copied the code from vscode-languageserver-node, 2. expecting commandline arguments only at a particular place in argv always seems a bit confusing / error-prone.
Happy to check argv[2] if you prefer, though .includes("--stdio")
seems nicer?
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.
Sure! Could you also simplify messageSender
and onMessage
to 2 function calls initiated by whether we see the flag? A little bit of contortion in the code right now
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.
Hope that's what you meant
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.
No just 2 calls, but I might have missed something. That's fine; I'll merge and do it later.
Thanks. I'll cut a release before merging this. Then I'll ping willing folks to test master |
motivated by LSP clients such as emacs lsp-mode.el that don't support communication over node IPC
f06d63f
to
998ce2b
Compare
Alright, I've cleaned up the code and pushed to your branch. I've briefly tested on Sublime Text and it seems this is good to go now. Feel free to test master. Thanks! |
Using Reason 3.3.7 @ 43efc14 Needed this before we do auto refactors later, to avoid reviewing excessive whitespaces
Using Reason 3.3.7 @ 43efc14 Needed this before we do auto refactors later, to avoid reviewing excessive whitespaces
This was discussed on the forum here. I understand your focus is on VS code so I'm not taking for granted that this will be accepted -- obviously I think the patch should be applied though :-)
Not sure if it helps, but I don't expect to be coming back with any requests to change behaviour beyond this in order to support emacs. Everything already seems workable as-is, the emacs lsp-mode.el people target feature parity with vscode, and also provide general-purpose message processing hooks to allow ad-hoc server-dependent treatment.
Should I add an explicit comment next to the command line switch code along the lines below?