Generate JSON Schema and Markdown doc for .sourcekit-lsp/config.json
#1849
+986
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Providing a JSON schema for the configuration file should improve the developer experience thanks to better auto-completion and diagnostics support provided by some editors.
Additionally, we have been manually maintaining the configuration file format documentation in
Documentation/Configuration File.md
, but it's easy for the documentation to get out of sync with the actual schema.This change introduces a new tool,
ConfigSchemaGen
, that generates a JSON schema and a Markdown document for the configuration file based on the Swift type definitions in theSKOptions
module by using swift-syntax.Plan for vscode-swift integration
VSCode exposes a way to feed a JSON Schema definition for an opening file based on file name:
https://code.visualstudio.com/api/references/contribution-points#contributes.jsonValidation
Since the schema URL can be a local path and the configuration field can be modified dynamically by extension, we can specify a schema file shipped in the selected Swift toolchain. Or to simplify packaging flow, we can embed the schema file within the sourcekit-lsp binary and provide a CLI interface to print it, then vscode-swift can write it out in its extension storage and feed the file to VSCode.