soroban-cli
soroban-cli copied to clipboard
feat: add vscode subcommands for adding/removing txn schema from vscode
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 thesettings.jsonsince 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: https://github.com/stellar/rs-stellar-xdr/pull/409
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?
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.
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"
}
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
This pull request is stale because it has been open for 30 days with no activity. It will be closed in 90 days unless the stale label is removed.