C#
C# 支持通过 C# 扩展 提供。
- Tree-sitter: tree-sitter/tree-sitter-c-sharp
- 语言服务器:
默认启用 Roslyn。若要切换回 OmniSharp,请将以下内容添加到您的 Zed 设置文件中:
json
{
"languages": {
"CSharp": {
"language_servers": ["omnisharp", "!roslyn", "..."]
}
}
}注意:设置中使用的语言名称是 "CSharp",而不是 "C#"。
配置
可以使用以下语言服务器设置配置 Roslyn:
json
{
"lsp": {
"roslyn": {
"settings": {
// 以下显示默认值,并在适用时提供备选选项。
"csharp|symbol_search": {
"dotnet_search_reference_assemblies": true
},
"csharp|type_members": {
"dotnet_member_insertion_location": "atTheEnd", // 或 "withOtherMembersOfTheSameKind"
"dotnet_property_generation_behavior": "preferThrowingProperties" // 或 "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" // 或 "tab"
},
"csharp|code_style.formatting.new_line": {
"end_of_line": "...", // 平台特定默认值
"insert_final_newline": false
},
"csharp|background_analysis": {
"dotnet_analyzer_diagnostics_scope": "default", // 或 "none" "openFiles" "fullSolution"
"dotnet_compiler_diagnostics_scope": "openFiles" // 或 "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" /* 添加额外参数 */]
}
}
}
}可以在 Zed 设置文件中配置 OmniSharp:
json
{
"lsp": {
"omnisharp": {
"binary": {
"path": "/path/to/OmniSharp",
"arguments": ["-lsp" /* 添加额外参数 */]
}
}
}
}