Improve grammar definitions

pull/724/head
Blaž Hrastnik 3 years ago
parent 37606bad47
commit a6108baec9

@ -1 +1 @@
Subproject commit 0ba7a24b062b671263ae08e707e9e94383b25bb7 Subproject commit 12ea597262125fc22fd2e91aa953ac69b19c26ca

@ -1,9 +1,3 @@
(identifier) @variable
;; In case you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
;((identifier) @type ; exception: mark `A_foo` sort of identifiers as variables
;(match? @type "^[A-Z][^_]"))
((identifier) @constant
(match? @constant "^[A-Z][A-Z_]{2}[A-Z_]*$"))
[ [
(triple_string) (triple_string)
@ -28,43 +22,43 @@
(call_expression (call_expression
(identifier) @function) (identifier) @function)
(call_expression (call_expression
(field_expression (identifier) @method .)) (field_expression (identifier) @function.method .))
(broadcast_call_expression (broadcast_call_expression
(identifier) @function) (identifier) @function)
(broadcast_call_expression (broadcast_call_expression
(field_expression (identifier) @method .)) (field_expression (identifier) @function.method .))
(parameter_list (parameter_list
(identifier) @parameter) (identifier) @variable.parameter)
(parameter_list (parameter_list
(optional_parameter . (optional_parameter .
(identifier) @parameter)) (identifier) @variable.parameter))
(typed_parameter (typed_parameter
(identifier) @parameter (identifier) @variable.parameter
(identifier) @type) (identifier) @type)
(type_parameter_list (type_parameter_list
(identifier) @type) (identifier) @type)
(typed_parameter (typed_parameter
(identifier) @parameter (identifier) @variable.parameter
(parameterized_identifier) @type) (parameterized_identifier) @type)
(function_expression (function_expression
. (identifier) @parameter) . (identifier) @variable.parameter)
(spread_parameter) @parameter (spread_parameter) @variable.parameter
(spread_parameter (spread_parameter
(identifier) @parameter) (identifier) @variable.parameter)
(named_argument (named_argument
. (identifier) @parameter) . (identifier) @variable.parameter)
(argument_list (argument_list
(typed_expression (typed_expression
(identifier) @parameter (identifier) @variable.parameter
(identifier) @type)) (identifier) @type))
(argument_list (argument_list
(typed_expression (typed_expression
(identifier) @parameter (identifier) @variable.parameter
(parameterized_identifier) @type)) (parameterized_identifier) @type))
;; Symbol expressions (:my-wanna-be-lisp-keyword) ;; Symbol expressions (:my-wanna-be-lisp-keyword)
(quote_expression (quote_expression
(identifier)) @symbol (identifier)) @string.special.symbol
;; Parsing error! foo (::Type) get's parsed as two quote expressions ;; Parsing error! foo (::Type) get's parsed as two quote expressions
(argument_list (argument_list
@ -76,7 +70,7 @@
(identifier) @type) (identifier) @type)
(parameterized_identifier (_)) @type (parameterized_identifier (_)) @type
(argument_list (argument_list
(typed_expression . (identifier) @parameter)) (typed_expression . (identifier) @variable.parameter))
(typed_expression (typed_expression
(identifier) @type .) (identifier) @type .)
@ -113,13 +107,13 @@
"end" @keyword "end" @keyword
(if_statement (if_statement
["if" "end"] @conditional) ["if" "end"] @keyword.control.conditional)
(elseif_clause (elseif_clause
["elseif"] @conditional) ["elseif"] @keyword.control.conditional)
(else_clause (else_clause
["else"] @conditional) ["else"] @keyword.control.conditional)
(ternary_expression (ternary_expression
["?" ":"] @conditional) ["?" ":"] @keyword.control.conditional)
(function_definition ["function" "end"] @keyword.function) (function_definition ["function" "end"] @keyword.function)
@ -134,47 +128,57 @@
"type" "type"
] @keyword ] @keyword
((identifier) @keyword (#any-of? @keyword "global" "local")) ((identifier) @keyword (match? @keyword "global|local"))
(compound_expression (compound_expression
["begin" "end"] @keyword) ["begin" "end"] @keyword)
(try_statement (try_statement
["try" "end" ] @exception) ["try" "end" ] @keyword.control.exception)
(finally_clause (finally_clause
"finally" @exception) "finally" @keyword.control.exception)
(catch_clause (catch_clause
"catch" @exception) "catch" @keyword.control.exception)
(quote_statement (quote_statement
["quote" "end"] @keyword) ["quote" "end"] @keyword)
(let_statement (let_statement
["let" "end"] @keyword) ["let" "end"] @keyword)
(for_statement (for_statement
["for" "end"] @repeat) ["for" "end"] @keyword.control.repeat)
(while_statement (while_statement
["while" "end"] @repeat) ["while" "end"] @keyword.control.repeat)
(break_statement) @repeat (break_statement) @keyword.control.repeat
(continue_statement) @repeat (continue_statement) @keyword.control.repeat
(for_binding (for_binding
"in" @repeat) "in" @keyword.control.repeat)
(for_clause (for_clause
"for" @repeat) "for" @keyword.control.repeat)
(do_clause (do_clause
["do" "end"] @keyword) ["do" "end"] @keyword)
(export_statement (export_statement
["export"] @include) ["export"] @keyword.control.import)
[ [
"using" "using"
"module" "module"
"import" "import"
] @include ] @keyword.control.import
((identifier) @include (#eq? @include "baremodule")) ((identifier) @keyword.control.import (#eq? @keyword.control.import "baremodule"))
(((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|Inf|NaN)$")) (((identifier) @constant.builtin) (match? @constant.builtin "^(nothing|Inf|NaN)$"))
(((identifier) @boolean) (eq? @boolean "true")) (((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "true"))
(((identifier) @boolean) (eq? @boolean "false")) (((identifier) @constant.builtin.boolean) (#eq? @constant.builtin.boolean "false"))
["::" ":" "." "," "..." "!"] @punctuation.delimiter ["::" ":" "." "," "..." "!"] @punctuation.delimiter
["[" "]" "(" ")" "{" "}"] @punctuation.bracket ["[" "]" "(" ")" "{" "}"] @punctuation.bracket
["="] @operator
(identifier) @variable
;; In case you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
;((identifier) @type ; exception: mark `A_foo` sort of identifiers as variables
;(match? @type "^[A-Z][^_]"))
((identifier) @constant
(match? @constant "^[A-Z][A-Z_]{2}[A-Z_]*$"))

@ -259,7 +259,7 @@
(comment) @comment (comment) @comment
(bracket_group) @parameter (bracket_group) @variable.parameter
[(math_operator) "="] @operator [(math_operator) "="] @operator
@ -312,7 +312,7 @@
key: (word) @text.reference) key: (word) @text.reference)
(key_val_pair (key_val_pair
key: (_) @parameter key: (_) @variable.parameter
value: (_)) value: (_))
["[" "]" "{" "}"] @punctuation.bracket ;"(" ")" is has no special meaning in LaTeX ["[" "]" "{" "}"] @punctuation.bracket ;"(" ")" is has no special meaning in LaTeX

@ -108,7 +108,7 @@
[ [
(false) (false)
(true) (true)
] @boolean ] @constant.builtin.boolean
(nil) @constant.builtin (nil) @constant.builtin
(spread) @constant ;; "..." (spread) @constant ;; "..."
((identifier) @constant ((identifier) @constant
@ -116,7 +116,7 @@
;; Parameters ;; Parameters
(parameters (parameters
(identifier) @parameter) (identifier) @variable.parameter)
; ;; Functions ; ;; Functions
(function [(function_name) (identifier)] @function) (function [(function_name) (identifier)] @function)
@ -139,8 +139,8 @@
(function_call (function_call
[ [
((identifier) @variable (method) @method) ((identifier) @variable (method) @function.method)
((_) (method) @method) ((_) (method) @function.method)
(identifier) @function (identifier) @function
(field_expression (property_identifier) @function) (field_expression (property_identifier) @function)
] ]

@ -25,12 +25,12 @@
(external (value_name) @function) (external (value_name) @function)
(method_name) @method (method_name) @function.method
; Variables ; Variables
;---------- ;----------
(value_pattern) @parameter (value_pattern) @variable.parameter
; Application ; Application
;------------ ;------------

@ -17,7 +17,7 @@
(escape_sequence) @escape (escape_sequence) @escape
(primitive_type) @type.builtin (primitive_type) @type.builtin
(boolean_literal) @constant.builtin (boolean_literal) @constant.builtin.boolean
[ [
(integer_literal) (integer_literal)
(float_literal) (float_literal)

@ -1,6 +1,6 @@
(block_mapping_pair key: (_) @property) (block_mapping_pair key: (_) @property)
(flow_mapping (_ key: (_) @property)) (flow_mapping (_ key: (_) @property))
(boolean_scalar) @boolean (boolean_scalar) @constant.builtin.boolean
(null_scalar) @constant.builtin (null_scalar) @constant.builtin
(double_quote_scalar) @string (double_quote_scalar) @string
(single_quote_scalar) @string (single_quote_scalar) @string

Loading…
Cancel
Save