mirror of https://github.com/helix-editor/helix
Replace MATLAB grammar (#7388)
parent
842518ccb7
commit
2c5288dafb
@ -0,0 +1,41 @@
|
|||||||
|
(function_definition
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(while_statement
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(for_statement
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(if_statement
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(elseif_clause
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(else_clause
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(switch_statement) @context
|
||||||
|
|
||||||
|
(case_clause
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(otherwise_clause
|
||||||
|
(block (_) @context.end)
|
||||||
|
) @context
|
||||||
|
|
||||||
|
(try_statement
|
||||||
|
"try"
|
||||||
|
(block (_) @context.end) @context
|
||||||
|
"end")
|
||||||
|
(catch_clause
|
||||||
|
"catch"
|
||||||
|
(block (_) @context.end) @context)
|
@ -0,0 +1,11 @@
|
|||||||
|
[(if_statement)
|
||||||
|
(for_statement)
|
||||||
|
(while_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(try_statement)
|
||||||
|
(function_definition)
|
||||||
|
(class_definition)
|
||||||
|
(enumeration)
|
||||||
|
(events)
|
||||||
|
(methods)
|
||||||
|
(properties)] @fold
|
@ -1,97 +1,127 @@
|
|||||||
; highlights.scm
|
; Constants
|
||||||
|
|
||||||
function_keyword: (function_keyword) @keyword.function
|
(events (identifier) @constant)
|
||||||
|
(attribute (identifier) @constant)
|
||||||
|
|
||||||
(function_definition
|
"~" @constant.builtin
|
||||||
function_name: (identifier) @function
|
|
||||||
(end) @function)
|
|
||||||
|
|
||||||
(parameter_list (identifier) @variable.parameter)
|
; Fields/Properties
|
||||||
|
|
||||||
[
|
(superclass "." (identifier) @variable.other.member)
|
||||||
"if"
|
(property_name "." (identifier) @variable.other.member)
|
||||||
"elseif"
|
(property name: (identifier) @variable.other.member)
|
||||||
"else"
|
|
||||||
"switch"
|
|
||||||
"case"
|
|
||||||
"otherwise"
|
|
||||||
] @keyword.control.conditional
|
|
||||||
|
|
||||||
(if_statement (end) @keyword.control.conditional)
|
; Types
|
||||||
(switch_statement (end) @keyword.control.conditional)
|
|
||||||
|
|
||||||
["for" "while"] @keyword.control.repeat
|
(class_definition name: (identifier) @keyword.storage.type)
|
||||||
(for_statement (end) @keyword.control.repeat)
|
(attributes (identifier) @constant)
|
||||||
(while_statement (end) @keyword.control.repeat)
|
(enum . (identifier) @type.enum.variant)
|
||||||
|
|
||||||
["try" "catch"] @keyword.control.exception
|
; Functions
|
||||||
(try_statement (end) @keyword.control.exception)
|
|
||||||
|
|
||||||
(function_definition end: (end) @keyword)
|
(function_definition
|
||||||
|
"function" @keyword.function
|
||||||
|
name: (identifier) @function
|
||||||
|
[ "end" "endfunction" ]? @keyword.function)
|
||||||
|
|
||||||
["return" "break" "continue"] @keyword.return
|
(function_signature name: (identifier) @function)
|
||||||
|
(function_call name: (identifier) @function)
|
||||||
|
(handle_operator (identifier) @function)
|
||||||
|
(validation_functions (identifier) @function)
|
||||||
|
(command (command_name) @function.macro)
|
||||||
|
(command_argument) @string
|
||||||
|
(return_statement) @keyword.control.return
|
||||||
|
|
||||||
(
|
; Assignments
|
||||||
(identifier) @constant.builtin
|
|
||||||
(#any-of? @constant.builtin "true" "false")
|
|
||||||
)
|
|
||||||
|
|
||||||
(
|
(assignment left: (_) @variable)
|
||||||
(identifier) @constant.builtin
|
(multioutput_variable (_) @variable)
|
||||||
(#eq? @constant.builtin "end")
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Punctuations
|
; Parameters
|
||||||
|
|
||||||
[";" ","] @punctuation.special
|
(function_arguments (identifier) @variable.parameter)
|
||||||
(argument_list "," @punctuation.delimiter)
|
|
||||||
(vector_definition ["," ";"] @punctuation.delimiter)
|
|
||||||
(cell_definition ["," ";"] @punctuation.delimiter)
|
|
||||||
":" @punctuation.delimiter
|
|
||||||
(parameter_list "," @punctuation.delimiter)
|
|
||||||
(return_value "," @punctuation.delimiter)
|
|
||||||
|
|
||||||
; ;; Brackets
|
; Operators
|
||||||
|
|
||||||
[
|
[
|
||||||
"("
|
"+"
|
||||||
")"
|
".+"
|
||||||
"["
|
"-"
|
||||||
"]"
|
".*"
|
||||||
"{"
|
"*"
|
||||||
"}"
|
".*"
|
||||||
] @punctuation.bracket
|
"/"
|
||||||
|
"./"
|
||||||
;; Operators
|
"\\"
|
||||||
"=" @operator
|
".\\"
|
||||||
(operation [ ">"
|
"^"
|
||||||
"<"
|
".^"
|
||||||
"=="
|
"'"
|
||||||
"<="
|
".'"
|
||||||
">="
|
"|"
|
||||||
"=<"
|
"&"
|
||||||
"=>"
|
"?"
|
||||||
"~="
|
"@"
|
||||||
"*"
|
"<"
|
||||||
".*"
|
"<="
|
||||||
"/"
|
">"
|
||||||
"\\"
|
">="
|
||||||
"./"
|
"=="
|
||||||
"^"
|
"~="
|
||||||
".^"
|
"="
|
||||||
"+"] @operator)
|
"&&"
|
||||||
|
"||"
|
||||||
;; boolean operator
|
":"
|
||||||
[
|
|
||||||
"&&"
|
|
||||||
"||"
|
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
;; Number
|
; Conditionals
|
||||||
(number) @constant.numeric
|
|
||||||
|
(if_statement [ "if" "end" ] @keyword.control.conditional)
|
||||||
|
(elseif_clause "elseif" @keyword.control.conditional)
|
||||||
|
(else_clause "else" @keyword.control.conditional)
|
||||||
|
(switch_statement [ "switch" "end" ] @keyword.control.conditional)
|
||||||
|
(case_clause "case" @keyword.control.conditional)
|
||||||
|
(otherwise_clause "otherwise" @keyword.control.conditional)
|
||||||
|
(break_statement) @keyword.control.conditional
|
||||||
|
|
||||||
|
; Repeats
|
||||||
|
|
||||||
|
(for_statement [ "for" "parfor" "end" ] @keyword.control.repeat)
|
||||||
|
(while_statement [ "while" "end" ] @keyword.control.repeat)
|
||||||
|
(continue_statement) @keyword.control.repeat
|
||||||
|
|
||||||
|
; Exceptions
|
||||||
|
|
||||||
;; String
|
(try_statement [ "try" "end" ] @keyword.control.exception)
|
||||||
|
(catch_clause "catch" @keyword.control.exception)
|
||||||
|
|
||||||
|
; Punctuation
|
||||||
|
|
||||||
|
[ ";" "," "." ] @punctuation.delimiter
|
||||||
|
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
|
||||||
|
(escape_sequence) @constant.character.escape
|
||||||
|
(formatting_sequence) @constant.character.escape
|
||||||
(string) @string
|
(string) @string
|
||||||
|
(number) @constant.numeric.float
|
||||||
|
(boolean) @constant.builtin.boolean
|
||||||
|
|
||||||
;; Comment
|
; Comments
|
||||||
(comment) @comment
|
|
||||||
|
[ (comment) (line_continuation) ] @comment.line
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
|
||||||
|
"classdef" @keyword.storage.type
|
||||||
|
[
|
||||||
|
"arguments"
|
||||||
|
"end"
|
||||||
|
"enumeration"
|
||||||
|
"events"
|
||||||
|
"global"
|
||||||
|
"methods"
|
||||||
|
"persistent"
|
||||||
|
"properties"
|
||||||
|
] @keyword
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
[
|
||||||
|
(if_statement)
|
||||||
|
(for_statement)
|
||||||
|
(while_statement)
|
||||||
|
(switch_statement)
|
||||||
|
(try_statement)
|
||||||
|
(function_definition)
|
||||||
|
(class_definition)
|
||||||
|
(enumeration)
|
||||||
|
(events)
|
||||||
|
(methods)
|
||||||
|
(properties)
|
||||||
|
] @indent
|
||||||
|
|
||||||
|
[
|
||||||
|
(elseif_clause)
|
||||||
|
(else_clause)
|
||||||
|
(case_clause)
|
||||||
|
(otherwise_clause)
|
||||||
|
(catch_clause)
|
||||||
|
] @indent @extend
|
||||||
|
|
||||||
|
[ "end" ] @outdent
|
@ -0,0 +1,2 @@
|
|||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
@ -0,0 +1,19 @@
|
|||||||
|
(function_definition name: (identifier) @local.definition ?) @local.scope
|
||||||
|
(function_arguments (identifier)* @local.definition)
|
||||||
|
|
||||||
|
(lambda (arguments (identifier) @local.definition)) @local.scope
|
||||||
|
|
||||||
|
(assignment left: ((function_call
|
||||||
|
name: (identifier) @local.definition)))
|
||||||
|
(assignment left: ((field_expression . [(function_call
|
||||||
|
name: (identifier) @local.definition)
|
||||||
|
(identifier) @local.definition])))
|
||||||
|
(assignment left: (_) @local.definition)
|
||||||
|
(assignment (multioutput_variable (_) @local.definition))
|
||||||
|
|
||||||
|
(iterator . (identifier) @local.definition)
|
||||||
|
(global_operator (identifier) @local.definition)
|
||||||
|
(persistent_operator (identifier) @local.definition)
|
||||||
|
(catch_clause (identifier) @local.definition)
|
||||||
|
|
||||||
|
(identifier) @local.reference
|
@ -0,0 +1,9 @@
|
|||||||
|
(arguments ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
(function_arguments ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
|
(lambda expression: (_) @function.inside) @function.around
|
||||||
|
(function_definition (block) @function.inside) @function.around
|
||||||
|
|
||||||
|
(class_definition) @class.inside @class.around
|
||||||
|
|
||||||
|
(comment) @comment.inside @comment.around
|
Loading…
Reference in New Issue