Skip to content
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

lsp-csharp doesn't work with C# .net 6 projects when using csharp-ls as a language-server #3198

Closed
3 tasks done
josteink opened this issue Nov 9, 2021 · 16 comments
Closed
3 tasks done
Labels

Comments

@josteink
Copy link
Contributor

josteink commented Nov 9, 2021

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command
emacs -q -l lsp-start-plain.el

where lsp-start-plain.el can be downloaded here.

Bug description

The title pretty much says it all, but if that was all I realize I should be reporting this in csharp-ls instead of here 😄

The main problem seems to be that lsp-csharp actually provides 2 language-servers:

  • One based on Omnisharp-Roslyn
  • One based on csharp-ls ... which somehow wraps Omnisharp?

Of these two only csharp-ls is unable to run with .NET 6 projects.

So the solution is for the user to chose the Omnisharp server, and keep on working, right?

And here is the problem: The way lsp-csharp is implemented the csharp-ls language server "shadows" the Omnisharp-Roslyn language-server, making csharp-ls the only selectable/installable language-server option for C#.

A temporary workaround I have to work with .NET 6 so far is to:

  • comment out all the csharp-ls code in lsp-csharp.el
  • delete ~/.dotnet/tools/csharp-ls
  • delete ~/.emacs.d/.cache/lsp/omnisharp-roslyn
  • restart emacs
  • install Omnisharp server when prompted

If we have 2 language servers for one language, it should IMO be possible for the user to chose which one he prefers, and right now it seems like that is not really possible.

CC: @razzmatazz

Steps to reproduce

sudo apt install dotnet-sdk-6.0
mkdir test
cd test
dotnet new console
emacs Program.cs

Observed:

  • You are prompted to install csharp-ls language server (with no choice for other server)
  • Language-server does not work

Expected behavior

If several language servers are available:

  • be able to chose which one I want
  • supplied language servers to work on current versions of .NET

Which Language Server did you use?

lsp-csharp with csharp-ls language server.

OS

Linux

Error callstack

No response

Anything else?

No response

@razzmatazz
Copy link
Collaborator

razzmatazz commented Nov 9, 2021

@josteink there is razzmatazz/csharp-language-server#3 issue reported by someone yesterday

will take a look later today/this week

as for csharp-ls -- this is my reimplementation of LSP server on top of roslyn (independent implementation from omnisharp-roslyn) -- I got tired trying to get people @ omnisharp-roslyn to merge my PRs and fixes and figured I could my own LSP server -- shouldn't be that hard huh.. and for most part it isn't that hard :D as LSP maps really nicely to Roslyn APIs. omnisharp-roslyn is way more complex and has long history, as it needs to support old protocol for vscode client and other things -- csharp-ls is much simpler

it already has some features omnisharp-roslyn doesn't, like go-to-definition in metadata

I think this should then be closed :)

@josteink
Copy link
Contributor Author

josteink commented Nov 9, 2021

I think closing is premature. You can see this issue is really 2 issues:

  • error in csharp-ls (which should obviously be fixed in csharp-ls)
  • lsp-csharp having 2 language-server definitions/implementations, but only 1 of them being selectable by the user (csharp-ls).

The latter is definitely an issue which should be fixed in lsp-csharp IMO.

@razzmatazz
Copy link
Collaborator

oh.. right

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2021

There is lsp-enabled-clients and lsp-disabled-clients which you can use for selecting what servers you want to run.

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2021

I believe there is nothing else here(please reopen if you disagree).

@yyoncho yyoncho closed this as completed Nov 9, 2021
@josteink
Copy link
Contributor Author

josteink commented Nov 9, 2021

Not so much agreeing vs disagreeing, as much as I think lsp-mode should let me chose (interactively) what language server to use when there are several options.

Right now it seems it just defaults to the last one defined and forgets/disregards previously defined language servers.

As a user there's literally no way to know there are other options (which can be enabled/disabled through elisp), because only one option is shown.

If that user-experience could be improved, I for one would really appreciate it.

Is this a general problem for lsp-mode as a whole or an issue specific to lsp-csharp? I don't know. Wouldn't it be interesting to find out?

I know rust has the same thing with several language servers (rls vs rust-analyser). Does the same issue manifest itself there?

I know as a maintainer one may be overburdened with work, but still, just closing the issue seems a tad dismissive to me.

@razzmatazz
Copy link
Collaborator

razzmatazz commented Nov 9, 2021

@josteink I could not replicate your problem though..

(doom emacs + some stock version of emacs-lsp/lsp-mode)

Bildschirmfoto vom 2021-11-09 19-06-44

I get omnisharp (as second selection item) and then, when I type "ENTER" it installs and runs properly for me..

LSP :: Download omnisharp started.                                                                                     
LSP :: Starting to download https://github.com/omnisharp/omnisharp-roslyn/releases/latest/download/omnisharp-linux-x64$
Contacting host: github.com:443                                                                                        
Wrote /home/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip                                   
LSP :: Finished downloading /home/bob/.emacs.d/.local/etc/lsp/omnisharp-roslyn/latest/omnisharp-roslyn.zip...          
(Shell command succeeded with no output)                                                                               
LSP :: Server omnisharp downloaded, auto-starting in 1 buffers.                                                        
LSP :: Guessed project root is ~/src/csharp/csharp-test                                                                
LSP :: Connected to [omnisharp:1580164/starting].                                                                      
LSP :: omnisharp:1580164 initialized successfully in folders: (/home/bob/src/csharp/csharp-test)                       

you said something about "shadowing" of omnisharp server version, how does it manifest on your machine?

one thing we could do is mark "csharp-ls" as "experimental" on the server selection list, as it is not of that high quality as omnisharp-roslyn (even if it has other features that omnisharp lacks)

maybe we should change priority of the csharp-ls ? @yyoncho now we have "csharp-ls" with :priority -2 while "omnisharp" has priority: -1. Does this mean that omnisharp has "higher priority" or not? because you can see on my screenshot "omnisharp" goes as "second" option on the list..

@josteink
Copy link
Contributor Author

josteink commented Nov 9, 2021

Thanks for the feedback so far guys.

I’ll try to get a screenshot and a minimal POC for reproducing tomorrow, so we have something (more) concrete to work with.

I mean, if I had gotten both options like you did, I wouldn’t have posted a issue here 😅

@razzmatazz
Copy link
Collaborator

razzmatazz commented Nov 9, 2021

@yyoncho I will let myself reopen this as @josteink seems to be having an issue with having omnisharp listed for some reason; also can you reply to my question regarding how :priotity value should work on this comment:

@razzmatazz razzmatazz reopened this Nov 9, 2021
@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2021

@josteink this was discussed at the beginning of the project.

  1. All lsp(vscode, theia, vim, etc) clients automatically select the language server.
  2. We have documented how to select a different server from the one with the highest priority in the FAQ section.

For sure if we ask the user to pick a server each time you open a project will bring tons of issue reports until we turn that off which again will narrow down to using lsp-enabled-clients/lsp-disabled-clients.

I know as a maintainer one may be overburdened with work, but still, just closing the issue seems a tad dismissive to me.

I thought that I have answered your question.

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2021

@razzmatazz

one thing we could do is mark "csharp-ls" as "experimental" on the server selection list, as it is not of that high quality as omnisharp-roslyn (even if it has other features that omnisharp lacks)

maybe we should change priority of the csharp-ls ? @yyoncho now we have "csharp-ls" with :priority -2 while "omnisharp" has priority: -1. Does this mean that omnisharp has "higher priority" or not? because you can see on my screenshot "omnisharp" goes as "second" option on the list..

I think that it is up to you. About the order of the servers in the list - we should do sorting by priority. I believe now the sorting is random. We may add a flag to the client :recommended which to list in that dialog.

@razzmatazz
Copy link
Collaborator

@razzmatazz

one thing we could do is mark "csharp-ls" as "experimental" on the server selection list, as it is not of that high quality as omnisharp-roslyn (even if it has other features that omnisharp lacks)
maybe we should change priority of the csharp-ls ? @yyoncho now we have "csharp-ls" with :priority -2 while "omnisharp" has priority: -1. Does this mean that omnisharp has "higher priority" or not? because you can see on my screenshot "omnisharp" goes as "second" option on the list..

I think that it is up to you. About the order of the servers in the list - we should do sorting by priority. I believe now the sorting is random. We may add a flag to the client :recommended which to list in that dialog.

so :priority does not mean anything now, right?

@razzmatazz
Copy link
Collaborator

razzmatazz commented Nov 9, 2021

@josteink now I am wondering, is your problem that you:
(a) are not able to select a server when you have one/more of them installed, or
(b) are not able to select a server to install when you have none installed?

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2021

@razzmatazz
Copy link
Collaborator

btw, @josteink I have just released csharp-ls 0.1.6 that has support for net6.0 projects too (among other improvements)

@josteink
Copy link
Contributor Author

josteink commented Nov 9, 2021

No idea why, but seeing as:

  1. csharp-ls now works with .net 6.0, and
  2. I can no longer reproduce the issue (that is lsp-mode now suggests both language-servers when none installed)...

I really think it's fully OK to close this issue.

Not sure what happened here or why, but sorry for wasting your time. I'll try to make sure it doesn't happen again 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants