Skip to content
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

Pass editor tab/indentation settings to OmniSharp #1055

Merged
merged 4 commits into from
Dec 19, 2016
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@
"type": "number",
"default": 250,
"description": "The maximum number of projects to be shown in the 'Select Project' dropdown (maximum 250)."
},
"omnisharp.useEditorFormattingSettings": {
"type": "boolean",
"default": true,
"description": "Specifes whether OmniSharp should use VS Code editor settings for C# code formatting (use of tabs, indentation size)."
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions src/omnisharp/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ function launch(cwd: string, args: string[]): Promise<LaunchResult> {
return PlatformInformation.GetCurrent().then(platformInfo => {
const options = Options.Read();

if (options.useEditorFormattingSettings)
{
let editorConfig = vscode.workspace.getConfiguration('editor');
args.push(`formattingOptions:useTabs=${!editorConfig.get('insertSpaces', true)}`);
args.push(`formattingOptions:tabSize=${editorConfig.get('tabSize', 4)}`);
args.push(`formattingOptions:indentationSize=${editorConfig.get('tabSize',4)}`);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can't these just be passed as additional arguments? I though OmniSharp's configuration builder would pick these up from the command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes they can - in fact I believe restore packages is passed like that already if I recall correctly. I can change that for consistency, there is no real reason to use environment variables indeed

Copy link
Member

Choose a reason for hiding this comment

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

That's what I thought -- thanks! Yeah, go ahead and pass them as args for consistency. I have no idea what the logic is for options overriding in the configuration middleware that OmniSharp uses. E.g. do command line args override environment variable or vice versa? I just ran into something similar with MSBuild, so it was on my mind. Hence, the question. 😄


if (options.path && options.useMono) {
return launchNixMono(options.path, cwd, args);
}
Expand Down
6 changes: 4 additions & 2 deletions src/omnisharp/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export class Options {
public loggingLevel?: string,
public autoStart?: boolean,
public projectLoadTimeout?: number,
public maxProjectResults?: number) { }
public maxProjectResults?: number,
public useEditorFormattingSettings?: boolean) { }

public static Read(): Options {
// Extra effort is taken below to ensure that legacy versions of options
Expand All @@ -37,7 +38,8 @@ export class Options {

const projectLoadTimeout = omnisharpConfig.get<number>('projectLoadTimeout', 60);
const maxProjectResults = omnisharpConfig.get<number>('maxProjectResults', 250);
const useEditorFormattingSettings = omnisharpConfig.get<boolean>('useEditorFormattingSettings', true);

return new Options(path, useMono, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults);
return new Options(path, useMono, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings);
}
}