Closed blldw closed 1 year ago
A while ago I was working with OmniSharp and eglot and I found that one reliable way to get this server is to install VsCode (ugh :vomiting_face: ) and use this incantation when Eglot prompts you:
dotnet $HOME/.vscode/extensions/ms-dotnettools.csharp-1.25.0-linux-x64/.omnisharp/1.39.0-net6.0/OmniSharp.dll -lsp
I've since uninstalled VsCode, so I can't test with a recent version. Probably replace $HOME with your home dir.
Hope this helps.
I am not sure if the problem is caused by the OS environment, by Emacs or eglot, and thanks for any tips.
I'm pretty sure it's not Eglot, but the incantation and the versino of the Omnisharp server. Using the version hidden away in VsCode seems like a good idea.
I installed VsCode and C# extension with OmniSharp support, and the incantation doesn't work either, I found:
(1) OmniSharp shipped with C# extension is just the one I used, I compared their hash value with md5sum
and got the same result: e7d914ed518c01c3eb6c4007b08633e0.
(2) OmniSharp worked in VsCode very well.
So, does VsCode load OmniSharp in some other way?
I found I I still have a omnisharp-roslyn
program lying around. It seems to work fine. The problem is likely with your configuration.
Here I am trying this out in a simple project. I'm using the latest Eglot and Emacs but it'll probably work with Emacs 28 and an older Eglot. Just make sure you start with with no fancy configuration, and then re-add some of this configuration once you have it working.
Also the reason I'm passing -f package-initialize
to the Emacs incantation is to activate local ELPA packages. Needed packages here are csharp-mode
and markdown-mode
(the last one is more like optional)
So, does VsCode load OmniSharp in some other way?
I had this question and I answered it with ps -fax
Yes, I followed your way and it works now, thanks for your answering.
@blldw I've had much better experience working in C# using this language server https://github.com/razzmatazz/csharp-language-server. It's much faster and haven't experienced any issues with it since I started using it, where with Omnisharp I had issues daily.
It can be installed with running dotnet tool install --global csharp-ls
.
Here is the emacs-lisp. :)
(add-to-list 'eglot-server-programs
'(csharp-mode . ("csharp-ls")))
For the working problem of eglot package with OmniSharp server, I followed the following threads, and neither could solve my problem: https://github.com/joaotavora/eglot/issues/573 https://github.com/joaotavora/eglot/issues/241
My OS is Ubuntu 20.04 and Emacs version is 29.0.50.
Following these steps for a Minimum Reproducible Example: (1) Install dotnet-sdk-6.0:
sudo apt install dotnet-sdk-6.0
. (2) Download latest OmniSharp version from this link:https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.39.1/omnisharp-linux-x64-net6.0.zip and extract it to
/opt/omnisharp-roslyn
, then add this path to PATH environment variable. (3) Create a C# project:(4) Start Emacs with an empty
~/.emacs.d
directory. (5) run these commands:(6) Rerun Emacs and open
~/tmp/Hello/Program.cs
, then typeM-x eglot
, Emacs will prompt in the minibuffer,and type
OmniSharp -stdio -lsp
, now the problem occurs.In the Messages buffer, notable text was:
While in the eglot events buffer, text was:
However, if I just run
OmniSharp -lsp
(without-stdio
option), the eglot event buffer output more text compared withOmniSharp -stdio -lsp
:If I run
OmniSharp -stdio -lsp
from the~/tmp/Hello
directory, the server seems to work fine.I am not sure if the problem is caused by the OS environment, by Emacs or eglot, and thanks for any tips.