{ "name": "Elixir", "scopeName": "source.elixir", "patterns": [ { "begin": "\\b(fn)\\b(?!.*-\u003e)", "end": "$", "patterns": [ { "include": "#core_syntax" } ], "beginCaptures": { "1": { "name": "keyword.control.elixir" } } }, { "begin": "\\b(fn)\\b(?=.*-\u003e)", "end": "(?\u003e(-\u003e)|(when)|(\\)))", "patterns": [ { "include": "#core_syntax" } ], "beginCaptures": { "1": { "name": "keyword.control.elixir" } }, "endCaptures": { "1": { "name": "keyword.operator.other.elixir" }, "2": { "name": "keyword.control.elixir" }, "3": { "name": "punctuation.section.function.elixir" } } }, { "include": "#core_syntax" }, { "begin": "^(?=.*-\u003e)((?![^\"']*(\"|')[^\"']*-\u003e)|(?=.*-\u003e[^\"']*(\"|')[^\"']*-\u003e))((?!.*\\([^\\)]*-\u003e)|(?=[^\\(\\)]*-\u003e)|(?=\\s*\\(.*\\).*-\u003e))((?!.*\\b(fn)\\b)|(?=.*-\u003e.*\\bfn\\b))", "end": "(?\u003e(-\u003e)|(when)|(\\)))", "patterns": [ { "include": "#core_syntax" } ], "beginCaptures": { "1": { "name": "keyword.control.elixir" } }, "endCaptures": { "1": { "name": "keyword.operator.other.elixir" }, "2": { "name": "keyword.control.elixir" }, "3": { "name": "punctuation.section.function.elixir" } } } ], "repository": { "core_syntax": { "patterns": [ { "name": "meta.module.elixir", "begin": "^\\s*(defmodule)\\b", "end": "\\b(do)\\b", "patterns": [ { "name": "entity.name.class.elixir", "match": "\\b[A-Z]\\w*\\b" } ], "beginCaptures": { "1": { "name": "keyword.control.module.elixir" } }, "endCaptures": { "1": { "name": "keyword.control.module.elixir" } } }, { "name": "meta.protocol_declaration.elixir", "begin": "^\\s*(defprotocol)\\b", "end": "\\b(do)\\b", "patterns": [ { "name": "entity.name.protocol.elixir", "match": "\\b[A-Z]\\w*\\b" } ], "beginCaptures": { "1": { "name": "keyword.control.protocol.elixir" } }, "endCaptures": { "1": { "name": "keyword.control.protocol.elixir" } } }, { "name": "meta.protocol_implementation.elixir", "begin": "^\\s*(defimpl)\\b", "end": "\\b(do)\\b", "patterns": [ { "name": "entity.name.protocol.elixir", "match": "\\b[A-Z]\\w*\\b" } ], "beginCaptures": { "1": { "name": "keyword.control.protocol.elixir" } }, "endCaptures": { "1": { "name": "keyword.control.protocol.elixir" } } }, { "name": "meta.function.public.elixir", "begin": "^\\s*(def|defmacro|defdelegate|defguard)\\s+((?\u003e[a-zA-Z_]\\w*(?\u003e\\.|::))?(?\u003e[a-zA-Z_]\\w*(?\u003e[?!]|=(?!\u003e))?|===?|\u003e[\u003e=]?|\u003c=\u003e|\u003c[\u003c=]?|[%\u0026`/\\|]|\\*\\*?|=?~|[-+]@?|\\[\\]=?))((\\()|\\s*)", "end": "(\\bdo:)|(\\bdo\\b)|(?=\\s+(def|defmacro|defdelegate|defguard)\\b)", "patterns": [ { "include": "$self" }, { "begin": "\\s(\\\\\\\\)", "end": ",|\\)|$", "patterns": [ { "include": "$self" } ], "beginCaptures": { "1": { "name": "keyword.operator.other.elixir" } } }, { "name": "keyword.control.elixir", "match": "\\b(is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_map|is_nil|is_number|is_pid|is_port|is_record|is_reference|is_tuple|is_exception|abs|bit_size|byte_size|div|elem|hd|length|map_size|node|rem|round|tl|trunc|tuple_size)\\b" } ], "beginCaptures": { "1": { "name": "keyword.control.module.elixir" }, "2": { "name": "entity.name.function.public.elixir" }, "4": { "name": "punctuation.section.function.elixir" } }, "endCaptures": { "1": { "name": "constant.other.keywords.elixir" }, "2": { "name": "keyword.control.module.elixir" } } }, { "name": "meta.function.private.elixir", "begin": "^\\s*(defp|defmacrop|defguardp)\\s+((?\u003e[a-zA-Z_]\\w*(?\u003e\\.|::))?(?\u003e[a-zA-Z_]\\w*(?\u003e[?!]|=(?!\u003e))?|===?|\u003e[\u003e=]?|\u003c=\u003e|\u003c[\u003c=]?|[%\u0026`/\\|]|\\*\\*?|=?~|[-+]@?|\\[\\]=?))((\\()|\\s*)", "end": "(\\bdo:)|(\\bdo\\b)|(?=\\s+(defp|defmacrop|defguardp)\\b)", "patterns": [ { "include": "$self" }, { "begin": "\\s(\\\\\\\\)", "end": ",|\\)|$", "patterns": [ { "include": "$self" } ], "beginCaptures": { "1": { "name": "keyword.operator.other.elixir" } } }, { "name": "keyword.control.elixir", "match": "\\b(is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_map|is_nil|is_number|is_pid|is_port|is_record|is_reference|is_tuple|is_exception|abs|bit_size|byte_size|div|elem|hd|length|map_size|node|rem|round|tl|trunc|tuple_size)\\b" } ], "beginCaptures": { "1": { "name": "keyword.control.module.elixir" }, "2": { "name": "entity.name.function.private.elixir" }, "4": { "name": "punctuation.section.function.elixir" } }, "endCaptures": { "1": { "name": "constant.other.keywords.elixir" }, "2": { "name": "keyword.control.module.elixir" } } }, { "name": "comment.documentation.heredoc", "begin": "@(module|type)?doc (~[a-z])?\"\"\"", "end": "\\s*\"\"\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ] }, { "name": "comment.documentation.heredoc", "begin": "@(module|type)?doc ~[A-Z]\"\"\"", "end": "\\s*\"\"\"" }, { "name": "comment.documentation.heredoc", "begin": "@(module|type)?doc (~[a-z])?'''", "end": "\\s*'''", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ] }, { "name": "comment.documentation.heredoc", "begin": "@(module|type)?doc ~[A-Z]'''", "end": "\\s*'''" }, { "name": "comment.documentation.false", "match": "@(module|type)?doc false" }, { "name": "comment.documentation.string", "begin": "@(module|type)?doc \"", "end": "\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ] }, { "name": "keyword.control.elixir", "match": "(?\u003c!\\.)\\b(do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defguardp?|defdelegate|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super|with)\\b(?![?!:])" }, { "name": "keyword.operator.elixir", "match": "(?\u003c!\\.)\\b(and|not|or|when|xor|in)\\b" }, { "name": "entity.name.class.elixir", "match": "\\b[A-Z]\\w*\\b" }, { "name": "constant.language.elixir", "match": "\\b(nil|true|false)\\b(?![?!])" }, { "name": "variable.language.elixir", "match": "\\b(__(CALLER|ENV|MODULE|DIR|STACKTRACE)__)\\b(?![?!])" }, { "name": "variable.other.readwrite.module.elixir", "match": "(@)[a-zA-Z_]\\w*", "captures": { "1": { "name": "punctuation.definition.variable.elixir" } } }, { "name": "variable.other.anonymous.elixir", "match": "(\u0026)\\d+", "captures": { "1": { "name": "punctuation.definition.variable.elixir" } } }, { "name": "variable.other.capture.elixir", "match": "\\^[a-z_]\\w*", "captures": { "1": { "name": "punctuation.definition.variable.elixir" } } }, { "name": "constant.numeric.elixir", "match": "\\b(0x[0-9A-Fa-f](?\u003e_?[0-9A-Fa-f])*|\\d(?\u003e_?\\d)*(\\.(?![^[:space:][:digit:]])(?\u003e_?\\d)*)?([eE][-+]?\\d(?\u003e_?\\d)*)?|0b[01]+|0o[0-7]+)\\b" }, { "name": "constant.other.symbol.single-quoted.elixir", "begin": ":'", "end": "'", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "captures": { "0": { "name": "punctuation.definition.constant.elixir" } } }, { "name": "constant.other.symbol.double-quoted.elixir", "begin": ":\"", "end": "\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "captures": { "0": { "name": "punctuation.definition.constant.elixir" } } }, { "name": "string.quoted.single.heredoc.elixir", "begin": "(?\u003e''')", "end": "^\\s*'''", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.single.elixir", "begin": "'", "end": "'", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.double.heredoc.elixir", "begin": "(?\u003e\"\"\")", "end": "^\\s*\"\"\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.double.elixir", "begin": "\"", "end": "\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.double.heredoc.elixir", "begin": "~[a-z](?\u003e\"\"\")", "end": "^\\s*\"\"\"", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.interpolated.elixir", "begin": "~[a-z]\\{", "end": "\\}[a-z]*", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.interpolated.elixir", "begin": "~[a-z]\\[", "end": "\\][a-z]*", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.interpolated.elixir", "begin": "~[a-z]\\\u003c", "end": "\\\u003e[a-z]*", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.interpolated.elixir", "begin": "~[a-z]\\(", "end": "\\)[a-z]*", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.interpolated.elixir", "begin": "~[a-z]([^\\w])", "end": "\\1[a-z]*", "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" }, { "include": "#escaped_char" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z](?\u003e\"\"\")", "end": "^\\s*\"\"\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z]\\{", "end": "\\}[a-z]*", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z]\\[", "end": "\\][a-z]*", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z]\\\u003c", "end": "\\\u003e[a-z]*", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z]\\(", "end": "\\)[a-z]*", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "string.quoted.other.literal.upper.elixir", "begin": "~[A-Z]([^\\w])", "end": "\\1[a-z]*", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.elixir" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.elixir" } } }, { "name": "constant.other.symbol.elixir", "match": "(?\u003c!:)(:)(?\u003e[a-zA-Z_][\\w@]*(?\u003e[?!]|=(?![\u003e=]))?|\\\u003c\\\u003e|===?|!==?|\u003c\u003c\u003e\u003e|\u003c\u003c\u003c|\u003e\u003e\u003e|~~~|::|\u003c\\-|\\|\u003e|=\u003e|=~|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|\u003e=?|\u003c=?|\u0026\u0026?\u0026?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(\\^\\^)?)", "captures": { "1": { "name": "punctuation.definition.constant.elixir" } } }, { "name": "constant.other.keywords.elixir", "match": "(?\u003e[a-zA-Z_][\\w@]*(?\u003e[?!])?)(:)(?!:)", "captures": { "1": { "name": "punctuation.definition.constant.elixir" } } }, { "name": "comment.line.section.elixir", "match": "^\\s*(##).*$\\n?", "captures": { "1": { "name": "punctuation.definition.comment.elixir" } } }, { "name": "comment.line.number-sign.elixir", "match": "(?:^[ \\t]+)?(#).*$\\n?", "captures": { "1": { "name": "punctuation.definition.comment.elixir" } } }, { "name": "constant.numeric.elixir", "match": "(?\u003c!\\w)\\?(\\\\(x[0-9A-Fa-f]{1,2}(?![0-9A-Fa-f])\\b|[^xMC])|[^\\s\\\\])" }, { "name": "keyword.operator.concatenation.elixir", "match": "\\+\\+|\\-\\-|\u003c\\|\u003e" }, { "name": "keyword.operator.sigils_1.elixir", "match": "\\|\\\u003e|\u003c~\u003e|\u003c\u003e|\u003c\u003c\u003c|\u003e\u003e\u003e|~\u003e\u003e|\u003c\u003c~|~\u003e|\u003c~|\u003c\\|\u003e" }, { "name": "keyword.operator.sigils_2.elixir", "match": "\u0026\u0026\u0026|\u0026\u0026" }, { "name": "keyword.operator.sigils_3.elixir", "match": "\u003c\\-|\\\\\\\\" }, { "name": "keyword.operator.comparison.elixir", "match": "===?|!==?|\u003c=?|\u003e=?" }, { "name": "keyword.operator.bitwise.elixir", "match": "(\\|\\|\\||\u0026\u0026\u0026|\\^\\^\\^|\u003c\u003c\u003c|\u003e\u003e\u003e|~~~)" }, { "name": "keyword.operator.logical.elixir", "match": "(?\u003c=[ \\t])!+|\\bnot\\b|\u0026\u0026|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b" }, { "name": "keyword.operator.arithmetic.elixir", "match": "(\\*|\\+|\\-|/)" }, { "name": "keyword.operator.other.elixir", "match": "\\||\\+\\+|\\-\\-|\\*\\*|\\\\\\\\|\\\u003c\\-|\\\u003c\\\u003e|\\\u003c\\\u003c|\\\u003e\\\u003e|\\:\\:|\\.\\.|\\|\u003e|~|=\u003e|\u0026" }, { "name": "keyword.operator.assignment.elixir", "match": "=" }, { "name": "punctuation.separator.other.elixir", "match": ":" }, { "name": "punctuation.separator.statement.elixir", "match": "\\;" }, { "name": "punctuation.separator.object.elixir", "match": "," }, { "name": "punctuation.separator.method.elixir", "match": "\\." }, { "name": "punctuation.section.scope.elixir", "match": "\\{|\\}" }, { "name": "punctuation.section.array.elixir", "match": "\\[|\\]" }, { "name": "punctuation.section.function.elixir", "match": "\\(|\\)" } ] }, "escaped_char": { "name": "constant.character.escaped.elixir", "match": "\\\\(x[\\da-fA-F]{1,2}|.)" }, "interpolated_elixir": { "patterns": [ { "name": "source.elixir.embedded.source", "match": "#\\{(\\})", "captures": { "0": { "name": "punctuation.section.embedded.elixir" }, "1": { "name": "source.elixir.embedded.source.empty" } } }, { "name": "source.elixir.embedded.source", "begin": "#\\{", "end": "\\}", "patterns": [ { "include": "#nest_curly_and_self" }, { "include": "$self" } ], "captures": { "0": { "name": "punctuation.section.embedded.elixir" } } } ] }, "nest_curly_and_self": { "patterns": [ { "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#nest_curly_and_self" } ], "captures": { "0": { "name": "punctuation.section.scope.elixir" } } }, { "include": "$self" } ] }, "regex_sub": { "patterns": [ { "include": "#interpolated_elixir" }, { "include": "#escaped_char" }, { "name": "string.regexp.arbitrary-repitition.elixir", "match": "(\\{)\\d+(,\\d+)?(\\})", "captures": { "1": { "name": "punctuation.definition.arbitrary-repitition.elixir" }, "3": { "name": "punctuation.definition.arbitrary-repitition.elixir" } } }, { "name": "string.regexp.character-class.elixir", "begin": "\\[(?:\\^?\\])?", "end": "\\]", "patterns": [ { "include": "#escaped_char" } ], "captures": { "0": { "name": "punctuation.definition.character-class.elixir" } } }, { "name": "string.regexp.group.elixir", "begin": "\\(", "end": "\\)", "patterns": [ { "include": "#regex_sub" } ], "captures": { "0": { "name": "punctuation.definition.group.elixir" } } }, { "name": "comment.line.number-sign.elixir", "match": "(?\u003c=^|\\s)(#)\\s[[a-zA-Z0-9,. \\t?!-][^\\x{00}-\\x{7F}]]*$", "captures": { "1": { "name": "punctuation.definition.comment.elixir" } } } ] } } }