Skip to content

Commit

Permalink
Merge pull request #1055 from filipw/feature/834
Browse files Browse the repository at this point in the history
Pass editor tab/indentation settings to OmniSharp
  • Loading branch information
DustinCampbell authored Dec 19, 2016
2 parents fe153eb + 48d27c8 commit 4628a74
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
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)}`);
}

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);
}
}

0 comments on commit 4628a74

Please sign in to comment.