Skip to content
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

feat: add vscode subcommands for adding/removing txn schema from vscode #1862

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

willemneal
Copy link
Member

@willemneal willemneal commented Jan 30, 2025

This PR adds support for VSCode to recognize any file ending in .stellar_txn.json as a stellar transaction envelope (very open to renaming this!)

  • vscode setup - adds a json schema file in the folder of settings for VSCode. In the future we can publish it to an endpoint and then the link in the settings will be a url. It also uses jsonc-parser to parse and update the settings.json since it uses comments which need to preserved.

  • vscode cleanup - is unimplemented as it isn't needed in to complete the goal and is rather a nice feature to have, but leaving the setting in place does not impact any other settings. However, it would be nice to have this as it would allow for updating the schema (which if it was a url would be automatic)

Note: Currently the schema is a fixture in the binary. However, it once the xdr cli makes the schema generation public, see: stellar/rs-stellar-xdr#409

@willemneal willemneal marked this pull request as ready for review February 6, 2025 16:36
@willemneal willemneal requested review from leighmcculloch, fnando and elizabethengelman and removed request for leighmcculloch February 6, 2025 18:16
@fnando
Copy link
Member

fnando commented Feb 6, 2025

Personally I don't think we should be editing user's editor settings in any way. I was discussing this with Leigh yesterday and we need to find a less intrusive approach. This can be a good time to start a vscode extension, given that we have plans in the future for making other features specific to it.

Can we keep this in draft mode while we discuss the issue?

@willemneal willemneal marked this pull request as draft February 6, 2025 18:29
@leighmcculloch
Copy link
Member

Can these settings be controlled by an extension? I would assume so, but it's been a while since I've done anything with vscode extensions and I don't remember if you can control arbitrary settings like that.

@fnando
Copy link
Member

fnando commented Feb 6, 2025

Yes, that works: https://code.visualstudio.com/docs/languages/json#_mapping-a-schema-in-an-extension

Another alternative would be adding $schema to the json. That means editors (including vscode) will be able to download the schema and use the completion. If you want to try, create a new json file and paste this code:

{
  "$schema": "https://json.schemastore.org/coffeelint"
}

@leighmcculloch
Copy link
Member

leighmcculloch commented Feb 6, 2025

TIL. So we could publish the output of stellar xdr types schema --type ... to the docs, and include it with each rendered JSON from the rs-stellar-xdr? =O

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

Successfully merging this pull request may close these issues.

4 participants