Open mickaelistria opened 8 years ago
@mickaelistria
OmniSharp -v -s /path/to/my/project/
-v
is important so you can see what the response looks like.
Omnisharp starts a webserver listening at localhost:2000
by default.
See all the http endpoints available here.
You can then use curl
to experiment.
Find the usage of each enum values and see which Request
class is associated so you can know what parameters each endpoint expect.
Let's take an example.
The endpoint enumeration is GoToDefinition
therefore the url will be http://localhost:2000/gotodefinition
.
After searching for its usages we can see it's used in the class GotoDefinitionRequest
which inherits from Request
. Each properties on those classes represent the http request parameters.
Here are all the properties:
Line
Column
Buffer
Changes
FileName
Timeout
WantMetadata
From my experience I know that when you need to go to the definition of a symbol you need to at least send to the server the line, column and file name values (the rest are optional, ie. it won't blow up).
With this we can craft this query:
curl -H "Content-Type: application/json" -X POST -d '{"Line":"31","Column":"26", "FileName":"/absolute/path/to/filename.cs"}' http://localhost:2000/gotodefinition
We should get the response back:
{"FileName":"/absolute/path/to/method/file.cs","Line":34,"Column":46,"MetadataSource":null}
Hope that helps.
@jtbm37 Thanks, that's very helpful, and I made progress thanks to your help. Is there a way to set the workspace "remotely", using some HTTP request to load it instead of using the -s /path/to/project
CLI parameter?
@mickaelistria did you get things running in the end? I'm doing the same thing you did back in July, m first request works then the second fails, did you come against a similar problem?
As I'm working on a client for a Java application (Eclipse, https://github.com/eclipselabs/eclipse-language-service ) and moved using the https://github.com/OmniSharp/omnisharp-node-client wrapper around OmniSharp, which implements https://github.com/Microsoft/language-server-protocol, I could use a nice Java client API ( https://github.com/TypeFox/ls-api ). The node client can understand JSon-RPC requests via stdin/stdout.
@mickaelistria thanks, fyi it turned out verbose mode was breaking it. I opened issue #629 regarding that.
Thanks anyway
A request from @thinca in the omnisharp-vim repo along the same lines as this request for (more) documentation:
I want:
- API reference, which describes all endpoints, and its input and output.
- Command line reference of OmniSharp command.
- About stdio mode.
I understand manpower is not enough. However, it is difficult for non core member of omnisharp-roslyn to follow the latest version without documentation.
So, is there a way to do what @mickaelistria wanted to do on https://github.com/OmniSharp/omnisharp-roslyn/issues/606#issuecomment-231793946 ? Or should I open a new issue for this?
@jtbm37
Start the server
OmniSharp -v -s /path/to/my/project/
Unfortunately I failed at the first step on macOS, see #2440.
+1 for creating some documentation around how to get started
I didn't manage to find any documentation or example of how requests/answers between OmniSharp-roslyn server and whethever client should look like. I've seem some clients doing that (for Vim, VSCode or Atom) and I tried to mimic what I thought would be necessary, without much success.
I also tried the example request shown on omnisharp-sever, but this one fail too.
Usually, the error I get with my (erroneous?) requests is