VS Code API
    Preparing search index...

    Interface WorkspaceConfiguration

    Represents the configuration. It is a merged view of

    • Default Settings
    • Global (User) Settings
    • Workspace settings
    • Workspace Folder settings - From one of the Workspace Folders under which requested resource belongs to.
    • Language settings - Settings defined under requested language.

    The effective value (returned by get) is computed by overriding or merging the values in the following order:

    1. defaultValue (if defined in package.json otherwise derived from the value's type)
    2. globalValue (if defined)
    3. workspaceValue (if defined)
    4. workspaceFolderValue (if defined)
    5. defaultLanguageValue (if defined)
    6. globalLanguageValue (if defined)
    7. workspaceLanguageValue (if defined)
    8. workspaceFolderLanguageValue (if defined)

    Note: Only object value types are merged and all other value types are overridden.

    Example 1: Overriding

    defaultValue = 'on';
    globalValue = 'relative'
    workspaceFolderValue = 'off'
    value = 'off'

    Example 2: Language Values

    defaultValue = 'on';
    globalValue = 'relative'
    workspaceFolderValue = 'off'
    globalLanguageValue = 'on'
    value = 'on'

    Example 3: Object Values

    defaultValue = { "a": 1, "b": 2 };
    globalValue = { "b": 3, "c": 4 };
    value = { "a": 1, "b": 3, "c": 4 };

    Note: Workspace and Workspace Folder configurations contains launch and tasks settings. Their basename will be part of the section identifier. The following snippets shows how to retrieve all configurations from launch.json:

    // launch.json configuration
    const config = workspace.getConfiguration('launch', vscode.workspace.workspaceFolders[0].uri);

    // retrieve values
    const values = config.get('configurations');

    Refer to Settings for more information.

    interface WorkspaceConfiguration {
        get<T>(section: string): T | undefined;
        get<T>(section: string, defaultValue: T): T;
        has(section: string): boolean;
        inspect<T>(
            section: string,
        ):
            | {
                defaultLanguageValue?: T;
                defaultValue?: T;
                globalLanguageValue?: T;
                globalValue?: T;
                key: string;
                languageIds?: string[];
                workspaceFolderLanguageValue?: T;
                workspaceFolderValue?: T;
                workspaceLanguageValue?: T;
                workspaceValue?: T;
            }
            | undefined;
        update(
            section: string,
            value: any,
            configurationTarget?: boolean | ConfigurationTarget | null,
            overrideInLanguage?: boolean,
        ): Thenable<void>;
        readonly [key: string]: any;
    }

    Indexable

    • readonly [key: string]: any

      Readable dictionary that backs this configuration.

    Index

    Methods

    • Return a value from this configuration.

      Type Parameters

      • T

      Parameters

      • section: string

        Configuration name, supports dotted names.

      Returns T | undefined

      The value section denotes or undefined.

    • Return a value from this configuration.

      Type Parameters

      • T

      Parameters

      • section: string

        Configuration name, supports dotted names.

      • defaultValue: T

        A value should be returned when no value could be found, is undefined.

      Returns T

      The value section denotes or the default.

    • Check if this configuration has a certain value.

      Parameters

      • section: string

        Configuration name, supports dotted names.

      Returns boolean

      true if the section doesn't resolve to undefined.

    • Retrieve all information about a configuration setting. A configuration value often consists of a default value, a global or installation-wide value, a workspace-specific value, folder-specific value and language-specific values (if WorkspaceConfiguration is scoped to a language).

      Also provides all language ids under which the given configuration setting is defined.

      Note: The configuration name must denote a leaf in the configuration tree (editor.fontSize vs editor) otherwise no result is returned.

      Type Parameters

      • T

      Parameters

      • section: string

        Configuration name, supports dotted names.

      Returns
          | {
              defaultLanguageValue?: T;
              defaultValue?: T;
              globalLanguageValue?: T;
              globalValue?: T;
              key: string;
              languageIds?: string[];
              workspaceFolderLanguageValue?: T;
              workspaceFolderValue?: T;
              workspaceLanguageValue?: T;
              workspaceValue?: T;
          }
          | undefined

      Information about a configuration setting or undefined.

      • {
            defaultLanguageValue?: T;
            defaultValue?: T;
            globalLanguageValue?: T;
            globalValue?: T;
            key: string;
            languageIds?: string[];
            workspaceFolderLanguageValue?: T;
            workspaceFolderValue?: T;
            workspaceLanguageValue?: T;
            workspaceValue?: T;
        }
        • OptionaldefaultLanguageValue?: T

          Language specific default value when this configuration value is created for a language scope.

        • OptionaldefaultValue?: T

          The default value which is used when no other value is defined

        • OptionalglobalLanguageValue?: T

          Language specific global value when this configuration value is created for a language scope.

        • OptionalglobalValue?: T

          The global or installation-wide value.

        • key: string

          The fully qualified key of the configuration value

        • OptionallanguageIds?: string[]

          All language identifiers for which this configuration is defined.

        • OptionalworkspaceFolderLanguageValue?: T

          Language specific workspace-folder value when this configuration value is created for a language scope.

        • OptionalworkspaceFolderValue?: T

          The workspace-folder-specific value.

        • OptionalworkspaceLanguageValue?: T

          Language specific workspace value when this configuration value is created for a language scope.

        • OptionalworkspaceValue?: T

          The workspace-specific value.

      • undefined
    • Update a configuration value. The updated configuration values are persisted.

      A value can be changed in

      Note: To remove a configuration value use undefined, like so: config.update('somekey', undefined)

      Parameters

      • section: string

        Configuration name, supports dotted names.

      • value: any

        The new value.

      • OptionalconfigurationTarget: boolean | ConfigurationTarget | null

        The configuration target or a boolean value. - If true updates Global settings. - If false updates Workspace settings. - If undefined or null updates to Workspace folder settings if configuration is resource specific, otherwise to Workspace settings.

      • OptionaloverrideInLanguage: boolean

        Whether to update the value in the scope of requested languageId or not. - If true updates the value under the requested languageId. - If undefined updates the value under the requested languageId only if the configuration is defined for the language.

      Returns Thenable<void>

      error while updating - configuration which is not registered. - window configuration to workspace folder - configuration to workspace or workspace folder when no workspace is opened. - configuration to workspace folder when there is no workspace folder settings. - configuration to workspace folder when WorkspaceConfiguration is not scoped to a resource.