diff --git a/package.json b/package.json index 2828c60..acc1446 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,16 @@ "light": "./icons/fauna.svg", "dark": "./icons/fauna-light.svg" } + }, + { + "id": "fsl", + "extensions": [ + ".fsl" + ], + "icon": { + "light": "./icons/fauna.svg", + "dark": "./icons/fauna-light.svg" + } } ], "grammars": [ @@ -115,6 +125,11 @@ "language": "fql", "scopeName": "source.fql", "path": "./syntax/fql.tmGrammar.json" + }, + { + "language": "fsl", + "scopeName": "source.fsl", + "path": "./syntax/fsl.tmGrammar.json" } ], "keybindings": [ diff --git a/syntax/fsl.tmGrammar.json b/syntax/fsl.tmGrammar.json new file mode 100644 index 0000000..437c434 --- /dev/null +++ b/syntax/fsl.tmGrammar.json @@ -0,0 +1,155 @@ +{ + "name": "fsl", + "scopeName": "source.fsl", + "patterns": [ + { + "comment": "Single-line comment", + "name": "comment.line.double-slash.fsl", + "begin": "//", + "end": "$" + }, + { + "include": "#block_comment" + }, + { + "comment": "Function body", + "name": "constant.function.fsl", + "begin": "\\b(function)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([\\S\\s]*\\)\\s*(:[\\S\\s]*)?\\s*{", + "end": "}", + "captures": { + "1": { + "name": "keyword.control.fsl" + }, + "2": { + "name": "entity.name.function.fsl" + } + }, + "patterns": [ + { + "include": "source.fql" + } + ] + }, + { + "comment": "Schema block", + "name": "constant.block.fsl", + "match": "\\b(collection|role|index|privileges|membership|(access\\s+provider))\\b(\\s+[a-zA-Z_][a-zA-Z0-9_]*)?", + "captures": { + "1": { + "name": "keyword.control.fsl" + }, + "3": { + "name": "entity.name.type.fsl" + } + } + }, + { + "comment": "Keyword", + "name": "keyword.control.fsl", + "match": "\\b(collection|function|role|access|provider|index|privileges|membership)\\b" + }, + { + "comment": "Action keyword", + "name": "variable.other.constant.property", + "match": "\\b(create|delete|read|write|call|history_read|history_write|unrestricted_read)\\b" + }, + { + "comment": "Field keyword", + "name": "variable.other.property", + "match": "\\b(terms|values|unique|predicate|history_days|ttl_days|issuer|jwks_uri)\\b" + }, + { + "include": "#single_string_literal" + }, + { + "include": "#double_string_literal" + }, + { + "comment": "Floating point literal (fraction)", + "name": "constant.numeric.float.fsl", + "match": "\\b[+-]?[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9][0-9_]*)?\\b" + }, + { + "comment": "Floating point literal (exponent)", + "name": "constant.numeric.float.fsl", + "match": "\\b[+-]?[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9][0-9_]*\\b" + }, + { + "comment": "Integer literal (decimal)", + "name": "constant.numeric.integer.decimal.fsl", + "match": "\\b[+-]?[0-9][0-9_]*\\b" + }, + { + "comment": "Integer literal (hexadecimal)", + "name": "constant.numeric.integer.hexadecimal.fsl", + "match": "\\b[+-]?0[xX][0-9a-fA-F_]+\\b" + }, + { + "comment": "Integer literal (octal)", + "name": "constant.numeric.integer.octal.fsl", + "match": "\\b[+-]?0[oO][0-7_]+\\b" + }, + { + "comment": "Integer literal (binary)", + "name": "constant.numeric.integer.binary.fsl", + "match": "\\b[+-]?0[bB][01_]+\\b" + }, + { + "comment": "Boolean constant", + "name": "constant.language.boolean.fsl", + "match": "\\b(true|false)\\b" + }, + { + "comment": "Null constant", + "name": "constant.language.null.fsl", + "match": "\\bnull\\b" + } + ], + "repository": { + "block_comment": { + "comment": "Block comment", + "name": "comment.block.fsl", + "begin": "/\\*", + "end": "\\*/", + "patterns": [ + { + "include": "#block_comment" + } + ] + }, + "escaped_character": { + "name": "constant.character.escape.fsl", + "match": "\\\\([\\\\0'\"`nrvtbf#]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{2}|u\\{[01]0[0-9a-fA-F]{0,4}\\}|u\\{[0-9a-fA-F]{1,4}\\})" + }, + "interpolated_value": { + "name": "constant.character.escape.fsl", + "begin": "#{", + "end": "}" + }, + "single_string_literal": { + "comment": "String literal (single quotes)", + "name": "string.quoted.single.fsl", + "begin": "'", + "end": "'", + "patterns": [ + { + "include": "#escaped_character" + } + ] + }, + "double_string_literal": { + "comment": "String literal (double quotes)", + "name": "string.quoted.double.fsl", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "#escaped_character" + }, + { + "include": "#interpolated_value" + } + ] + } + } +}