Skip to content

Instantly share code, notes, and snippets.

@aaltat
Created May 8, 2020 11:40
Show Gist options
  • Save aaltat/acb0651c6b4a3d0451921132ac7bfd53 to your computer and use it in GitHub Desktop.
Save aaltat/acb0651c6b4a3d0451921132ac7bfd53 to your computer and use it in GitHub Desktop.
Robot Framework tmLanguage
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"fileTypes": [
"robot"
],
"repository": {
"settings_table": {
"begin": "(?i)^(\\*+ ?(?:Settings|Setting)[ *]*)(?= {2,}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "entity.name.type.class.robot"
}
},
"end": "^(?=\\*)",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#documentation"
},
{
"include": "#settings_table_setting"
},
{
"include": "#settings_table_setting_keywordCalls"
},
{
"include": "#settings_table_setting_imports"
}
],
"name": "meta.table.settings.robot"
},
"settings_table_setting": {
"begin": "(?i)^(Force Tags|Default Tags|Test Timeout|Task Timeout)(?= {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "storage.type.setting.robot"
}
},
"contentName": "string.quoted.single.robot",
"end": "^(?!\\s*\\.\\.\\.)",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.setting.documentation.robot"
},
"settings_table_setting_imports": {
"begin": "(?i)^(Library|Resource|Variables|Metadata)(?: {2,}| ?\\t)+(.*?)(?= {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "storage.type.setting.robot"
},
"2": {
"name": "entity.other.inherited-class.robot"
}
},
"end": "^(?!\\s*\\.\\.\\.)",
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
},
{
"include": "#named_argument"
}
],
"name": "meta.setting.imports.robot"
},
"settings_table_setting_keywordCalls": {
"begin": "(?i)^(Suite Setup|Suite Teardown|Test Setup|Task Setup|Test Teardown|Task Teardown|Test Template|Task Template)(?: {2,}| ?\\t)+(.*?)(?= {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "storage.type.setting.robot"
},
"2": {
"name": "support.function.robot"
}
},
"end": "^(?!\\s*\\.\\.\\.)",
"contentName": "constant.other.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
},
{
"include": "#named_argument"
}
],
"name": "meta.setting.kwcalls.robot"
},
"documentation": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "(?i)^(Documentation)(?= {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "storage.type.method.robot"
}
},
"contentName": "string.quoted.tripple.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#line_continuation"
}
],
"name": "meta.documentation.robot"
},
"variables_table": {
"begin": "(?i)^(\\*+ ?(?:Variables|Variable)[ *]*)(?= {2,}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "entity.name.type.class.robot"
}
},
"end": "^(?=\\*)",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#variable_assign"
},
{
"include": "#line_continuation"
}
],
"name": "meta.table.variables.robot"
},
"variable_assign": {
"begin": "^(?:([$@&%]\\{)(.+?}*)(\\})( ?=)?)",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "variable.parameter.robot"
},
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "keyword.operator.robot"
}
},
"contentName": "string.quoted.single.robot",
"end": "^(?!\\s*\\.\\.\\.)",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#line_continuation"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
}
],
"name": "meta.variable.assign.robot"
},
"test_cases_table": {
"begin": "(?i)^(\\*+ ?(?:Test Cases|Test Case|Tasks|Task)[ *]*)(?= {2,}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "entity.name.type.class.robot"
}
},
"end": "^(?=\\*)",
"patterns": [
{
"include": "#function_declaration"
},
{
"include": "#fuction_documentation"
},
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#BDD_keyword_call"
},
{
"include": "#returning_keyword_call"
},
{
"include": "#for_loop"
},
{
"include": "#ELSE_IF"
},
{
"include": "#ELSE"
},
{
"include": "#run_keyword_if"
},
{
"include": "#line_continuation"
},
{
"include": "#variables"
},
{
"include": "#function_tags"
},
{
"include": "#function_timeout"
},
{
"include": "#function_setup"
},
{
"include": "#function_teardown"
},
{
"include": "#function_template"
},
{
"include": "#keyword_call"
},
{
"include": "#named_argument"
}
],
"name": "meta.table.testcases.robot"
},
"keywords_table": {
"begin": "(?i)^(\\*+ ?(?:Keywords|Keyword)[ *]*)(?= {2,}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "entity.name.type.class.robot"
}
},
"end": "^(?=\\*)",
"patterns": [
{
"include": "#function_declaration"
},
{
"include": "#fuction_documentation"
},
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#for_loop"
},
{
"include": "#returning_keyword_call"
},
{
"include": "#BDD_keyword_call"
},
{
"include": "#ELSE_IF"
},
{
"include": "#ELSE"
},
{
"include": "#run_keyword_if"
},
{
"include": "#line_continuation"
},
{
"include": "#variables"
},
{
"include": "#function_tags"
},
{
"include": "#keyword_arguments"
},
{
"include": "#function_return"
},
{
"include": "#function_timeout"
},
{
"include": "#function_teardown"
},
{
"include": "#keyword_call"
},
{
"include": "#named_argument"
}
],
"name": "meta.table.keywords.robot"
},
"comments_table": {
"end": "^(?=\\*)",
"begin": "(?i)^(\\*+\\s*comments?[\\s*].*)",
"beginCaptures": {
"1": {
"name": "entity.name.type.class.robot"
}
},
"contentName": "comment.line.robot",
"name": "meta.table.comments.robot"
},
"variables": {
"match": "(?i)(?:(?:(?<!^)(?<!\\\\)|(?<=\\\\\\\\))([$@&%]\\{)(?:((?:\\d+\\.?\\d*)|(?:0x[\/da-f]+)|(?:0o[0-7]+)|(?:0b[01]+))|(true|false|none|null|empty|space|\/|:|\\\\n)|((.+?}*)))(\\})(?:(\\[)(?:(\\d+)|(.*?))?(\\]))?)",
"captures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "constant.numeric.robot"
},
"3": {
"name": "constant.language.robot"
},
"4": {
"name": "constant.other.robot"
},
"5": {
"name": "variable.other.robot"
},
"6": {
"name": "keyword.operator.robot"
},
"7": {
"name": "keyword.operator.robot"
},
"8": {
"name": "constant.numeric.robot"
},
"9": {
"name": "variable.other.robot"
},
"10": {
"name": "keyword.operator.robot"
}
},
"name": "meta.variables.robot"
},
"BDD_keyword_call": {
"begin": "(?i)^(?=(?: {2,}| ?\\t ?)+(?:given |when |then |and |but )[^\\s])(?:\\s)",
"contentName": "string.quoted.single.robot",
"end": "^(?!\\s*\\.\\.\\.)",
"patterns": [
{
"include": "#BDD_keyword"
},
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
}
],
"name": "meta.bdd.keyword.robot"
},
"BDD_keyword": {
"begin": "(?i)(?<=^\\s)(?:\\s+)(?=(?:given|when|then|and|but))",
"contentName": "keyword.operator.robot",
"end": "(?: )(.*?)(?: {2,}| ?\\t+| ?$)",
"patterns": [
{
"include": "#escape"
},
{
"include": "#parameter"
},
{
"include": "#line_continuation"
},
{
"include": "#comment"
}
],
"name": "meta.bdd.keyword.body.robot",
"endCaptures": {
"1": {
"name": "support.function.robot"
}
}
},
"run_keyword_if": {
"end": "(?: | ?\\t| ?$)",
"begin": "(?i)^(?:\\s)+((?:Run Keyword If)|(?:Run Keyword Unless))(?:(?: {2,})|(?: ?\\t))+(.*?)?(?: | ?\\t| ?$)+(.*?)?(?: | ?\\t| ?$)+",
"beginCaptures": {
"1": {
"name": "keyword.control.robot"
},
"2": {
"name": "string.interpolated.robot"
},
"3": {
"name": "support.function.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.runkeywordif.robot"
},
"ELSE_IF": {
"end": "(?: | ?\\t| ?$)",
"begin": "(?m)(?:(^\\s*\\.\\.\\.(?: {2,}| ?\\t))|(?: {2,}| ?\\t))(ELSE IF)(?:(?:(?: {2,})|(?: ?\\t)|(\\s*\\.\\.\\.\\s))+(.*?))?(?:(?:(?: {2,})|(?: ?\\t)|(\\s*\\.\\.\\.\\s))+(.*?))?(?: | ?\\t| ?$)+",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "keyword.control.robot"
},
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "string.interpolated.robot"
},
"5": {
"name": "keyword.operator.robot"
},
"6": {
"name": "support.function.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.else.if.robot"
},
"ELSE": {
"end": "(?: | ?\\t| ?$)",
"begin": "(?m)(?:(^\\s*\\.\\.\\.(?: {2,}| ?\\t))|(?: {2,}| ?\\t))(ELSE)(?:(?:(?: {2,})|(?: ?\\t)|(\\s*\\.\\.\\.\\s))+(.*?))?(?: | ?\\t| ?$)+",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "keyword.control.robot"
},
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "support.function.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.else.robot"
},
"function_declaration": {
"end": "(?= {2}| ?\\t| ?$)",
"begin": "^(?=[^ \\t\\*\\n\\|#]+)",
"contentName": "entity.name.function.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
}
],
"name": "meta.function.declaration.robot"
},
"function_template": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "(?i)^(?:\\s)+(\\[)(template)(\\])(?: {2}| ?\\t| ?$)(?:\\s)*(.*?)(?: {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
},
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "support.function.robot"
}
},
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.template.robot"
},
"function_tags": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "^(?i)(?:\\s)+(\\[)(tags)(\\])",
"beginCaptures": {
"3": {
"name": "keyword.operator.robot"
},
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
}
},
"contentName": "entity.name.tag.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.tags.robot"
},
"function_setup": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "(?i)^(?:\\s)+(\\[)(setup)(\\])(?: {2}| ?\\t| ?$)(?:\\s)*(.*?)(?: {2}| ?\\t| ?$)",
"beginCaptures": {
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "support.function.robot"
},
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.setup.robot"
},
"function_timeout": {
"begin": "^(?i)(?:\\s)+(\\[)(timeout)(\\])",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
},
"3": {
"name": "keyword.operator.robot"
}
},
"end": "^(?!\\s*\\.\\.\\.)",
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.timeout.robot"
},
"fuction_documentation": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "(?i)^(?: {2,}| ?\\t ?)+(\\[)(Documentation)(\\])(?= {2}| ?\\t| ?$)",
"beginCaptures": {
"3": {
"name": "keyword.operator.robot"
},
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
}
},
"contentName": "string.quoted.tripple.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#line_continuation"
}
],
"name": "meta.documentation.robot"
},
"function_teardown": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "(?i)^(?:\\s)+(\\[)(teardown)(\\])(?: {2}| ?\\t| ?$)(?:\\s)*(.*?)(?: {2}| ?\\t| ?$)",
"beginCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
},
"3": {
"name": "keyword.operator.robot"
},
"4": {
"name": "support.function.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.teardown.robot"
},
"function_return": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "^(?i)(?:\\s)+(\\[)(return)(\\])",
"beginCaptures": {
"3": {
"name": "keyword.operator.robot"
},
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.return.robot"
},
"comment": {
"match": "(?:^ ?|\\t+| {2,})(#.*)$",
"captures": {
"1": {
"name": "comment.line.robot"
}
},
"name": "meta.comment.robot"
},
"escape": {
"match": "(?:\\\\\\\\)*(\\\\.?)",
"captures": {
"1": {
"name": "constant.character.escape"
}
},
"name": "meta.escape.robot"
},
"for_loop": {
"begin": "^(?=(?: {2,}| ?\\t ?)+(?:FOR))",
"contentName": "meta.keyword.control.robot",
"end": "^(?: {2,}| ?\\t ?)(END)",
"patterns": [
{
"include": "#for_header"
},
{
"include": "#keyword_call"
},
{
"include": "#returning_keyword_call"
},
{
"include": "#escape"
},
{
"include": "#comment"
}
],
"name": "meta.for.loop.robot",
"endCaptures": {
"1": {
"name": "keyword.control.robot"
}
}
},
"for_header": {
"begin": "^(?: {2,}| ?\\t ?)+(FOR)",
"beginCaptures": {
"1": {
"name": "keyword.control.robot"
}
},
"contentName": "meta.keyword.control.robot",
"end": "^(?!\\s*\\.\\.\\.)",
"patterns": [
{
"include": "#for_operator"
},
{
"include": "#parameter"
},
{
"include": "#line_continuation"
},
{
"include": "#escape"
},
{
"include": "#comment"
}
],
"name": "meta.for.header.robot"
},
"for_operator": {
"begin": "(?<=\\s)(IN ENUMERATE|IN RANGE|IN ZIP|IN)",
"beginCaptures": {
"1": {
"name": "keyword.control.robot"
}
},
"contentName": "meta.keyword.control.robot",
"end": "^(?!\\s*\\.\\.\\.)",
"patterns": [
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
},
{
"include": "#escape"
},
{
"include": "#comment"
}
],
"name": "meta.for.header.operator.robot"
},
"keyword_call": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "^(?!(?: {2,}| ?\\t ?)+(?:(?=[$\\[@&%]|\\.)))(?: {2,}| ?\\t ?)+(.*?)(?= {2,}| ?\\t ?| ?$)",
"beginCaptures": {
"1": {
"name": "support.function.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
}
],
"name": "meta.keyword.call.robot"
},
"keyword_arguments": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "^(?i)(?:\\s)+(\\[)(arguments)(\\])",
"beginCaptures": {
"3": {
"name": "keyword.operator.robot"
},
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "storage.type.method.robot"
}
},
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#escape"
},
{
"include": "#comment"
},
{
"include": "#parameter"
},
{
"include": "#line_continuation"
}
],
"name": "meta.function.doc.arguments.robot"
},
"parameter": {
"match": "(?:(?<!\\\\)|(?<=\\\\\\\\))([$@&]\\{)(?:(.+?}*))(\\})",
"captures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "variable.parameter.robot"
},
"3": {
"name": "keyword.operator.robot"
}
},
"name": "meta.parameter.robot"
},
"named_argument": {
"match": "((?<=[\\s|])[^ |\\t=]*)((?<!\\\\)=)(?=[^\\s=])",
"captures": {
"1": {
"name": "variable.parameter.robot"
},
"2": {
"name": "keyword.operator.robot"
}
},
"name": "meta.named.argument.robot"
},
"returning_keyword_call": {
"end": "^(?!\\s*\\.\\.\\.)",
"begin": "^(?=(?: {2,}| ?\\t ?)+(?:(?=[$@&])))(?:\\s)",
"contentName": "string.quoted.single.robot",
"patterns": [
{
"include": "#variable_assignment_from_kw"
},
{
"include": "#variables"
},
{
"include": "#named_argument"
},
{
"include": "#line_continuation"
},
{
"include": "#escape"
},
{
"include": "#comment"
}
],
"name": "meta.returning.keyword.robot"
},
"variable_assignment_from_kw": {
"name": "meta.variable.assignment.keyword.robot",
"begin": "(?<=^\\s)(?:\\s*)(?=[$@&])",
"contentName": "support.function.robot",
"end": "( ?=)?(?: {2,}| ?\\t+ ?| ?$)(?!\\.\\.\\.)([^#$@& \\n\\r].*?)(?: {2,}| ?\\t+| ?$)",
"endCaptures": {
"1": {
"name": "keyword.operator.robot"
},
"2": {
"name": "support.function.robot"
}
},
"patterns": [
{
"include": "#parameter"
},
{
"include": "#line_continuation"
},
{
"include": "#escape"
},
{
"include": "#comment"
}
]
},
"line_continuation": {
"match": "^(\\s*\\.\\.\\.)(?: {2,}| ?\\t+| ?$)(?!ELSE)",
"name": "keyword.operator.robot"
}
},
"uuid": "a7fae509-bc8d-451e-b5fc-a47feb9d2a9e",
"patterns": [
{
"include": "#escape"
},
{
"include": "#settings_table"
},
{
"include": "#variables_table"
},
{
"include": "#test_cases_table"
},
{
"include": "#keywords_table"
},
{
"include": "#comment"
},
{
"include": "#comments_table"
}
],
"name": "Robot Framework",
"scopeName": "source.robot"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment