Add prettier

This commit is contained in:
Alex Dima 2020-09-02 17:44:31 +02:00
parent 1ca4a3a0aa
commit 3efc637414
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
156 changed files with 51562 additions and 37461 deletions

View file

@ -11,7 +11,7 @@ import ILanguage = monaco.languages.IMonarchLanguage;
export const conf: IRichLanguageConfiguration = {
comments: {
lineComment: '//',
blockComment: ['/*', '*/'],
blockComment: ['/*', '*/']
},
brackets: [
['{', '}'],
@ -22,20 +22,20 @@ export const conf: IRichLanguageConfiguration = {
{ open: '[', close: ']' },
{ open: '{', close: '}' },
{ open: '(', close: ')' },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '"', close: '"', notIn: ['string'] },
{ open: "'", close: "'", notIn: ['string', 'comment'] },
{ open: '"', close: '"', notIn: ['string'] }
],
surroundingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
{ open: "'", close: "'" }
],
folding: {
markers: {
start: new RegExp("^\\s*#pragma\\s+region\\b"),
end: new RegExp("^\\s*#pragma\\s+endregion\\b")
start: new RegExp('^\\s*#pragma\\s+region\\b'),
end: new RegExp('^\\s*#pragma\\s+endregion\\b')
}
}
};
@ -44,52 +44,221 @@ export const language = <ILanguage>{
tokenPostfix: '.rust',
defaultToken: 'invalid',
keywords: [
'as', 'box', 'break', 'const', 'continue', 'crate', 'else', 'enum',
'extern', 'false', 'fn', 'for', 'if', 'impl', 'in', 'let', 'loop',
'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return', 'self',
'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use',
'where', 'while', 'catch', 'default', 'union', 'static', 'abstract',
'alignof', 'become', 'do', 'final', 'macro', 'offsetof', 'override',
'priv', 'proc', 'pure', 'sizeof', 'typeof', 'unsized', 'virtual',
'yield',
'as',
'box',
'break',
'const',
'continue',
'crate',
'else',
'enum',
'extern',
'false',
'fn',
'for',
'if',
'impl',
'in',
'let',
'loop',
'match',
'mod',
'move',
'mut',
'pub',
'ref',
'return',
'self',
'static',
'struct',
'super',
'trait',
'true',
'type',
'unsafe',
'use',
'where',
'while',
'catch',
'default',
'union',
'static',
'abstract',
'alignof',
'become',
'do',
'final',
'macro',
'offsetof',
'override',
'priv',
'proc',
'pure',
'sizeof',
'typeof',
'unsized',
'virtual',
'yield'
],
typeKeywords: [
'Self', 'm32', 'm64', 'm128', 'f80', 'f16', 'f128', 'int', 'uint',
'float', 'char', 'bool', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64', 'i8',
'i16', 'i32', 'i64', 'str', 'Option', 'Either', 'c_float', 'c_double',
'c_void', 'FILE', 'fpos_t', 'DIR', 'dirent', 'c_char', 'c_schar',
'c_uchar', 'c_short', 'c_ushort', 'c_int', 'c_uint', 'c_long',
'c_ulong', 'size_t', 'ptrdiff_t', 'clock_t', 'time_t', 'c_longlong',
'c_ulonglong', 'intptr_t', 'uintptr_t', 'off_t', 'dev_t', 'ino_t',
'pid_t', 'mode_t', 'ssize_t',
'Self',
'm32',
'm64',
'm128',
'f80',
'f16',
'f128',
'int',
'uint',
'float',
'char',
'bool',
'u8',
'u16',
'u32',
'u64',
'f32',
'f64',
'i8',
'i16',
'i32',
'i64',
'str',
'Option',
'Either',
'c_float',
'c_double',
'c_void',
'FILE',
'fpos_t',
'DIR',
'dirent',
'c_char',
'c_schar',
'c_uchar',
'c_short',
'c_ushort',
'c_int',
'c_uint',
'c_long',
'c_ulong',
'size_t',
'ptrdiff_t',
'clock_t',
'time_t',
'c_longlong',
'c_ulonglong',
'intptr_t',
'uintptr_t',
'off_t',
'dev_t',
'ino_t',
'pid_t',
'mode_t',
'ssize_t'
],
constants: [
'true', 'false', 'Some', 'None', 'Left', 'Right', 'Ok', 'Err',
],
constants: ['true', 'false', 'Some', 'None', 'Left', 'Right', 'Ok', 'Err'],
supportConstants: [
'EXIT_FAILURE', 'EXIT_SUCCESS', 'RAND_MAX', 'EOF', 'SEEK_SET',
'SEEK_CUR', 'SEEK_END', '_IOFBF', '_IONBF', '_IOLBF', 'BUFSIZ',
'FOPEN_MAX', 'FILENAME_MAX', 'L_tmpnam', 'TMP_MAX', 'O_RDONLY',
'O_WRONLY', 'O_RDWR', 'O_APPEND', 'O_CREAT', 'O_EXCL', 'O_TRUNC',
'S_IFIFO', 'S_IFCHR', 'S_IFBLK', 'S_IFDIR', 'S_IFREG', 'S_IFMT',
'S_IEXEC', 'S_IWRITE', 'S_IREAD', 'S_IRWXU', 'S_IXUSR', 'S_IWUSR',
'S_IRUSR', 'F_OK', 'R_OK', 'W_OK', 'X_OK', 'STDIN_FILENO',
'STDOUT_FILENO', 'STDERR_FILENO',
'EXIT_FAILURE',
'EXIT_SUCCESS',
'RAND_MAX',
'EOF',
'SEEK_SET',
'SEEK_CUR',
'SEEK_END',
'_IOFBF',
'_IONBF',
'_IOLBF',
'BUFSIZ',
'FOPEN_MAX',
'FILENAME_MAX',
'L_tmpnam',
'TMP_MAX',
'O_RDONLY',
'O_WRONLY',
'O_RDWR',
'O_APPEND',
'O_CREAT',
'O_EXCL',
'O_TRUNC',
'S_IFIFO',
'S_IFCHR',
'S_IFBLK',
'S_IFDIR',
'S_IFREG',
'S_IFMT',
'S_IEXEC',
'S_IWRITE',
'S_IREAD',
'S_IRWXU',
'S_IXUSR',
'S_IWUSR',
'S_IRUSR',
'F_OK',
'R_OK',
'W_OK',
'X_OK',
'STDIN_FILENO',
'STDOUT_FILENO',
'STDERR_FILENO'
],
supportMacros: [
'format!', 'print!', 'println!', 'panic!', 'format_args!', 'unreachable!',
'write!', 'writeln!'
'format!',
'print!',
'println!',
'panic!',
'format_args!',
'unreachable!',
'write!',
'writeln!'
],
operators: [
'!', '!=', '%', '%=', '&', '&=', '&&', '*', '*=', '+', '+=', '-', '-=',
'->', '.', '..', '...', '/', '/=', ':', ';', '<<', '<<=', '<', '<=', '=',
'==', '=>', '>', '>=', '>>', '>>=', '@', '^', '^=', '|', '|=', '||', '_',
'?', '#'
'!',
'!=',
'%',
'%=',
'&',
'&=',
'&&',
'*',
'*=',
'+',
'+=',
'-',
'-=',
'->',
'.',
'..',
'...',
'/',
'/=',
':',
';',
'<<',
'<<=',
'<',
'<=',
'=',
'==',
'=>',
'>',
'>=',
'>>',
'>>=',
'@',
'^',
'^=',
'|',
'|=',
'||',
'_',
'?',
'#'
],
escapes: /\\([nrt0\"''\\]|x\h{2}|u\{\h{1,6}\})/,
@ -100,7 +269,8 @@ export const language = <ILanguage>{
tokenizer: {
root: [
[/[a-zA-Z][a-zA-Z0-9_]*!?|_[a-zA-Z0-9_]+/,
[
/[a-zA-Z][a-zA-Z0-9_]*!?|_[a-zA-Z0-9_]+/,
{
cases: {
'@typeKeywords': 'keyword.type',
@ -108,7 +278,7 @@ export const language = <ILanguage>{
'@supportConstants': 'keyword',
'@supportMacros': 'keyword',
'@constants': 'keyword',
'@default': 'identifier',
'@default': 'identifier'
}
}
],
@ -123,27 +293,33 @@ export const language = <ILanguage>{
{ include: '@numbers' },
// Whitespace + comments
{ include: '@whitespace' },
[/@delimiters/, {
cases: {
'@keywords': 'keyword',
'@default': 'delimiter'
[
/@delimiters/,
{
cases: {
'@keywords': 'keyword',
'@default': 'delimiter'
}
}
}],
],
[/[{}()\[\]<>]/, '@brackets'],
[/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
[
/@symbols/,
{ cases: { '@operators': 'operator', '@default': '' } }
]
],
whitespace: [
[/[ \t\r\n]+/, 'white'],
[/\/\*/, 'comment', '@comment'],
[/\/\/.*$/, 'comment'],
[/\/\/.*$/, 'comment']
],
comment: [
[/[^\/*]+/, 'comment'],
[/\/\*/, 'comment', '@push'],
["\\*/", 'comment', '@pop'],
['\\*/', 'comment', '@pop'],
[/[\/*]/, 'comment']
],
@ -159,13 +335,16 @@ export const language = <ILanguage>{
//Binary
[/(0b[0-1_]+)(@intSuffixes)?/, { token: 'number' }],
//Exponent
[/[\d][\d_]*(\.[\d][\d_]*)?[eE][+-][\d_]+(@floatSuffixes)?/, { token: 'number' }],
[
/[\d][\d_]*(\.[\d][\d_]*)?[eE][+-][\d_]+(@floatSuffixes)?/,
{ token: 'number' }
],
//Float
[/\b(\d\.?[\d_]*)(@floatSuffixes)?\b/, { token: 'number' }],
//Hexadecimal
[/(0x[\da-fA-F]+)_?(@intSuffixes)?/, { token: 'number' }],
//Integer
[/[\d][\d_]*(@intSuffixes?)?/, { token: 'number' }],
[/[\d][\d_]*(@intSuffixes?)?/, { token: 'number' }]
]
}
};