<!-- DO NOT EDIT THIS FILE. This file is generated by ConfigSchemaGen/OptionDocument.swift. -->

# Configuration File

`.sourcekit-lsp/config.json` configuration files can be used to modify the behavior of SourceKit-LSP in various ways. The following locations are checked. Settings in later configuration files override settings in earlier configuration files
- `~/.sourcekit-lsp/config.json`
- On macOS: `~/Library/Application Support/org.swift.sourcekit-lsp/config.json` from the various `Library` folders on the system
- If the `XDG_CONFIG_HOME` environment variable is set: `$XDG_CONFIG_HOME/sourcekit-lsp/config.json`
- Initialization options passed in the initialize request
- A `.sourcekit-lsp/config.json` file in a workspace’s root

Modifying the configuration file requires SourceKit-LSP to be restarted for the new options to take effect.

The structure of the file is currently not guaranteed to be stable. Options may be removed or renamed.

## Structure

`config.json` is a JSON file with the following structure. All keys are optional and unknown keys are ignored.
- `swiftPM`: Options for SwiftPM workspaces.
  - `configuration: "debug"|"release"`: The configuration to build the project for during background indexing and the configuration whose build folder should be used for Swift modules if background indexing is disabled. Equivalent to SwiftPM's `--configuration` option.
  - `scratchPath: string`: Build artifacts directory path. If nil, the build system may choose a default value. This path can be specified as a relative path, which will be interpreted relative to the project root. Equivalent to SwiftPM's `--scratch-path` option.
  - `swiftSDKsDirectory: string`: Equivalent to SwiftPM's `--swift-sdks-path` option.
  - `swiftSDK: string`: Equivalent to SwiftPM's `--swift-sdk` option.
  - `triple: string`: Equivalent to SwiftPM's `--triple` option.
  - `sdk: string`: Equivalent to SwiftPM's `--sdk` option.
  - `toolsets: string[]`: Equivalent to SwiftPM's `--toolset` option.
  - `pkgConfigPaths: string[]`: Equivalent to SwiftPM's `--pkg-config-path` option.
  - `traits: string[]`: Traits to enable for the package. Equivalent to SwiftPM's `--traits` option.
  - `cCompilerFlags: string[]`: Extra arguments passed to the compiler for C files. Equivalent to SwiftPM's `-Xcc` option.
  - `cxxCompilerFlags: string[]`: Extra arguments passed to the compiler for C++ files. Equivalent to SwiftPM's `-Xcxx` option.
  - `swiftCompilerFlags: string[]`: Extra arguments passed to the compiler for Swift files. Equivalent to SwiftPM's `-Xswiftc` option.
  - `linkerFlags: string[]`: Extra arguments passed to the linker. Equivalent to SwiftPM's `-Xlinker` option.
  - `buildToolsSwiftCompilerFlags: string[]`: Extra arguments passed to the compiler for Swift files or plugins. Equivalent to SwiftPM's `-Xbuild-tools-swiftc` option.
  - `forceResolvedVersions: boolean`: Equivalent to SwiftPM's `--force-resolved-versions` option. Makes all processes (including background indexing) treat Package.resolved as a lock file.
  - `disableSandbox: boolean`: Disables running subprocesses from SwiftPM in a sandbox. Equivalent to SwiftPM's `--disable-sandbox` option. Useful when running `sourcekit-lsp` in a sandbox because nested sandboxes are not supported.
  - `extraArguments: string[]`: Additional arguments appended to SwiftPM when starting or preparing the build server.
  - `buildSystem: "native"|"swiftbuild"`: Which SwiftPM build system should be used when opening a package.
- `compilationDatabase`: Dictionary with the following keys, defining options for workspaces with a compilation database.
  - `searchPaths: string[]`: Additional paths to search for a compilation database, relative to a workspace root.
- `fallbackBuildSystem`: Dictionary with the following keys, defining options for files that aren't managed by any build server.
  - `cCompilerFlags: string[]`: Extra arguments passed to the compiler for C files.
  - `cxxCompilerFlags: string[]`: Extra arguments passed to the compiler for C++ files.
  - `swiftCompilerFlags: string[]`: Extra arguments passed to the compiler for Swift files.
  - `sdk: string`: The SDK to use for fallback arguments. Default is to infer the SDK using `xcrun`.
- `buildSettingsTimeout: integer`: Number of milliseconds to wait for build settings from the build server before using fallback build settings.
- `clangdOptions: string[]`: Extra command line arguments passed to `clangd` when launching it.
- `index`: Options related to indexing.
  - `indexPrefixMap: [string: string]`: Path remappings for remapping index data for local use.
  - `updateIndexStoreTimeout: integer`: Number of seconds to wait for an update index store task to finish before terminating it.
- `logging`: Options related to logging, changing SourceKit-LSP’s logging behavior on non-Apple platforms. On Apple platforms, logging is done through the [system log](Diagnose%20Bundle.md#Enable%20Extended%20Logging). These options can only be set globally and not per workspace.
  - `level: "debug"|"info"|"default"|"error"|"fault"`: The level from which one onwards log messages should be written.
  - `privacyLevel: "public"|"private"|"sensitive"`: Whether potentially sensitive information should be redacted. Default is `public`, which redacts potentially sensitive information.
  - `inputMirrorDirectory: string`: Write all input received by SourceKit-LSP on stdin to a file in this directory. Useful to record and replay an entire SourceKit-LSP session.
  - `outputMirrorDirectory: string`: Write all data sent from SourceKit-LSP to the client to a file in this directory. Useful to record the raw communication between SourceKit-LSP and the client on a low level.
- `sourcekitd`: Options modifying the behavior of sourcekitd.
- `defaultWorkspaceType: "buildServer"|"compilationDatabase"|"swiftPM"`: Default workspace type. Overrides workspace type selection logic.
- `generatedFilesPath: string`: Directory in which generated interfaces and macro expansions should be stored.
- `backgroundIndexing: boolean`: Whether background indexing is enabled.
- `backgroundPreparationMode: "build"|"noLazy"|"enabled"`: Determines how background indexing should prepare a target.
  - `build`: Build a target to prepare it.
  - `noLazy`: Prepare a target without generating object files but do not do lazy type checking and function body skipping. This uses SwiftPM's `--experimental-prepare-for-indexing-no-lazy` flag.
  - `enabled`: Prepare a target without generating object files.
- `cancelTextDocumentRequestsOnEditAndClose: boolean`: Whether sending a `textDocument/didChange` or `textDocument/didClose` notification for a document should cancel all pending requests for that document.
- `reportSyntacticHighlightInSemanticTokens: boolean`: Whether the response for `textDocument/semanticTokens` should include semantic tokens for syntactic and semantic highlighting or just semantic highlighting. This should be enabled in cases where the syntactic grammar (e.g. TextMate or tree-sitter) used by an editor is insufficient for properly highlighting the source code. This can happen for example happen when using complex string interpolations or nested raw strings.
- `experimentalFeatures: ("on-type-formatting"|"structured-logs")[]`: Experimental features that are enabled.
- `swiftPublishDiagnosticsDebounceDuration: number`: The time that `SwiftLanguageService` should wait after an edit before starting to compute diagnostics and sending a `PublishDiagnosticsNotification`.
- `workDoneProgressDebounceDuration: number`: When a task is started that should be displayed to the client as a work done progress, how many milliseconds to wait before actually starting the work done progress. This prevents flickering of the work done progress in the client for short-lived index tasks which end within this duration.
- `sourcekitdRequestTimeout: number`: The maximum duration that a sourcekitd request should be allowed to execute before being declared as timed out. In general, editors should cancel requests that they are no longer interested in, but in case editors don't cancel requests, this ensures that a long-running non-cancelled request is not blocking sourcekitd and thus most semantic functionality. In particular, VS Code does not cancel the semantic tokens request, which can cause a long-running AST build that blocks sourcekitd.
- `semanticServiceRestartTimeout: number`: If a request to sourcekitd or clangd exceeds this timeout, we assume that the semantic service provider is hanging for some reason and won't recover. To restore semantic functionality, we terminate and restart it.
- `buildServerWorkspaceRequestsTimeout: number`: Duration how long to wait for responses to `workspace/buildTargets` or `buildTarget/sources` request by the build server before defaulting to an empty response.
- `preparationBatchingStrategy: object`: Defines the batch size for target preparation. If nil, defaults to preparing 1 target at a time.
  - This is a tagged union discriminated by the `strategy` field. Each case has the following structure:
  - `strategy: "fixedTargetBatchSize"`: Prepare a fixed number of targets in a single batch. `batchSize`: The number of targets to prepare in each batch.
    - `batchSize: integer`: The number of targets to prepare in each batch.
