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

Improve formatting options experience #366

Closed
jrieken opened this issue Dec 15, 2015 · 11 comments
Closed

Improve formatting options experience #366

jrieken opened this issue Dec 15, 2015 · 11 comments

Comments

@jrieken
Copy link
Contributor

jrieken commented Dec 15, 2015

From @anfomin on December 14, 2015 17:34

I've configured VS Code to always use tabs:

// Place your settings in this file to overwrite the default settings
{
    "editor.insertSpaces": false
}

But C# Format Code command (Shift+Alt+F) always replaces tabs with spaces. I'm using OS X El Capitan.

Copied from original issue: microsoft/vscode#1300

@jrieken jrieken self-assigned this Dec 15, 2015
@jrieken
Copy link
Contributor Author

jrieken commented Dec 15, 2015

This is because OmniSharp doesn't support per request formatting options (https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Abstractions/Models/v1/FormatRangeRequest.cs#L6). Moving to OmniSharp for that.

@jrieken
Copy link
Contributor Author

jrieken commented Dec 15, 2015

@anfomin - to workaround this, you can create an omnisharp.json with the config

@anfomin
Copy link

anfomin commented Jun 18, 2016

@jrieken I tried to create omnisharp.json in my project room directory with content:

{
    "TextEditorOptions": {
        "tabsToSpaces": false
    }
}

But Format Code command still uses spaces.

@anfomin
Copy link

anfomin commented Jun 18, 2016

I have found file I needed:

{
    "FormattingOptions": {
        "useTabs": true
    }
}

Now it's OK.

@0xdeafcafe
Copy link

0xdeafcafe commented Dec 19, 2016

The method posted above doesn't seem to work anymore.

@filipw
Copy link
Member

filipw commented Dec 19, 2016

here is a new wiki article I just posted today, hopefully this helps
https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration%20Options

When the new C# Extension for VS Code is released, the VS Code intendation/tab settings will be inherited by OmniSharp automatically.

@DustinCampbell
Copy link
Contributor

There are two things that we need to support to improve the experience.

  1. The omnisharp.json file should be reloaded when it changes so that users don't have to restart OmniSharp after changing this file.
  2. We need a new end point for specifying formatting options. This will allow hosts to pass along options that aren't stored in omnisharp.json file. (E.g. omnisharp-vscode passes the "editor.insertSpaces" and "editor.tabSize" VS Code options along as "formattingOptions:useTabs", "formattingOptions:tabSize" and "formattingOptions:indentationSize" to OmniSharp.

@DustinCampbell DustinCampbell changed the title Expose route to set formatting options Improve formatting options experience Dec 23, 2016
@filipw
Copy link
Member

filipw commented Dec 23, 2016

I can go ahead and implement this

@Thaina
Copy link

Thaina commented Dec 24, 2016

I'm not so sure that omnisharp itself was normally listening to files changed in workspace, or is it?
Or it was designed to be restarted when omnisharp.json was changed and it is extension responsible to call omnisharp restart command?

Also if there are per request formatting options supported. What would happen to omnisharp.json when there is command to change? Would it keep track of change?

What would happen if we have omnisharp.json to set tabSize to 2
Then call command to change it to 3
Then modified omnisharp.json to set tabSize to 4

Another scenario is
we have omnisharp.json to set tabSize:2 and useTabs:false
Then call command to set tabSize:3 and useTabs:true
Then modified omnisharp.json to set tabSize to 4, is the useTabs would be override?

In my opinion omnisharp.json should track all configurations values that changed from default in workspace

@kenning
Copy link

kenning commented Sep 3, 2018

Not sure exactly what's wrong here, but when I run code formatting it uses 4 space indentations. Other formatting options seem to work, like "NewLinesForBracesInTypes": true, work after I change them. (I definitely do not have separate omnisharp.json files for this project overriding this.)

Side note, the casing for omnisharp.json on the wiki file (https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration%20Options) seems to be inconsistent, too. FormattingOptions is sometimes pascal-cased and sometimes camel-cased, as is TabSize, in different areas of the file. I guess it doesn't change anything because I tried all possible combinations but none worked for me, you may want to mention that it's agnostic if it actually is.

Other than that issue, the wiki article is pretty clear, so nice job

@filipw
Copy link
Member

filipw commented Jul 28, 2020

I will close this as implemented.

  • changes in omnisharp.json are now watched in real time
  • we have editorconfig support which is also watched in real time
  • omnisharp.json options are not case-sensitive

@filipw filipw closed this as completed Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants