-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add JSON schema for config #2859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JSON schema for config #2859
Conversation
Can somebody clarify color format being used here in config? |
I have almost done. The following features are not implemented yet:
|
BTW, here is my script to speed up schema creation in Nushell: # Convert YAML files with no nesting to JSON schema `properties` key contents.
# YAML key values are supposed to be `default` values in JSON schema.
def main [file_to_convert: string] {
let content = open $file_to_convert | to json
$content |
jq 'with_entries(select(.value | type != "object") | .value = {
title: (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase),
description: ("A " + (.key | sub("(?<a>[A-Z])"; " \(.a)"; "g") | ascii_downcase) + " keybinding\nhttps://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#default"),
type: (.value | type),
default: .value
})' |
xclip -selection clipboard
} |
Thanks for working on this, it looks extremely useful! You might add a bit more information to the PR description about how to use it. It took me a while to figure this out. A few thoughts from my side:
|
I share @stefanhaller 's thoughts re: maintenance burden. Some thoughts:
EDIT: also, if we go all-in on a json schema, it would be good to then generate markdown documentation from it e.g. via https://github.com/adobe/jsonschema2md |
I think it depends also on how easy is to support such versioned thing. AFAIK it's not always straightforward. I suggest add some
Totally agree here. But as for start I can just copy this schema to SchemaStore directly to get at least some assistance while working with config. Later I plan to automatically generate it and put generation result in this repository.
We don't need to even do that: we can just put a reference to schema from this repo like I did for another project. There is just one thing to keep in mind: our JSON schema should exist as a JSON file which means it should be generated (or manually written) before it's referred to.
You should have YAML Red Hat VS Code extension preinstalled to enable intellisence in config file. Yes, just that: installed extension. It automatically pulls schema and validate config against it. As a sidenote: if a user can create their own schema for our config and want to use it they can use their local schema instead of remote one. This is useful when they wanna add more hints to JSON schema matching their personal workflow. |
Registering the schema with SchemaStore is nice, but we'd probably have to rename our config file first to something like "lazygit-config.yml", don't we? "config.yml" feels a bit too generic to register. (Although I see that "config.json" was also registered, for "ASP.NET project config file", so there's precedence...) I also find Jesse's suggestion to auto-generate the schema using https://github.com/invopop/jsonschema super attractive. I'd combine this with trying to use https://github.com/invopop/yaml for reading/writing (to avoid having to put in both yaml and json tags); this might also give us other benefits, e.g. being able to warn about unrecognized fields to catch typos. @EmilySeville7cfg Are you interested in working on this? |
Definitely interested. ;) |
Feel free to test my JSON schema. It's ready for usage. If everything is fine we can put this schema in this repo, I can refer to it from SchemaStore and in the next PR implement it's autogeneration. UPD: all errors are fixed (default config passes without any issues). |
But honestly, I'm not sure it makes sense to continue working on manually crafting the schema, when we agreed we want to auto-generate it. I'm not sure I feel comfortable with the approach of merging this now, and then only switch to auto-generation later. |
I've put this schema directly to SchemaStore. When PR is merged users automatically get completions for **/.config/lazygit/config.yml and **/.config/lazygit/config.yaml files. Should I close this PR and implement JSON schema generation in a separate one or not? |
Very nice, huge usability improvement, thanks. (I've commented on that PR about the file patterns.) We still need to tell people about it, so once that PR is merged, it would be good to mention the Red Hat extension in
Since the manually created schema is now already on schemastore, I think there's no point in committing it here, too. So I'd vote for not merging this, and instead work on auto-generation. But that's just my personal opinion, I'll leave this for Jesse to decide. |
Agreed: no need to merge this: let's focus on auto-generating the schema |
Let me know if you're up for working on that @EmilySeville7cfg :) |
If not, I'd be interested in giving it a try. I don't want to take it from you, please go ahead if you want to; just in case. And I do think it's important that we solve this soon; I'm working on a PR that adds a new user config, and I'm getting a big red warning in the editor when I try to put it in. It would be unfortunate if users see this with a new release. |
Currently, I am adding JSON schemas for all lazy* projects such as lazydocker, lazynpm, etc. In a few days, I think I gonna start working on schema generation. When some JSON schema becomes autogenerated I remove it from SchemaStore and reference to lazy* repo (where it exists). |
Awesome, sounds good. Let me know if you need a rubber duck to bounce implementation ideas off of. 😄 |
PR Description


Adds JSON schema to enable config validation.
Please check if the PR fulfills these requirements
go run scripts/cheatsheet/main.go generate
)docs/Config.md
) have been updated if necessary