Skip to content

Configuration Options

Alex Forbes-Reed edited this page Dec 20, 2016 · 34 revisions

OmniSharp exposes a set of configuration options that can be used to modify the behavior of the OmniSharp regarding:

  • how it treats dotnet CLI projects
  • code formatting options

The configuration is stored in the config.json file and deployed together with OmniSharp.

{
    "dotnet": {
        "alias": "default",
        "projects": "**/project.json",
        "enablePackageRestore": true,
        "packageRestoreTimeout": "180"
    },
    "formattingOptions": {
        "newLine": "\n",
        "useTabs": false,
        "tabSize": 4,
        "indentationSize": 4
    }
}

At startup, OmniSharp obtains the configuration options using the following order:

  • the built-in config.json
  • environment variables
  • command line arguments
  • omnisharp.json file located in the working directory which OmniSharp has been pointed at

Each of the configuration sources, can overwrite any of the settings set by the previous source.

Environment variables

Environment variables should be passed into the OmniSharp process as flattened JSON paths. Instead of ., : should be used as a delimiter.

Example

To override the default formattingOptions > tabSize setting of config.json (4) with 2, you should set environment variable formattingOptions:tabSize with the value 2.

Command line arguments

Command line arguments are parsed by OmniSharp after environment variables. Their format is the same as environment variables - flattened JSON paths, with : as a delimiter. Additionally, the do not require any prefix - neither -, nor --.

Example

To override the default formattingOptions > tabSize setting of config.json (4), or anything set by environment variables, with 2, you should launch OmniSharp with the following command:

OmniSharp.exe -s {folder path} {other arguments} formattingOptions:tabSize=2

omnisharp.json

The highest order of precedence is given to omnisharp.json located in the folder which OmniSharp server is looking at. This doesn't need to be a full copy of config.json - it can contain only individual settings, and they will be merged into the settings provided by config.json, environment variables and command line args, and simply overwrite the matching ones.

Example

To override the default formattingOptions > tabSize setting of config.json (4), or anything set by environment variables/command line args with 2, you should create the following omnisharp.json file in the folder of your project:

{
    "formattingOptions": {
        "tabSize": 2
    }
}