OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.72k stars 417 forks source link

VSCode Omnisharp tab formatting issue #2575

Open tilkinsc opened 8 months ago

tilkinsc commented 8 months ago

So I enabled omnisharp (after having it disabled because I am heckin vanilla). I am not using the C# dev kit extension (idk who its targeted for, me?).

I got greeted by my code looking like this, image

I was like what the heck, so in looking for a reason it apparently hates me using tabs. So I am like no big deal tab issues theres options for that™️. I went over to omnisharp.json in my %userprofile%/.omnisharp and set some settings

    "FormattingOptions": {
        "EnableEditorConfigSupport": false,
        "OrganizeImports": true,
        "NewLine": "\n",
        "UseTabs": true,
        "TabSize": 4,
        "IndentationSize": 4,

However, I am not able to make anything happen. I can enable/disable inlay hints. Yet it ignores my use of tabs entirely. I've attempted to disable editor config support, enable it, in both places. Its actually pretty ambiguous what that means. When I use the lightbulb to do the suggested fix, it actually doesn't do anything. On some lines, it deletes the trailing space on the line before a field. Weird. I hate having "tab pits" in my code where the editor doesn't jack it up to the proper tab level for me when I hit tab or even virtualize it out for me like intellij.

One final thing, image

I refuse to use block scoped namespaces.

I like some of the features omnisharp has to offer but this is unusable. Solutions?

omnisharp.json

JoeRobich commented 8 months ago

I recommend using an .editorconfig file for storing your formatting settings along with the editorconfig vs code extension. The Roslyn formatter, which is used by O#, will respect your .editorconfig. Do note that the Roslyn formatter trims trailing whitespace which may be what you are calling "tab pits". The C# extension has a long running tracking issue waiting for virtual space to be implemented in vscode (see https://github.com/dotnet/vscode-csharp/issues/1980).

tilkinsc commented 8 months ago

Yeah I stumbled upon the editorconfig which works very well. I know virtual space is a solution to the tab pits problem, but there is also the solution of "dont touch my freakin whitespace in the first place".

JoeRobich commented 8 months ago

Yeah I stumbled upon the editorconfig which works very well. I know virtual space is a solution to the tab pits problem, but there is also the solution of "dont touch my freakin whitespace in the first place".

As we use the Roslyn formatter, this would be a good issue to comment on https://github.com/dotnet/roslyn/issues/41666