csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

On neovim decompile does not work

Open Decodetalkers opened this issue 3 years ago • 15 comments

When I use csharpls, and use the jump of nvimlsp, it do not return a decompile file.

I see that you have support decompile, I think it should work

Decodetalkers avatar Mar 08 '22 07:03 Decodetalkers

hi @chen244

support for decompilation is an (custom) extension of lsp protocol and needs work on the client to be supported (works on emacs only for now, AFAIK)

if you're willing to do this I can provide pointers; you should probably check java/clojure or other related nvimlsp client where decompilation is supported, copy the code and I can help you hack it in

razzmatazz avatar Mar 08 '22 07:03 razzmatazz

hi @chen244

support for decompilation is an extension of lsp protocol and needs work on the client to be supported (works on emacs only for now, AFAIK)

if you're willing to do this I can provide pointers; you should probably check java/clojure or other related nvimlsp client where decompilation is supported, copy the code and I can help you hack it in

Thanks. what should I do , how to make a lsp extension to support decompile? I will try. Can you help me?

Decodetalkers avatar Mar 08 '22 07:03 Decodetalkers

can you find an existing nvimlsp client that suports decompilation? so we can have some starting base. maybe java or clojure or some other?

razzmatazz avatar Mar 08 '22 07:03 razzmatazz

can you find an existing nvimlsp client that suports decompilation? so we can have some starting base. maybe java or clojure or some other?

https://github.com/Hoffs/omnisharp-extended-lsp.nvim/issues/6 It is decompile for omnisharp But it is the autor says it is because the bug of omnisharp..

Decodetalkers avatar Mar 08 '22 07:03 Decodetalkers

this is a great start!

I have no experience in nvim/lua but copying most of the logic plus doing a couple of changes should work as the protocol for csharp-ls "get metadata" is not that different from omnisharp-lsp "get metadata" op

razzmatazz avatar Mar 08 '22 08:03 razzmatazz

Thanks very much

Decodetalkers avatar Mar 08 '22 08:03 Decodetalkers

local result, err = client.request_sync("o#/metadata", params, 10000)

in omnisharp , it get the decompile from o#/metadata, but how can I get the result in csharp_ls

Decodetalkers avatar Mar 08 '22 10:03 Decodetalkers

the handler for this on csharp-ls is "csharp/metadata":

  • https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L1206

you need to send this:

  • https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L72

and the response is:

  • https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L76

you can see emacs lsp-mode implementation here:

  • https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-csharp.el#L381

please ask if you need request examples, I may be able to provide lsp traces for what emacs sends and receives so you can emulate this

razzmatazz avatar Mar 08 '22 10:03 razzmatazz

the handler for this on csharp-ls is "csharp/metadata":

* https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L1206

you need to send this:

* https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L72

and the response is:

* https://github.com/razzmatazz/csharp-language-server/blob/master/src/CSharpLanguageServer/Server.fs#L76

you can see emacs lsp-mode implementation here:

* https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-csharp.el#L381

please ask if you need request examples, I may be able to provide lsp traces for what emacs sends and receives so you can emulate this

For example ,I get csharp:/metadata/projects/trainning2/assemblies/System.Console/symbols/System.Console.cs this url

and I will get

{
      assymblyName = "System.Console", 
     projectName = "trainning2",
      typeName = "System.Console"
}

Then I send this to csharp/metadata. is it right?

Decodetalkers avatar Mar 08 '22 11:03 Decodetalkers

emacs trace for go-to-def to string:

Screenshot 2022-03-08 at 13 15 02

resolving definition:

Screenshot 2022-03-08 at 13 17 28

then it sees that the url is csharp:/ and retrieves metadata:

Screenshot 2022-03-08 at 13 18 17

razzmatazz avatar Mar 08 '22 11:03 razzmatazz

emacs trace for go-to-def to string:

Screenshot 2022-03-08 at 13 15 02

resolving definition:

Screenshot 2022-03-08 at 13 17 28

then it sees that the url is csharp:/ and retrieves metadata:

Screenshot 2022-03-08 at 13 18 17

I Got it! will

https://github.com/chen244/csharpls_extend-lsp.nvim

I finished it!!

Decodetalkers avatar Mar 08 '22 11:03 Decodetalkers

great!

razzmatazz avatar Mar 08 '22 13:03 razzmatazz

btw, could you add PR with FAQ entry to README.md on this project on how to make it work?

razzmatazz avatar Mar 08 '22 13:03 razzmatazz

btw, could you add PR with FAQ entry to README.md on this project on how to make it work?

Ok , I see. btw, you means your project, the csharp-language-server?

Decodetalkers avatar Mar 08 '22 13:03 Decodetalkers

btw, could you add PR with FAQ entry to README.md on this project on how to make it work?

Ok , I see. btw, you means your project, the csharp-language-server?

yes, here https://github.com/razzmatazz/csharp-language-server/blob/master/README.md

I see there is not FAQ yet, -- just add new FAQ section and then you could just drop a line with reference to your project or general directions on to make metadata work on nvim

razzmatazz avatar Mar 08 '22 13:03 razzmatazz