From 3617e0d1b79b238a7d7aa6948e375f865dbeee73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Sat, 21 Mar 2020 14:44:20 +0100 Subject: [PATCH] Various schema improvements - Add $schema to all schemas and unify whitespace - Remove `additionalProperties: false` from sublime-project schema because: a) we don't actually want to limit keys to only known names b) it was defined in the wrong spot so it didn't function as one would expect (it was just an extra property called literally `additionalProperties`). - Add enum descriptions in sublime-settings schema - Use markdown for rendering descriptions - Added schema definitions created by AmjadHD Original schemas from https://github.com/AmjadHD/sublime_json_schemas - Fix multiple items in context triggering a warning If there was more than one object in context array, and those didn't follow the same schema then warning was triggered. --- schemas/jsconfig.json | 17 +- schemas/package-json-eslint.json | 12 +- schemas/sublime-build.json | 117 ++++- schemas/sublime-color-scheme.json | 1 + schemas/sublime-commands.json | 1 + schemas/sublime-completions.json | 1 + schemas/sublime-keymap.json | 3 +- schemas/sublime-macro.json | 1 + schemas/sublime-menu.json | 1 + schemas/sublime-mousemap.json | 1 + schemas/sublime-project.json | 82 ++- schemas/sublime-settings.json | 848 +++++++++++++++++++++++++++++- schemas/sublime-theme.json | 1 + schemas/tsconfig.json | 25 +- schemas/vscode-base.json | 1 + 15 files changed, 1082 insertions(+), 30 deletions(-) diff --git a/schemas/jsconfig.json b/schemas/jsconfig.json index 9cdd063..bee3d0d 100644 --- a/schemas/jsconfig.json +++ b/schemas/jsconfig.json @@ -1,11 +1,12 @@ { - "allowComments": true, - "allowTrailingCommas": true, - "title": "JSON schema for the JavaScript configuration file", - "type": "object", - "default": { - "compilerOptions": { - "target": "es6" - } + "$schema": "http://json-schema.org/draft-07/schema#", + "allowComments": true, + "allowTrailingCommas": true, + "title": "JSON schema for the JavaScript configuration file", + "type": "object", + "default": { + "compilerOptions": { + "target": "es6" } + } } diff --git a/schemas/package-json-eslint.json b/schemas/package-json-eslint.json index c5c169b..ace6b9c 100644 --- a/schemas/package-json-eslint.json +++ b/schemas/package-json-eslint.json @@ -1,9 +1,9 @@ { - "$schema": "http://json-schema.org/draft-07/schema", - "properties": { - "eslintConfig": { - "description": "ESLint configuration", - "$ref": "http://json.schemastore.org/eslintrc" - } + "$schema": "http://json-schema.org/draft-07/schema", + "properties": { + "eslintConfig": { + "description": "ESLint configuration", + "$ref": "http://json.schemastore.org/eslintrc" } + } } diff --git a/schemas/sublime-build.json b/schemas/sublime-build.json index 9a64403..6ea93d6 100644 --- a/schemas/sublime-build.json +++ b/schemas/sublime-build.json @@ -1,7 +1,122 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-build", "title": "Sublime Text Build System", "allowComments": true, "allowTrailingCommas": true, - "type": "object" + "type": "object", + "properties": { + "selector": { + "type": "string", + "markdownDescription": "The base scope name of the syntax that this build system should be enabled for." + }, + "file_patterns": { + "markdownDescription": "A list of file name patterns the build system should be enabled for.", + "type": "array", + "items": { + "type": "string" + } + }, + "keyfiles": { + "markdownDescription": "A list of file names, if present in one of the opened folders, that will cause the build system to be enabled.", + "type": "array", + "items": { + "type": "string" + } + }, + "variants": { + "markdownDescription": "A list of subsidiary build systems that will inherit the options from the top-level build system. Each variant needs to specify a `name` key, and may override or add options to the top-level build system", + "type": "array", + "items": { + "allOf": [ + {"$ref": "#"}, + { "properties": { + "name": { + "type": "string" + } + }, + "required": ["name"] + } + ] + } + }, + "cancel": { + "markdownDescription": "A string command name, or an object of string options. If a string is specified, the command specified will be used to cancel the build. If an object, the primary target will be called, with these options added on. This only needs to be specified when using a custom `target`.", + "type": ["string", "object"] + }, + "target": { + "markdownDescription": "The command to run when the build system is invoked. The default value of exec allows use of the additional options specified in [exec Target Options](https://www.sublimetext.com/docs/3/build_systems.html#exec_options). If a value other than `exec` is specified, none of the options in exec Target Options will do anything. See the [Advanced Example](https://www.sublimetext.com/docs/3/build_systems.html#advanced_example) for a complete example.", + "type": "string" + }, + "windows": { + "allOf": [ + {"$ref": "#"}, + { + "markdownDescription": "An object of options to use when the build system is being executed on a Windows machine.\nExample:\n```\n{\n\t\"cmd\": [\"my_command.exe\", \"/D\", \"$file\"]\n}\n```" + } + ] + }, + "osx": { + "allOf": [ + {"$ref": "#"}, + { + "markdownDescription": "An object of options to use when the build system is being executed on a Mac machine.\nExample:\n```\n{\n\t\"cmd\": [\"/Applications/MyProgram.app/Contents/MacOS/my_command\", \"-d\", \"$file\"]\n}" + } + ] + }, + "linux": { + "allOf": [ + {"$ref": "#"}, + { + "markdownDescription": "An object of options to use when the build system is being executed on a Linux machine.\nExample:\n```\n{\n\t\"cmd\": [\"/usr/local/bin/my_command\", \"-d\", \"$file\"]\n}" + } + ] + }, + "cmd": { + "markdownDescription": "A list of strings specifying the executable to run, plus any arguments to pass to it. Shell constructs such as piping and redirection are not supported – see [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd). May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).", + "type": "array", + "items": { + "type": "string" + } + }, + "shell_cmd": { + "markdownDescription": "A string specifying a shell command to execute. Unlike the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) option, this does allow piping and redirection. Will use `bash` on Mac and Linux machine, and `cmd.exe` on Windows. May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).\nExample: `\"my_command \\\"$file\\\" | other_command\"`", + "type": "string" + }, + "working_dir": { + "markdownDescription": "A string specifying the directory to execute the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) or [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd) within. May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).\nExample: `\"$file_path\"`", + "type": "string" + }, + "file_regex": { + "markdownDescription": "A string containing a regular expression to run on the build output to match file information. The matched file information is used to enable result navigation. The regex should capture 2, 3 or 4 groups.\n\nThe capture groups should be:\n\n1. filename\n2. line number\n3. column number\n4. message\n\nExample: `\"^\\s*(\\S[^:]*)\\((\\d+):(\\d+)\\): ([^\\n]+)\"`", + "type": "string", + "format": "regex" + }, + "line_regex": { + "markdownDescription": "A string containing a regular expression to run on the build output to match line information. The matched file information is used to enable result navigation. The regex should capture 1, 2 or 3 groups.\n\nThe groups should capture:\n\n1.line number\n2. column number\n3. error message\n\nThis regular expression is only necessary when some results contain strictly a line number, line and column numbers, or line and column numbers with a message. When such a match is made, the [file_regex](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-file_regex) option will be used to search backwards to find the appropriate file name.\n\nExample: `\"^\\s*line (\\d+) col (\\d+): ([^\\n]+)\"", + "type": "string", + "format": "regex" + }, + "encoding": { + "markdownDescription": "A string specifying the encoding of the build system output. Uses [Python codec names](https://docs.python.org/3.3/library/codecs.html#id3). Defaults to `\"utf-8\"`.\n\nExample: `\"iso-8859-1\"`", + "type": "string" + }, + "env": { + "markdownDescription": "An object containing environment variable values to use when running the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) or [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd).\nExample:\n```\n{\n\t\"PYTHONIOENCODING\": \"utf-8\"\n}", + "type": "object" + }, + "quiet": { + "markdownDescription": "A boolean that reduces the amount of output about the build system invocation.", + "type": "boolean" + }, + "word_wrap": { + "markdownDescription": "A boolean that turns on word wrapping in the build system output panel.", + "type": "boolean" + }, + "syntax": { + "markdownDescription": "A string specifying the syntax file to use to highlight the build system output panel.\nExample: `\"Packages/JavaScript/JSON.sublime-syntax\"`", + "type": "string", + "pattern": "^Packages/.+\\.(sublime-syntax|tmLanguage)" + } + } } diff --git a/schemas/sublime-color-scheme.json b/schemas/sublime-color-scheme.json index f344640..c9198ca 100644 --- a/schemas/sublime-color-scheme.json +++ b/schemas/sublime-color-scheme.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-color-scheme", "title": "Sublime Text Color Scheme", "allowComments": true, diff --git a/schemas/sublime-commands.json b/schemas/sublime-commands.json index b09dad6..d423007 100644 --- a/schemas/sublime-commands.json +++ b/schemas/sublime-commands.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-commands", "title": "Sublime Text Commands", "allowComments": true, diff --git a/schemas/sublime-completions.json b/schemas/sublime-completions.json index 0d1787f..b2489b9 100644 --- a/schemas/sublime-completions.json +++ b/schemas/sublime-completions.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-completions", "title": "Sublime Text Completions", "allowComments": true, diff --git a/schemas/sublime-keymap.json b/schemas/sublime-keymap.json index cc097d0..733193d 100644 --- a/schemas/sublime-keymap.json +++ b/schemas/sublime-keymap.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-keymap", "title": "Sublime Text Keymap", "allowComments": true, @@ -20,7 +21,7 @@ "type": "object", "properties": { "key": { - "oneOf": [ + "anyOf": [ { "type": "string", "description": "Condition that must evaluate to true for the key binding to be active", diff --git a/schemas/sublime-macro.json b/schemas/sublime-macro.json index e98b86d..722e4fe 100644 --- a/schemas/sublime-macro.json +++ b/schemas/sublime-macro.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-macro", "title": "Sublime Text Macro", "allowComments": true, diff --git a/schemas/sublime-menu.json b/schemas/sublime-menu.json index 7662fea..4d6f5dd 100644 --- a/schemas/sublime-menu.json +++ b/schemas/sublime-menu.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-menu", "title": "Sublime Text Menu", "allowComments": true, diff --git a/schemas/sublime-mousemap.json b/schemas/sublime-mousemap.json index bbfdc03..084e1fd 100644 --- a/schemas/sublime-mousemap.json +++ b/schemas/sublime-mousemap.json @@ -1,4 +1,5 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-mousemap", "title": "Sublime Text Mousemap", "allowComments": true, diff --git a/schemas/sublime-project.json b/schemas/sublime-project.json index c4b4ad4..4b77061 100644 --- a/schemas/sublime-project.json +++ b/schemas/sublime-project.json @@ -1,7 +1,87 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", "$id": "sublime://sublime-project", "title": "Sublime Text Project", "allowComments": true, "allowTrailingCommas": true, - "type": "object" + "type": "object", + "properties": { + "folders": { + "markdownDescription": "List of folders added to the project", + "type": "array", + "items": { + "type": "object", + "properties": { + "additionalProperties": false, + "path": { + "markdownDescription": "A path of a project folder.", + "type": "string" + }, + "name": { + "markdownDescription": "A string used in place of the folder name in the side bar.", + "type": "string" + }, + "file_include_patterns": { + "markdownDescription": "A list of filenames to include from the folder. Anything not matching these patterns will be excluded. This is checked before `file_exclude_patterns`.", + "type": "array", + "items": { + "type": "string" + } + }, + "file_exclude_patterns": { + "markdownDescription": "A list of strings for filenames to exclude from the folder. This is added to the global setting of the same name. This is checked after `file_include_patterns`.", + "type": "array", + "items": {"type": "string", "examples": ["Hello", "World"]} + }, + "folder_include_patterns": { + "markdownDescription": "A list of strings for subfolder paths to include from the folder. Anything not matching these patterns will be excluded. This is checked before `folder_exclude_patterns`.", + "type": "array", + "items": {"type": "string"} + }, + "folder_exclude_patterns": { + "markdownDescription": "A list of strings for subfolder paths to exclude from the folder. This is added to the global setting of the same name. This is checked after `folder_include_patterns`.", + "type": "array", + "items": {"type": "string"} + }, + "binary_file_patterns": { + "markdownDescription": "A list of strings for filenames to treat as binary files, and thus ignored in _Goto Anything_ or _Find in Files_.", + "type": "array", + "items": {"type": "string"} + }, + "index_include_patterns": { + "markdownDescription": "A list of strings for full file paths to index in the folder. This is added to the global setting of the same name. Anything not matching these patterns will be excluded from the index. This is checked before `index_exclude_patterns`.", + "type": "array", + "items": {"type": "string"} + }, + "index_exclude_patterns": { + "markdownDescription": "A list of strings for file full paths to index in the folder. This is added to the global setting of the same name. This is checked after `index_include_patterns`.", + "type": "array", + "items": {"type": "string"} + }, + "follow_symlinks": { + "markdownDescription": "If symlinks should be followed when building the folder tree.", + "type": "boolean" + } + } + } + }, + "settings": { + "type": "object" + }, + "build_systems": { + "type": "array", + "items": { + "allOf": [ + {"$ref": "sublime://sublime-build"}, + { "properties": { + "name": { + "type": "string" + } + }, + "required": ["name"] + } + ] + } + } + } } diff --git a/schemas/sublime-settings.json b/schemas/sublime-settings.json index cef455f..a3f3e61 100644 --- a/schemas/sublime-settings.json +++ b/schemas/sublime-settings.json @@ -1,7 +1,853 @@ { + "$schema": "http://json-schema.org/draft-07/schema", "$id": "sublime://sublime-settings", "title": "Sublime Text Settings", "allowComments": true, "allowTrailingCommas": true, - "type": "object" + "type": "object", + "properties": { + "color_scheme": { + "markdownDescription": "Sets the colors used within the text area.", + "type": "string", + "pattern": "^.+\\.(sublime-color-scheme|tmTheme)$", + "default": "Monokai.sublime-color-scheme" + }, + "font_face": { + "markdownDescription": "Font face of the text area.\n`font_face` is overridden in the platform specific settings file, for example, \"Preferences (Linux).sublime-settings\".\n Because of this, setting it here will have no effect: you must set it in your User File Preferences.", + "type": "string", + "default": "" + }, + "font_size": { + "markdownDescription": "Point size of the font used in the text area.\n`font_size` is overridden in the platform specific settings file, for example, \"Preferences (Linux).sublime-settings\".\n Because of this, setting it here will have no effect: you must set it in your User File Preferences.", + "type": "integer", + "default": 10 + }, + "font_options": { + "markdownDescription": "Options for text font.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "no_bold", + "no_italic", + "no_antialias", + "gray_antialias", + "no_liga", + "no_clig", + "no_calt", + "dlig", + "ss01", + "ss02", + "ss03", + "ss04", + "ss05", + "ss06", + "ss07", + "ss08", + "ss09", + "ss10", + "directwrite", + "gdi", + "dwrite_cleartype_classic", + "dwrite_cleartype_natural", + "subpixel_antialias", + "no_round" + ], + "markdownEnumDescriptions": [ + "Disable bold text.", + "Disable italic text.", + "Disable antialiasing.", + "Use grayscale antialiasing instead of subpixel.", + "Disable standard ligatures (OpenType liga feature).", + "Disable contextual ligatures (OpenType clig feature).", + "Disable contextual alternatives (OpenType calt feature).", + "Enable discretionary ligatures (OpenType dlig feature).", + "Enable OpenType stylistic set 1.", + "Enable OpenType stylistic set 2.", + "Enable OpenType stylistic set 3.", + "Enable OpenType stylistic set 4.", + "Enable OpenType stylistic set 5.", + "Enable OpenType stylistic set 6.", + "Enable OpenType stylistic set 7.", + "Enable OpenType stylistic set 8.", + "Enable OpenType stylistic set 9.", + "Enable OpenType stylistic set 10.", + "Use DirectWrite for font rendering (default, Windows only!).", + "Use GDI for font rendering (Windows only!).", + "Only applicable to `directwrite` mode, should render fonts similar to traditional GDI (Windows only!).", + "Only applicable to `directwrite` mode, should render fonts similar to ClearType \"natural quality\" GDI (Windows only!).", + "Force ClearType antialiasing when disabled at system level (Windows only!).", + "Don't round glyph widths for monospace fonts when `font_size` is small (Mac only!)." + ] + }, + "default": [] + }, + "theme_font_options": { + "markdownDescription": "Options for theme text font.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "no_antialias", + "gray_antialias", + "no_liga", + "no_clig", + "no_calt", + "dlig", + "ss01", + "ss02", + "ss03", + "ss04", + "ss05", + "ss06", + "ss07", + "ss08", + "ss09", + "ss10", + "directwrite", + "gdi", + "dwrite_cleartype_classic", + "dwrite_cleartype_natural", + "subpixel_antialias", + "no_round" + ], + "markdownEnumDescriptions": [ + "Disable antialiasing.", + "Use grayscale antialiasing instead of subpixel.", + "Disable standard ligatures (OpenType liga feature).", + "Disable contextual ligatures (OpenType clig feature).", + "Disable contextual alternatives (OpenType calt feature).", + "Enable discretionary ligatures (OpenType dlig feature).", + "Enable OpenType stylistic set 1.", + "Enable OpenType stylistic set 2.", + "Enable OpenType stylistic set 3.", + "Enable OpenType stylistic set 4.", + "Enable OpenType stylistic set 5.", + "Enable OpenType stylistic set 6.", + "Enable OpenType stylistic set 7.", + "Enable OpenType stylistic set 8.", + "Enable OpenType stylistic set 9.", + "Enable OpenType stylistic set 10.", + "Use DirectWrite for font rendering (default, Windows only!).", + "Use GDI for font rendering (Windows only!).", + "Only applicable to `directwrite` mode, should render fonts similar to traditional GDI (Windows only!).", + "Only applicable to `directwrite` mode, should render fonts similar to ClearType \"natural quality\" GDI (Windows only!).", + "Force ClearType antialiasing when disabled at system level (Windows only!).", + "Don't round glyph widths for monospace fonts when `font_size` is small (Mac only!)." + ] + }, + "default": [] + }, + "word_separators": { + "markdownDescription": "Characters that are considered to separate words.", + "type": "string", + "default": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?" + }, + "line_numbers": { + "markdownDescription": "Set to `false` to prevent line numbers being drawn in the gutter.", + "type": "boolean", + "default": true + }, + "gutter": { + "markdownDescription": "Set to `false` to hide the gutter altogether.", + "type": "boolean", + "default": true + }, + "margin": { + "markdownDescription": "Spacing between the gutter and the text.", + "type": "integer", + "default": 4 + }, + "fold_buttons": { + "markdownDescription": "Fold buttons are the triangles shown in the gutter to fold regions of text.", + "type": "boolean", + "default": true + }, + "fade_fold_buttons": { + "markdownDescription": "Hides the fold buttons unless the mouse is over the gutter.", + "type": "boolean", + "default": true + }, + "mini_diff": { + "markdownDescription": "Indicate modified lines in the gutter.", + "enum": [true, false, "auto"], + "markdownEnumDescriptions": [ + "Enable modified line indicators on all files.", + "Disable modified line indicators.", + "Enable modified line indicators on tracked files within Git." + ], + "default": "auto" + }, + "rulers": { + "markdownDescription": "Columns in which to display vertical rulers.", + "type": "array", + "uniqueItems": true, + "items": {"type": "integer"}, + "default": [] + }, + "spell_check": { + "markdownDescription": "Set to true to turn spell checking on by default.", + "type": "boolean", + "default": false + }, + "tab_size": { + "markdownDescription": "The number of spaces a tab is considered equal to.", + "type": "integer", + "default": 4 + }, + "translate_tabs_to_spaces": { + "markdownDescription": "Set to true to insert spaces when tab is pressed.", + "type": "boolean", + "default": false + }, + "use_tab_stops": { + "markdownDescription": "If `translate_tabs_to_spaces` is true, use_tab_stops will make tab and backspace insert/delete up to the next tabstop.", + "type": "boolean", + "default": true + }, + "detect_indentation": { + "markdownDescription": "Set to `false` to disable detection of tabs vs. spaces on load.", + "type": "boolean", + "default": true + }, + "auto_indent": { + "markdownDescription": "Calculates indentation automatically when pressing enter.", + "type": "boolean", + "default": true + }, + "smart_indent": { + "markdownDescription": "Makes auto indent a little smarter, e.g., by indenting the next line after an if statement in C. Requires `auto_indent` to be enabled.", + "type": "boolean", + "default": true + }, + "indent_to_bracket": { + "markdownDescription": "Adds whitespace up to the first open bracket when indenting. Requires `auto_indent` to be enabled.", + "type": "boolean", + "default": false + }, + "trim_automatic_white_space": { + "markdownDescription": "Trims white space added by `auto_indent` when moving the caret off the line.", + "type": "boolean", + "default": true + }, + "word_wrap": { + "markdownDescription": "Disables horizontal scrolling if enabled.", + "enum": [true, false, "auto"], + "markdownEnumDescriptions": [ + "Enable word wrap.", + "Disable word wrap.", + "Enable word wrap for source code and disable it otherwise." + ], + "default": "auto" + }, + "wrap_width": { + "markdownDescription": "Set to a value other than `0` to force wrapping at that column rather than the window width.", + "type": "integer", + "default": 0 + }, + "indent_subsequent_lines": { + "markdownDescription": "Set to `false` to prevent word wrapped lines from being indented to the same level", + "type": "boolean", + "default": true + }, + "draw_centered": { + "markdownDescription": "Draws text centered in the window rather than left aligned.", + "type": "boolean", + "default": false + }, + "auto_match_enabled": { + "markdownDescription": "Controls auto pairing of quotes, brackets etc.", + "type": "boolean", + "default": true + }, + "auto_close_tags": { + "markdownDescription": "Automatically close HTML and XML tags when `