Open leftbones opened 5 months ago
Hi, this is usually a formatting style setting for lsp, which should normally be achieved by configuring lsp to
Right - Zed isn't the thing making the changes in this case - which language server are you using?
Right - Zed isn't the thing making the changes in this case - which language server are you using?
Ah! Sorry, I wasn't really sure, I need to study more about how language servers work in an application like Zed.
It looks like the C# extension in Zed uses OmniSharp, hopefully there's a way to customize this behavior! I know it has to be possible, because I've also used OmniSharp in Visual Studio Code and didn't have this problem.
To configure omnisharp, you can use an omnisharp.json file. More information here: https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options
The location of the file is the following:
%USERPROFILE%\.omnisharp\omnisharp.json
~/.omnisharp/omnisharp.json
Within the file you can enable .editorconfig
support.
{
"FormattingOptions": {
"EnableEditorConfigSupport": true
}
}
You might be interested in enabling the roslyn analyzers. That way zed shows warnings and code actions for omnisharp.
{
"RoslynExtensionsOptions": {
"enableAnalyzersSupport": true
}
}
Zed's inlay hints can be enabled for omnisharp in the same json file with the inlayHintsOptions
section, within the roslyn extension options.
{
"RoslynExtensionsOptions": {
"inlayHintsOptions": {
"enableForParameters": true,
"forLiteralParameters": true,
"forIndexerParameters": true,
"forObjectCreationParameters": true,
"forOtherParameters": true,
"suppressForParametersThatDifferOnlyBySuffix": false,
"suppressForParametersThatMatchMethodIntent": false,
"suppressForParametersThatMatchArgumentName": false,
"enableForTypes": true,
"forImplicitVariableTypes": true,
"forLambdaParameterTypes": true,
"forImplicitObjectCreation": true
}
}
}
The complete file can look like this:
{
"FormattingOptions": {
"EnableEditorConfigSupport": true
},
"RoslynExtensionsOptions": {
"enableDecompilationSupport": true,
"enableImportCompletion": true,
"enableAnalyzersSupport": true,
"inlayHintsOptions": {
"enableForParameters": true,
"forLiteralParameters": true,
"forIndexerParameters": true,
"forObjectCreationParameters": true,
"forOtherParameters": true,
"suppressForParametersThatDifferOnlyBySuffix": false,
"suppressForParametersThatMatchMethodIntent": false,
"suppressForParametersThatMatchArgumentName": false,
"enableForTypes": true,
"forImplicitVariableTypes": true,
"forLambdaParameterTypes": true,
"forImplicitObjectCreation": true
}
}
}
Notes:
Once you have enabled .editorconfig
support, create or edit an .editorconfig
file in your project, and set formatting and analyzer options in there.
For example, to keep the braces in the same line for C# files:
[*.cs]
csharp_new_line_before_open_brace = none
This is the result:
Cheers.
Check for existing issues
Describe the feature
I've noticed if you are putting something in brackets and you delete the closing bracket that Zed put there for you, then add one yourself, the open bracket is automatically moved one line down. Everyone has their own preferences, mine is to have all of the open brackets on the same line as the stuff before them, rather than the next line, a setting for this would be nice!
If applicable, add mockups / screenshots to help present your vision of the feature
https://github.com/zed-industries/zed/assets/77086654/4ce0aa60-614c-4331-bd94-2cf9930968b6