helix: C-Sharp LSP not starting when opening .cs files

Summary

I have installed omnisharp and checked with hx --health c-sharp to make sure it is ok.

But when I open a .cs file in a c-sharp project the LSP doesn’t start.

Do I have to open a special file or in a special directory for it to work?

Reproduction Steps

I built from the source and checked with hx --health c-sharp and it showed that the LSP was found.

I also fetched the grammar and built them.

Then I opened a .cs file in a project but nothing worked and trying code actions told me that no LSP was running for the current buffer.

Helix log

2022-05-31T00:41:23.562 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:23.875 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:23.875 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.174 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.174 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.485 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.485 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.975 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:24.975 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.287 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.287 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.671 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.671 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.953 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:41:25.953 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2022-05-31T00:44:26.843 helix_view::theme [WARN] Theme: malformed hexcode: fg
2022-05-31T00:44:26.843 helix_view::theme [WARN] Theme: malformed hexcode: form

Platform

Windows

Terminal Emulator

Windows Terminal Version: 1.12.10983.0

Helix Version

helix 22.05 (370a16d0)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 17 (9 by maintainers)

Most upvoted comments

I was experiencing a similar issue, my logs contained a timeout which I believe to be the root problem. helix_lsp [ERROR] failed to initialize language server: request 0 timed out

From what I can tell, the default timeout (20 seconds) was too short for my project. I adjusted languages.toml to the following:

[[language]]
name = "c-sharp"
scope = "source.cs"
injection-regex = "c-?sharp"
roots = ["sln", "csproj"]
file-types = ["cs"]
comment-token = "//"
indent = { tab-width = 4, unit = "    " }
language-server = { command = "omnisharp", args = ["-lsp"], timeout=10000 }

Specifically, this line: language-server = { command = "omnisharp", args = ["-lsp"], timeout=10000 }

Hope this helps someone else.

The o#/ messages aren’t part of the LSP spec AFAIK, I assume those are specific to the C# language server. That shouldn’t be a problem since we’re discarding them, unless the language server is expecting responses to those messages. Maybe that behavior can be turned off by some configuration? https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options

@MAST1999 Would you mind attach your omnisharp.json file. (I’m not able to get rid off 2023-01-12T11:51:14.107 helix_lsp [ERROR] failed to initialize language server: request timed out from helix.log)

UPDATE

Ok, nevermind. it was my PATH Env Variable that was getting too long… Now i can elaborate further

No that looks good. archseer is taking a look at this in #2430