diff --git a/README.md b/README.md index 5269bca..13db763 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - Syntax highlighting - Bracket matching +- Indentation rules - YAML versions [1.2](https://yaml.org/spec/1.2.2), [1.1](https://yaml.org/spec/1.1/), [1.0](https://yaml.org/spec/1.0/) and [1.3](https://spec.yaml.io/main/spec/1.3.0/) @@ -14,6 +15,6 @@ - Previously known [Issues](https://github.com/RedCMD/YAML-Syntax-Highlighter/issues/1) - Original YAML [grammar](https://github.com/textmate/yaml.tmbundle) - Atom's YAML [grammar](https://github.com/atom/language-yaml) -- Offical YAML [website](https://yaml.org/) +- Official YAML [website](https://yaml.org/) - Github [repo](https://github.com/RedCMD/YAML-Syntax-Highlighter) - Marketplace [extension](https://marketplace.visualstudio.com/items?itemName=RedCMD.yaml-syntax) \ No newline at end of file diff --git a/language-configuration.json b/language-configuration.json index 8b0f5ba..687517b 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -32,6 +32,7 @@ ["{", "}"], ["[", "]"] ], + // markers that can be folded "folding": { "offSide": true, "markers": { @@ -39,8 +40,122 @@ "end": "^[ \t]*#[ \t]*endregion\\b|^\\.{3}[ \t]*(#.*)?$" } }, - "indentationRules": { - "increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\[[^\\]\"']*)?$", - "decreaseIndentPattern": "^\\s+[\\]\\}]$" - } + // Only the first successful rule is chosen + "onEnterRules": [ + { + // indent 1 space after block-scalar with indentation-indicator + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?1" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?2" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?3" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?4" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?5" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?6" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?7" + }, + { + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?8" + }, + { + // indent 9 spaces after block-scalar with indentation-indicator + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "([ \t]+|^)[|>][+-]?9" + }, + { + // - block-map: # with an empty value OR block-scalar. Prefixed with a block-seq + "action": { + "appendText": " ", + "indent": "none" + }, + "beforeText": "(^| |\t)-[ \t]+[^#,\\[\\]{}].*:(([ \t]+[|>][+-]?)?([ \t]+#.*)?|[ \t]*)$" + }, + { + // indent 2 spaces after non-root block-scalar + "action": { + "appendText": " ", + "indent": "none", + }, + "afterText": "^(?![ \t]*#)", + "beforeText": "[-?:][ \t]+[|>][+-]?[ \t]*(#.*)?$" + }, + { + // block-map: cursor_must_be_before_value + "action": { + "appendText": " ", + "indent": "none" + }, + "beforeText": "(?