jj icon indicating copy to clipboard operation
jj copied to clipboard

FR: Contribute config-schema to schemastore

Open jgreitemann opened this issue 8 months ago • 0 comments

We have a reasonably accurate schema for the config TOML but we don't actually benefit from it when editing the config file in an editor which either has a taplo-derived plugin (like Even Better TOML in VSCode) or uses the taplo LSP directly. That currently requires dumping the schema somewhere using jj util config-schema or finding it in the docs and then adding a schema directive to the top of the config file:

#:schema https://jj-vcs.github.io/jj/latest/config-schema.json

Taplo has actually support for the JSON Schema Store. If we were to register our schema with them, .jjconfig.toml, jj/config.toml, .jj/repo/config.toml files could automatically apply the schema. There are two options for contributing schema: hosted at the schemastore repo or externally hosted, i.e. directly from the jj-vcs/jj repo. Since we have documented the https://jj-vcs.github.io/jj/latest/config-schema.json URL already, the externally hosted option is probably the way to go.

Alternatively, we could write the schema locally to disk, at least when using jj config edit, and populate the TOML file with a schema directive pointing to the local file before opening the editor. The benefit of this would be that it would also work offline. The downside is that it wouldn't work when editing the config file without using jj config edit at least once to populate the schema directive.

jgreitemann avatar Apr 17 '25 19:04 jgreitemann