Skip to content

Add code formatting presets #893

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

Merged
merged 4 commits into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@
"default": false,
"description": "Launches the language service with the /waitForDebugger flag to force it to wait for a .NET debugger to attach before proceeding."
},
"powershell.codeFormatting.preset": {
"type":"string",
"enum": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, I was looking for how to do the enum values and couldn't find it!

"Custom",
"OTBS",
"Allman"
],
"default": "Custom",
"description": "Sets the codeformatting options to follow the given indent style in a way that is compatible with PowerShell syntax. For more information about the brace styles please refer to https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81."
},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we point to this or create some documentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use this link for now until we get our own documentation together.

"powershell.codeFormatting.openBraceOnSameLine": {
"type": "boolean",
"default": true,
Expand Down
8 changes: 8 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
import vscode = require('vscode');
import utils = require('./utils');

enum CodeFormattingPreset {
Custom,
OTBS,
Allman
}

export interface ICodeFormattingSettings {
preset: CodeFormattingPreset;
openBraceOnSameLine: boolean;
newLineAfterOpenBrace: boolean;
newLineAfterCloseBrace: boolean;
Expand Down Expand Up @@ -69,6 +76,7 @@ export function load(): ISettings {
};

let defaultCodeFormattingSettings: ICodeFormattingSettings = {
preset: CodeFormattingPreset.Custom,
openBraceOnSameLine: true,
newLineAfterOpenBrace: true,
newLineAfterCloseBrace: true,
Expand Down