export const languageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { lineComment: '#', }, brackets: [ ['{', '}'], ['[', ']'], ], autoClosingPairs: [ { open: '{', close: '}' }, { open: '[', close: ']' }, { open: '"', close: '"' }, { open: "'", close: "'" }, ], surroundingPairs: [ { open: '{', close: '}' }, { open: '[', close: ']' }, { open: '"', close: '"' }, { open: "'", close: "'" }, ], folding: { offSide: true, }, }; // YAML keywords const keywords = ['true', 'false', 'null', 'True', 'False', 'Null', 'TRUE', 'FALSE', 'NULL', 'yes', 'no', 'Yes', 'No', 'YES', 'NO', 'on', 'off', 'On', 'Off', 'ON', 'OFF']; // YAML operators and special characters (for future use) // const operators = [':', '-', '|', '>', '&', '*', '!', '%', '@']; export const language = { tokenPostfix: '.yaml', brackets: [ { token: 'delimiter.bracket', open: '{', close: '}' }, { token: 'delimiter.square', open: '[', close: ']' }, ], keywords: keywords, numberInteger: /(?:0|[+-]?[0-9]+)/, numberFloat: /(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/, numberOctal: /0o[0-7]+/, numberHex: /0x[0-9a-fA-F]+/, numberInfinity: /[+-]?\.(?:inf|Inf|INF)/, numberNaN: /\.(?:nan|Nan|NAN)/, numberDate: /\d{4}-\d{2}-\d{2}(?:[Tt ]\d{1,2}:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d{1,2}(?::\d{2})?))?)?/, escapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/, tokenizer: { root: [ { include: '@whitespace' }, { include: '@comment' }, // Document markers [/^---/, 'meta.document'], [/^\.{3}/, 'meta.document'], // Keys (property names) [/^(\s*)([^:\s]+)(\s*)(:)/, ['white', 'key', 'white', 'delimiter']], [/(\s*)([^:\s]+)(\s*)(:)/, ['white', 'key', 'white', 'delimiter']], // Flow collections [/\{/, '@brackets', '@flowMap'], [/\[/, '@brackets', '@flowSequence'], // Block scalars [/[|>][-+]?(\d+)?/, 'string.block', '@blockScalar'], // Numbers [/@numberInfinity/, 'number.infinity'], [/@numberNaN/, 'number.nan'], [/@numberDate/, 'number.date'], [/@numberHex/, 'number.hex'], [/@numberOctal/, 'number.octal'], [/@numberFloat/, 'number.float'], [/@numberInteger/, 'number'], // Strings [/"([^"\\]|\\.)*$/, 'string.invalid'], [/'([^'\\]|\\.)*$/, 'string.invalid'], [/"/, 'string', '@doubleQuotedString'], [/'/, 'string', '@singleQuotedString'], // Anchors and aliases [/&\w+/, 'tag.anchor'], [/\*\w+/, 'tag.alias'], // Tags [/![\w\-\/]+/, 'tag'], // Keywords [ /[^\s\[\{\,]+/, { cases: { '@keywords': 'keyword', '@default': 'string.unquoted', }, }, ], // List items [/^(\s*)(-\s)/, ['white', 'delimiter']], [/(\s*)(-\s)/, ['white', 'delimiter']], ], whitespace: [[/[ \t\r\n]+/, 'white']], comment: [[/#.*$/, 'comment']], doubleQuotedString: [ [/[^\\"]+/, 'string'], [/@escapes/, 'string.escape'], [/\\./, 'string.escape.invalid'], [/"/, 'string', '@pop'], ], singleQuotedString: [ [/[^\\']+/, 'string'], [/''/, 'string.escape'], [/'/, 'string', '@pop'], ], blockScalar: [ [/^(\s*).+$/, 'string.block'], [/^(?!\s)/, '', '@pop'], ], flowMap: [ { include: '@whitespace' }, { include: '@comment' }, [/\}/, '@brackets', '@pop'], [/,/, 'delimiter'], [/:/, 'delimiter'], [/"/, 'string', '@doubleQuotedString'], [/'/, 'string', '@singleQuotedString'], [/[^\s\,\}\:]+/, 'string.unquoted'], ], flowSequence: [ { include: '@whitespace' }, { include: '@comment' }, [/\]/, '@brackets', '@pop'], [/,/, 'delimiter'], [/"/, 'string', '@doubleQuotedString'], [/'/, 'string', '@singleQuotedString'], [/[^\s\,\]]+/, 'string.unquoted'], ], }, };