diff --git a/src/schemas/bindingOverrides.json b/src/schemas/bindingOverrides.json new file mode 100644 index 0000000..c263771 --- /dev/null +++ b/src/schemas/bindingOverrides.json @@ -0,0 +1,178 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Binding Overrides", + "type": "object", + "additionalProperties": false, + "definitions": { + "bindingOverride": { + "type": "object", + "additionalProperties": false, + "properties": { + "keys": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] + }, + "position": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "definitions.json#/definitions/bindingType" + }, + "command": { + "$ref": "definitions.json#/definitions/command" + }, + "commands": { + "$ref": "definitions.json#/definitions/commands" + }, + "args": { + "$ref": "definitions.json#/definitions/args" + }, + "bindings": { + "$ref": "definitions.json#/definitions/bindings" + } + }, + "required": [ + "keys" + ], + "allOf": [ + { + "if": { + "properties": { + "position": { + "minimum": 0 + } + } + }, + "then": { + "required": [ + "name", + "type" + ] + } + }, + { + "if": { + "anyOf": [ + { + "properties": { + "type": { + "const": "command" + } + } + }, + { + "allOf": [ + { + "properties": { + "type": { + "const": "transient" + } + }, + "not": { + "required": [ + "commands" + ] + } + } + ] + } + ] + }, + "then": { + "required": [ + "command" + ] + } + }, + { + "if": { + "anyOf": [ + { + "properties": { + "type": { + "const": "commands" + } + } + }, + { + "allOf": [ + { + "properties": { + "type": { + "const": "transient" + } + }, + "not": { + "required": [ + "command" + ] + } + } + ] + } + ] + }, + "then": { + "required": [ + "commands" + ] + } + }, + { + "if": { + "properties": { + "type": { + "const": "commands" + } + } + }, + "then": { + "properties": { + "args": { + "type": "array" + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "bindings" + } + } + }, + "then": { + "required": [ + "bindings" + ] + } + } + ] + } + }, + "properties": { + "$schema": { + "type": "string", + "description": "uri to schema" + }, + "bindingOverrides": { + "type": "array", + "items": { + "$ref": "#/definitions/bindingOverride" + } + } + } +} diff --git a/src/schemas/bindings.json b/src/schemas/bindings.json new file mode 100644 index 0000000..884838e --- /dev/null +++ b/src/schemas/bindings.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Bindings", + "type": "object", + "additionalProperties": false, + "properties": { + "$schema": { + "type": "string", + "description": "uri to schema" + }, + "bindings": { + "type": "array", + "items": { + "$ref": "definitions.json#/definitions/bindingItem" + } + } + }, + "required": [ + "bindings" + ] +} diff --git a/src/schemas/definitions.json b/src/schemas/definitions.json new file mode 100644 index 0000000..ad1bb99 --- /dev/null +++ b/src/schemas/definitions.json @@ -0,0 +1,77 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Bindings", + "type": "object", + "additionalProperties": false, + "definitions": { + "bindingItem": { + "type": "object", + "additionalProperties": false, + "properties": { + "key": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "definitions.json#/definitions/bindingType" + }, + "command": { + "$ref": "definitions.json#/definitions/command" + }, + "commands": { + "$ref": "definitions.json#/definitions/commands" + }, + "args": { + "$ref": "definitions.json#/definitions/args" + }, + "bindings": { + "$ref": "definitions.json#/definitions/bindings" + } + }, + "required": [ + "key", + "name", + "type" + ] + }, + "bindingType": { + "type": "string", + "enum": [ + "command", + "commands", + "bindings", + "transient" + ] + }, + "command": { + "type": "string" + }, + "commands": { + "type": "array", + "items": { + "type": "string" + } + }, + "args": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "array", + "items": { + "type": "object" + } + } + ] + }, + "bindings": { + "type": "array", + "items": { + "$ref": "definitions.json#/definitions/bindingItem" + } + } + } +} diff --git a/src/schemas/examples/bindingOverrides.json b/src/schemas/examples/bindingOverrides.json new file mode 100644 index 0000000..7d580f5 --- /dev/null +++ b/src/schemas/examples/bindingOverrides.json @@ -0,0 +1,18 @@ +{ + "$schema": "../bindingOverrides.json", + "bindingOverrides": [ + { + "keys": "g", + "name": "Go...", + "type": "bindings", + "bindings": [ + { + "key": "s", + "name": "Go to", + "type": "command", + "command": "workbench.action.gotoLine" + } + ] + } + ] +} diff --git a/src/schemas/examples/bindings.json b/src/schemas/examples/bindings.json new file mode 100644 index 0000000..5a5a0e1 --- /dev/null +++ b/src/schemas/examples/bindings.json @@ -0,0 +1,37 @@ +{ + "$schema": "../bindings.json", + "bindings": [ + { + "key": "f", + "name": "File...", + "type": "bindings", + "bindings": [ + { + "key": "f", + "name": "Open file", + "type": "command", + "command": "workbench.action.files.openFileFolder" + }, + { + "key": "i", + "name": "Indentation...", + "type": "bindings", + "bindings": [ + { + "key": "i", + "name": "Change indentation", + "type": "command", + "command": "changeEditorIndentation" + }, + { + "key": "d", + "name": "Detect indentation", + "type": "command", + "command": "editor.action.detectIndentation" + } + ] + } + ] + } + ] +}