zed/docs/src/languages/csharp.md
Vlad Ionescu 70bb09eeaa
docs: Add csharp-ls to C# docs (#59028)
I was chatting with somebody today and they told me Zed is terrible
because it [only supports OmniSharp for C# as per the marketing
site](https://zed.dev/languages/csharp) which I knew 100% to be false.
While looking to do a quick fix for that, I realized the Zed marketing
website code is not part of this repo (as [confirmed by a quick
search](https://github.com/search?q=repo%3Azed-industries%2Fzed+LINQ+expressions&type=code))
but that [Zed C# docs](https://zed.dev/docs/languages/csharp) are part
of the repo and they too don't include the changes from
https://github.com/zed-extensions/csharp/pull/77. Here's a quick update
for that!

I did test that `csharp-ls` actually receives the [extra
settings](https://github.com/razzmatazz/csharp-language-server#configuration)
by setting `"razorSupport": true` and confirming that with the LSP logs.

**Note**: I'd wait for https://github.com/zed-extensions/csharp/pull/89
to be merged before merging this PR.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
2026-06-10 14:18:05 +00:00

5.3 KiB

title description
C# Configure C# language support in Zed, including language servers, formatting, and debugging.

C#

C# support is available through the C# extension.

Roslyn is enabled by default. To switch to csharp-ls or OmniSharp, add the following to your Zed settings file:

{
  "languages": {
    "CSharp": {
      "language_servers": ["csharp-ls", "!roslyn", "!omnisharp", "..."]
    }
  }
}

Note: the language name used in settings is "CSharp", not "C#".

Configuration

Roslyn can be configured with the following language server settings:

{
  "lsp": {
    "roslyn": {
      "settings": {
        // Default values are shown below, along with alternative options where applicable.
        "csharp|symbol_search": {
          "dotnet_search_reference_assemblies": true
        },
        "csharp|type_members": {
          "dotnet_member_insertion_location": "atTheEnd", // or "withOtherMembersOfTheSameKind"
          "dotnet_property_generation_behavior": "preferThrowingProperties" // or "preferAutoProperties"
        },
        "csharp|completion": {
          "dotnet_show_name_completion_suggestions": true,
          "dotnet_provide_regex_completions": true,
          "dotnet_show_completion_items_from_unimported_namespaces": true,
          "dotnet_trigger_completion_in_argument_lists": true
        },
        "csharp|quick_info": {
          "dotnet_show_remarks_in_quick_info": true
        },
        "csharp|navigation": {
          "dotnet_navigate_to_decompiled_sources": true,
          "dotnet_navigate_to_source_link_and_embedded_sources": true
        },
        "csharp|highlighting": {
          "dotnet_highlight_related_json_components": true,
          "dotnet_highlight_related_regex_components": true
        },
        "csharp|inlay_hints": {
          "dotnet_enable_inlay_hints_for_parameters": true,
          "dotnet_enable_inlay_hints_for_literal_parameters": true,
          "dotnet_enable_inlay_hints_for_indexer_parameters": true,
          "dotnet_enable_inlay_hints_for_object_creation_parameters": true,
          "dotnet_enable_inlay_hints_for_other_parameters": true,
          "dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix": true,
          "dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent": true,
          "dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name": true,
          "csharp_enable_inlay_hints_for_types": true,
          "csharp_enable_inlay_hints_for_implicit_variable_types": true,
          "csharp_enable_inlay_hints_for_lambda_parameter_types": true,
          "csharp_enable_inlay_hints_for_implicit_object_creation": true,
          "csharp_enable_inlay_hints_for_collection_expressions": true
        },
        "csharp|code_style.formatting.indentation_and_spacing": {
          "tab_width": 4,
          "indent_size": 4,
          "indent_style": "space" // or "tab"
        },
        "csharp|code_style.formatting.new_line": {
          "end_of_line": "...", // platform-specific default
          "insert_final_newline": false
        },
        "csharp|background_analysis": {
          "dotnet_analyzer_diagnostics_scope": "default", // or "none" "openFiles" "fullSolution"
          "dotnet_compiler_diagnostics_scope": "openFiles" // or "fullSolution"
        },
        "csharp|code_lens": {
          "dotnet_enable_references_code_lens": false,
          "dotnet_enable_tests_code_lens": false
        },
        "csharp|auto_insert": {
          "dotnet_enable_auto_insert": true
        },
        "csharp|projects": {
          "dotnet_binary_log_path": null,
          "dotnet_enable_automatic_restore": true,
          "dotnet_enable_file_based_programs": true,
          "dotnet_enable_file_based_programs_when_ambiguous": true
        },
        "csharp|formatting": {
          "dotnet_organize_imports_on_format": false
        }
      },
      "binary": {
        "path": "/path/to/roslyn-language-server",
        "arguments": ["--stdio", "--autoLoadProjects" /* add extra arguments */]
      }
    }
  }
}

csharp-ls can be configured in a Zed settings file with:

{
  "lsp": {
    "csharp-ls": {
      "binary": {
        "path": "/path/to/csharp-ls",
        "arguments": [
          /* add extra arguments */
        ]
      },
      "settings": {
        // Default values are shown below.
        "logLevel": "information",
        "applyFormattingOptions": false,
        "analyzersEnabled": false,
        "useMetadataUris": true,
        "razorSupport": false,
        "solutionPathOverride": null,
        "locale": null,
        "debug": {
          "debugMode": false,
          "solutionLoadDelay": null
        }
      }
    }
  }
}

OmniSharp can be configured in a Zed settings file with:

{
  "lsp": {
    "omnisharp": {
      "binary": {
        "path": "/path/to/OmniSharp",
        "arguments": ["-lsp" /* add extra arguments */]
      }
    }
  }
}