Skip to content

Please revisit the idea of exposing the configuration format as JSON schema #1640

@idanarye

Description

@idanarye

Long ago I've suggested to add methods for clients to get the current configuration and a schema for the configuration (#467). This was closed as out of scope, and the main objection (as I understand it) was that JSON a generic client won't be able to do anything useful with that information.

Now that the ecosystem is a bit more mature, I request that you look again at the idea. JSON Schema seems to be the standard for specifying JSON structure, and has lots of tools and libraries. I can think of two ways to utilize it for this task - both done by the clients (the protocol and the servers just need to offer the schema and the configuration):

I. Language servers for data serialization formats

Language servers like vscode-json-languageservice or YAML Language Server can read a JSON Schema and use it to lint deviations from the schema, provide completion for the specific fields and their possible values, and show tooltips when hoovering on fields or values.

An editor or an IDE could:

  1. Get the current configuration from the language server.
  2. Serialize that configuration to JSON or YAML.
  3. Put that serialized configuration in a text buffer.
  4. Attach a language server to that text buffer.
  5. Get the configuration schema from the original language server, and feed it to the language server that handles the serialized configuration buffer.
  6. When the user is done editing the configuration, send it back to the original language server.

The user will be working on a full configuration - even if it's just the default one, it would still have all the fields because we got it from the server which means that's what the server uses internally. Working on something like that, together with a language server that helps you edit it, should be much easier than writing a configuration from scratch based on documentation and some examples.

II. UI generators

There are many libraries that can take a JSON Schema and generate UI for editing that schema. Most of them are web UIs, so this is mainly useful for editors/IDEs based on web technologies (like VSCode), but other editors can just use the first method.

This works the same as the previous method, but instead of using a language server for JSON/YAML the editor/IDE would use one of these libraries to generate a UI for editing the configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions