Skip to content

Commit 4628a74

Browse files
Merge pull request #1055 from filipw/feature/834
Pass editor tab/indentation settings to OmniSharp
2 parents fe153eb + 48d27c8 commit 4628a74

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@
365365
"type": "number",
366366
"default": 250,
367367
"description": "The maximum number of projects to be shown in the 'Select Project' dropdown (maximum 250)."
368+
},
369+
"omnisharp.useEditorFormattingSettings": {
370+
"type": "boolean",
371+
"default": true,
372+
"description": "Specifes whether OmniSharp should use VS Code editor settings for C# code formatting (use of tabs, indentation size)."
368373
}
369374
}
370375
},

src/omnisharp/launcher.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ function launch(cwd: string, args: string[]): Promise<LaunchResult> {
161161
return PlatformInformation.GetCurrent().then(platformInfo => {
162162
const options = Options.Read();
163163

164+
if (options.useEditorFormattingSettings)
165+
{
166+
let editorConfig = vscode.workspace.getConfiguration('editor');
167+
args.push(`formattingOptions:useTabs=${!editorConfig.get('insertSpaces', true)}`);
168+
args.push(`formattingOptions:tabSize=${editorConfig.get('tabSize', 4)}`);
169+
args.push(`formattingOptions:indentationSize=${editorConfig.get('tabSize',4)}`);
170+
}
171+
164172
if (options.path && options.useMono) {
165173
return launchNixMono(options.path, cwd, args);
166174
}

src/omnisharp/options.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class Options {
1212
public loggingLevel?: string,
1313
public autoStart?: boolean,
1414
public projectLoadTimeout?: number,
15-
public maxProjectResults?: number) { }
15+
public maxProjectResults?: number,
16+
public useEditorFormattingSettings?: boolean) { }
1617

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

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

41-
return new Options(path, useMono, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults);
43+
return new Options(path, useMono, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings);
4244
}
4345
}

0 commit comments

Comments
 (0)