Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface WorkspaceConfiguration

Represents the configuration. It is a merged view of

  • Default configuration
  • Global configuration
  • Workspace configuration (if available)
  • Workspace folder configuration of the requested resource (if available)

Global configuration comes from User Settings and shadows Defaults.

Workspace configuration comes from Workspace Settings and shadows Global configuration.

Workspace Folder configuration comes from .vscode folder under one of the workspace folders.

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.window.activeTextEditor.document.uri);

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

Refer to Settings for more information.

Hierarchy

  • WorkspaceConfiguration

Indexable

[key: string]: any

Readable dictionary that backs this configuration.

Index

Methods

  • get<T>(section: string): undefined | T
  • get<T>(section: string, defaultValue: T): T
  • Return a value from this configuration.

    Type Parameters

    • T

    Parameters

    • section: string

      Configuration name, supports dotted names.

    Returns undefined | T

    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.

  • has(section: string): boolean
  • 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.

  • inspect<T>(section: string): undefined | { defaultValue?: T; globalValue?: T; key: string; workspaceFolderValue?: T; workspaceValue?: T }
  • 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 and a folder-specific value.

    The effective value (returned by get) is computed like this: defaultValue overwritten by globalValue, globalValue overwritten by workspaceValue. workspaceValue overwritten by workspaceFolderValue. Refer to Settings Inheritance for more information.

    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 undefined | { defaultValue?: T; globalValue?: T; key: string; workspaceFolderValue?: T; workspaceValue?: T }

    Information about a configuration setting or undefined.

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

    A value can be changed in

    Note 1: Setting a global value in the presence of a more specific workspace value has no observable effect in that workspace, but in others. Setting a workspace value in the presence of a more specific folder value has no observable effect for the resources under respective folder, but in others. Refer to Settings Inheritence for more information.

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

    Will throw error when

    • Writing a configuration which is not registered.
    • Writing a configuration to workspace or folder target when no workspace is opened
    • Writing a configuration to folder target when there is no folder settings
    • Writing to folder target without passing a resource when getting the configuration (workspace.getConfiguration(section, resource))
    • Writing a window configuration to folder target

    Parameters

    • section: string

      Configuration name, supports dotted names.

    • value: any

      The new value.

    • Optional configurationTarget: boolean | ConfigurationTarget

      The configuration target or a boolean value.

      • If true configuration target is ConfigurationTarget.Global.
      • If false configuration target is ConfigurationTarget.Workspace.
      • If undefined or null configuration target is ConfigurationTarget.WorkspaceFolder when configuration is resource specific ConfigurationTarget.Workspace otherwise.

    Returns Thenable<void>