1---
2title: C#
3description: "Configure C# language support in Zed, including language servers, formatting, and debugging."
4---
5
6# C#
7
8C# support is available through the [C# extension](https://github.com/zed-extensions/csharp).
9
10- Tree-sitter: [tree-sitter/tree-sitter-c-sharp](https://github.com/tree-sitter/tree-sitter-c-sharp)
11- Language Servers:
12 - [roslyn-language-server](https://www.nuget.org/packages/roslyn-language-server#readme)
13 - [OmniSharp/omnisharp-roslyn](https://github.com/OmniSharp/omnisharp-roslyn)
14
15Roslyn is enabled by default. To switch back to OmniSharp, add the following to your Zed settings file:
16
17```json [settings]
18{
19 "languages": {
20 "CSharp": {
21 "language_servers": ["omnisharp", "!roslyn", "..."]
22 }
23 }
24}
25```
26
27Note: the language name used in settings is "CSharp", not "C#".
28
29## Configuration
30
31Roslyn can be configured with the following language server settings:
32
33```json [settings]
34{
35 "lsp": {
36 "roslyn": {
37 "settings": {
38 // Default values are shown below, along with alternative options where applicable.
39 "csharp|symbol_search": {
40 "dotnet_search_reference_assemblies": true
41 },
42 "csharp|type_members": {
43 "dotnet_member_insertion_location": "atTheEnd", // or "withOtherMembersOfTheSameKind"
44 "dotnet_property_generation_behavior": "preferThrowingProperties" // or "preferAutoProperties"
45 },
46 "csharp|completion": {
47 "dotnet_show_name_completion_suggestions": true,
48 "dotnet_provide_regex_completions": true,
49 "dotnet_show_completion_items_from_unimported_namespaces": true,
50 "dotnet_trigger_completion_in_argument_lists": true
51 },
52 "csharp|quick_info": {
53 "dotnet_show_remarks_in_quick_info": true
54 },
55 "csharp|navigation": {
56 "dotnet_navigate_to_decompiled_sources": true,
57 "dotnet_navigate_to_source_link_and_embedded_sources": true
58 },
59 "csharp|highlighting": {
60 "dotnet_highlight_related_json_components": true,
61 "dotnet_highlight_related_regex_components": true
62 },
63 "csharp|inlay_hints": {
64 "dotnet_enable_inlay_hints_for_parameters": true,
65 "dotnet_enable_inlay_hints_for_literal_parameters": true,
66 "dotnet_enable_inlay_hints_for_indexer_parameters": true,
67 "dotnet_enable_inlay_hints_for_object_creation_parameters": true,
68 "dotnet_enable_inlay_hints_for_other_parameters": true,
69 "dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix": true,
70 "dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent": true,
71 "dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name": true,
72 "csharp_enable_inlay_hints_for_types": true,
73 "csharp_enable_inlay_hints_for_implicit_variable_types": true,
74 "csharp_enable_inlay_hints_for_lambda_parameter_types": true,
75 "csharp_enable_inlay_hints_for_implicit_object_creation": true,
76 "csharp_enable_inlay_hints_for_collection_expressions": true
77 },
78 "csharp|code_style.formatting.indentation_and_spacing": {
79 "tab_width": 4,
80 "indent_size": 4,
81 "indent_style": "space" // or "tab"
82 },
83 "csharp|code_style.formatting.new_line": {
84 "end_of_line": "...", // platform-specific default
85 "insert_final_newline": false
86 },
87 "csharp|background_analysis": {
88 "dotnet_analyzer_diagnostics_scope": "default", // or "none" "openFiles" "fullSolution"
89 "dotnet_compiler_diagnostics_scope": "openFiles" // or "fullSolution"
90 },
91 "csharp|code_lens": {
92 "dotnet_enable_references_code_lens": false,
93 "dotnet_enable_tests_code_lens": false
94 },
95 "csharp|auto_insert": {
96 "dotnet_enable_auto_insert": true
97 },
98 "csharp|projects": {
99 "dotnet_binary_log_path": null,
100 "dotnet_enable_automatic_restore": true,
101 "dotnet_enable_file_based_programs": true,
102 "dotnet_enable_file_based_programs_when_ambiguous": true
103 },
104 "csharp|formatting": {
105 "dotnet_organize_imports_on_format": false
106 }
107 },
108 "binary": {
109 "path": "/path/to/roslyn-language-server",
110 "arguments": ["--stdio", "--autoLoadProjects" /* add extra arguments */]
111 }
112 }
113 }
114}
115```
116
117OmniSharp can be configured in a Zed settings file with:
118
119```json [settings]
120{
121 "lsp": {
122 "omnisharp": {
123 "binary": {
124 "path": "/path/to/OmniSharp",
125 "arguments": ["-lsp" /* add extra arguments */]
126 }
127 }
128 }
129}
130```