0

I have recently started using eglot for code completion. I was able to install Omnisharp on my system and get eglot to run for my .cs files. However eglot does not seem to be aware of any of the Godot namespace functions, classes, or types. It display an error about unknown symbols and cannot find definitions.

As a test I used Visual Studio Code and it was able to code complete Godot c# types without any Godot extensions installed.

Looking inside my project directory I see a .sln file as well as .mono directory with its assemblies directory containing several GodotSharp c# files like .dll and .xml. I am assuming that the .sln file combined with the GodotSharp.{dll,pdb,xml} files are what Visual Studio Code uses to learn about Godot c# types.

My question is: How do I configure eglot and Omnisharp to know about the Godot c# types? I see in the Omnisharp documentation it mentions pointing the Omnisharp binary to a .sln file to use c# solutions. So I tried modifying my eglot-server-programs variable to launch Omnisharp this way:

(setq eglot-server-programs (remove '(csharp-mode "omnisharp" "-lsp") eglot-server-programs))
  (add-to-list 'eglot-server-programs '(csharp-mode "omnisharp" "*.sln" "-lsp"))

I also tried variations with omnisharp -s *.sln -lsp and omnisharp myproject.sln -lsp. However with all these attempts eglot fails to connect to Omnisharp.

How might I configure eglot and Omnisharp to know about Godot c# types?

1 Answer 1

0

In my case I had to do 2 things to solve this issue. Item #2 might not be relevant but I want to post it just in case it is and others have this issue.

  1. Ensure that the OmniSharp binary is being run in your project's directory. Due to the way I had installed OmniSharp (on Linux so it was a bit custom through a package manager) the OmniSharp binary was being run with a working directory of /usr/local/bin. This meant it couldn't find my solution file because I was giving a relative path. I figured this out when I saw an error message from the OmniSharp LSP server which said it couldn't find the myproject.sln file. Once I editted my install to make OmniSharp run in my project directory I was able to get eglot working.
  2. I installed the Mono version of OmnisSharp. I'm not quite sure if this is absolutely required, but I think it makes sense because Godot uses Mono and I assume there is some formatting difference of Mono vs .NET dll files which might have caused the Godot dll files to not be read properly.

Eglot docs for godot type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.