-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newline formatting options #313
Comments
I agree. I have found the forced formatting annoying. Is there any plans for configuring how the formatting works? |
Agree+1 We need rights to format code as what we need, not the fixed role! |
+1 |
In the meantimes we could create This is what I use {
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": true, // You need to change this
"SpaceAfterControlFlowStatementKeyword": false,
"SpaceAfterComma": false
}
} However I would also support that omnisharp should also add vscode config contribution point |
If you're like me (and I know I am) you want the brackets on the same line for everything, not just control blocks. Here's the full listing for all of the common squirrely bracket cases.
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
} Omnisharp doesn't presently reload the It's possible that I missed a couple of NewLine settings for edge cases. The formatting options don't seem to be documented anywhere, but you can see them all in the code: http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.CSharp.Workspaces/Formatting/CSharpFormattingOptions.cs,dac739b7b8a53984 HURRAY! This was the only thing left that was still bugging me about vscode. Thanks @Thaina for the PROTIP. |
that's correct, this is planned to change though, the config file will be watched. it's tracked here OmniSharp/omnisharp-roslyn#366 (comment)
I wrote a wiki page about dealing with omnisharp config here https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration%20Options but indeed, the individual options are just picked up from Roslyn directly. |
I’ve tried this, but nothing happened, when I try to format code, it still places every braces in new line, shit….
… On 7 Jan 2017, at 21:53, Brian Bugh ***@***.***> wrote:
If you're like me (and I know I am) you want the brackets on the same line for everything, not just control blocks. Here's the full listing for all of the common squirrely bracket cases.
Put this in the base of your project as omnisharp.json
open the command palette and run Omnisharp: Restart Omnisharp.
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLineForElse": false,
"NewLineForCatch": false,
"NewLineForFinally": false
}
}
Omnisharp doesn't presently reload the omnisharp.json files automatically, so if you make changes while you're in the editor, you'll have to restart Omnisharp again.
It's possible that I missed a couple of NewLine settings for edge cases. The formatting options don't seem to be documented anywhere, but you can see them all in the code: http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.CSharp.Workspaces/Formatting/CSharpFormattingOptions.cs,dac739b7b8a53984 <http://source.roslyn.codeplex.com/#Microsoft.CodeAnalysis.CSharp.Workspaces/Formatting/CSharpFormattingOptions.cs,dac739b7b8a53984>
HURRAY! This was the only thing left that was still bugging me about vscode. Thanks @Thaina <https://github.com/Thaina> for the PROTIP.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#313 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAJExmr02gXgvz4BgsAdFt6Wn_CvNnnhks5rP5jVgaJpZM4IdMcI>.
|
@unalone Have you restart omnisharp? |
Sure, I have created a new file named “omnisharp.json”, and placed this file under my root path of project, also, I added a line in my settings.json file like this:
"omnisharp.json": “/path/to/omnisharp.json”
And then I restart the vs code and nothing happened….. what’s wrong?
… On 9 Jan 2017, at 17:04, Thaina Yu ***@***.***> wrote:
@unalone <https://github.com/unalone> Have you restart omnisharp?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#313 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAJExu4qm17-Cx2W8Oq5TNd9yAG1ppWtks5rQfgFgaJpZM4IdMcI>.
|
@unalone First, I think you should not put that line in settings.json |
First, this file is under the root path of my project.
Second, I both tried to restart the OmniSharp and VS Code, nothin happened...
… On 9 Jan 2017, at 17:09, Thaina Yu ***@***.***> wrote:
First, I think you should not put that line in settings.json
Second, you may need to restart omnisharp too in addition to restart vscode
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#313 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAJExpaKw1TvJrMWrODQaeswiLBSN3R5ks5rQflBgaJpZM4IdMcI>.
|
Ok, the reason is my C# plugin was out of date, everything goes well after update them, thank you :)
… On 9 Jan 2017, at 17:09, Thaina Yu ***@***.***> wrote:
First, I think you should not put that line in settings.json
Second, you may need to restart omnisharp too in addition to restart vscode
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#313 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAJExpaKw1TvJrMWrODQaeswiLBSN3R5ks5rQflBgaJpZM4IdMcI>.
|
one more thing, regarding documentation - you can also use @DustinCampbell I think this issue can be closed as it seems everything needed here has been explained/addressed. Omnisharp.json auto-reload is tracked in the omnisharp repo OmniSharp/omnisharp-roslyn#366 (comment) |
so, why won't the omnisharp.json file be configured globally?
…Sent from my iPhone
On 9 Jan 2017, at 22:01, Filip W ***@***.***> wrote:
one more thing, regarding documentation - you can also use omnisharp.json from schemastore.org here http://json.schemastore.org/omnisharp
@DustinCampbell I think this issue can be closed as it seems everything needed here has been explained/addressed.
Omnisharp.json auto-reload is tracked in the omnisharp repo OmniSharp/omnisharp-roslyn#366 (comment)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
it will - this is tracked in separate issue already OmniSharp/omnisharp-roslyn#717 |
Sounds good @filipw. Closing this issue. |
@filipw Have you include |
Nope. That's my fault. I've commented on the PR. |
Looking for a way to configure auto-format for newlines. I'm a fan of this structure:
However the current auto-format will place all my curly braces on a new line. I've noticed that both TypeScript and JavaScript have the options
placeOpenBraceOnNewLineForControlBlocks
andplaceOpenBraceOnNewLineForFunctions
.The text was updated successfully, but these errors were encountered: