Skip to content

add cargo config jsonschema support for editor auto completion and docs jumping #14482

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

Closed
wants to merge 2 commits into from

Conversation

loynoir
Copy link

@loynoir loynoir commented Sep 1, 2024

What does this PR try to resolve?

There is not yet editor hint and completion support for .cargo/config.toml.

So I impl it.

Related

Goals

[x] vscode tab completion on key

[x] vscode tab completion on value candidates

[x] vscode err hint when invalid key/value

[x] vscode hint on document url

How should we test and review this PR?

Review schema/cargo-config.schema.d.mts.

The jsonschema is generate from typescript using npm:typescript-json-schema@0.65.1.

Try genereated jsonschema using any supported editor toml extension.

        "evenBetterToml.schema.associations": {
            "^.*/\\.cargo/config\\.toml$": "https://raw.githubusercontent.com/loynoir/cargo/feat-json-schema-for-editor/schema/cargo-config.schema.json",

Additional information

As result, you can see the output jsonschema is very large.

Not able to let human write it.

So I generate it from typescript dts.

Maybe someone can impl macro rules to generate jsonschema, website docs and cli parser at the same time in the future.

@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 1, 2024
@epage
Copy link
Contributor

epage commented Sep 3, 2024

Generally we use cargo xtasks for automating things in the repo with a CI check to ensure that the generator and the output haven't drifted (make the generator was run, avoid hand-edits). This also duplicates information in an out-of-the-way place (currently in source and in our own documentation).

Also, I'm unsure what the implications are of us having incomplete or wrong information for targets since a straight combination of arch, sub, vendor, sys, and abi are being used. We might want to just leave that as a string.

I wonder if we could use schemars or something like would be a good way to single-source this information. Maybe then we could also code-generate some of our documentation from it as well.

If you go down this route, I'd recommend playing with this for Cargo.toml first in crates/cargo-util-schemas. We could have an unstable-schemagen feature and the xtask could enable it and get the schema and dump it. If/when we get that settled, we could work to move the config schemas to cargo-util-schemas and under unstable-schemagen have a top-level TomlConfig struct.

@loynoir loynoir closed this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants