2015-12-22 130 views
4

我試圖利用與Visual Studio代碼的集成,但無法弄清楚如何設置C#格式選項。我Mac上的OmniSharp exe文件旁邊的config.json(/ Applications/Visual Studio Code.app/Contents/Resources/app/extensions/jrieken.vscode-omnisharp/bin/packages/OmniSharp/config.json)沒有匹配the standard OmniSharp config.json format,因此設置大括號+換行符屬性不起作用,例如methodBraceStyle。它確實可以設置tabSize等。在Visual Studio代碼上爲OmniSharp設置C#格式選項?

+0

你有沒有解決這個問題,我已經花了半天只是試圖讓我的C#括號正確設置 – Jaybeecave

+0

不,我從來沒有。 – csells

回答

6

剛剛得到這個工作使用最新的omnisharp(dev分支)和omnisharp.json(粘貼在下面)在我的項目的.sln相同的文件夾中。 自從v1.9-beta18開始,它應該可以與所有releases一起工作,我只是從源代碼編譯,因爲我不使用受支持的系統。

{ 
    "FormattingOptions": { 
     "newLine": "\n", 
     "useTabs": false, 
     "tabSize": 4, 
     "indentationSize": 4, 

     "NewLinesForBracesInTypes": false, 
     "NewLinesForBracesInMethods": false, 
     "NewLinesForBracesInProperties": false, 
     "NewLinesForBracesInAccessors": false, 
     "NewLinesForBracesInAnonymousMethods": false, 
     "NewLinesForBracesInControlBlocks": false, 
     "NewLinesForBracesInAnonymousTypes": false, 
     "NewLinesForBracesInObjectCollectionArrayInitializers": false, 
     "NewLinesForBracesInLambdaExpressionBody": false, 

     "NewLineForElse": false, 
     "NewLineForCatch": false, 
     "NewLineForFinally": false, 
     "NewLineForMembersInObjectInit": false, 
     "NewLineForMembersInAnonymousTypes": false, 
     "NewLineForClausesInQuery": false, 
    } 
} 

可用的選項都列在該文件:https://github.com/bstockus/omnisharp-roslyn/blob/dev/src/OmniSharp.Abstractions/Options/FormattingOptions.cs

相關問題