mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
refactor(highlights/julia): Update definitions
See https://github.com/tree-sitter/tree-sitter-julia/pull/54 Remove a bunch of patterns with `argument_list`. No longer necessary with `short_function_definition`. Other minor changes including: - Add boolean literals See https://github.com/tree-sitter/tree-sitter-julia/pull/44 - Update highlights for operators (for bindings, type operators, etc) - Update lockfile
This commit is contained in:
parent
c6992f69d3
commit
27bbb64f87
2 changed files with 161 additions and 122 deletions
|
|
@ -186,7 +186,7 @@
|
|||
"revision": "0475a5017ad7dc84845d1d33187f2321abcb261d"
|
||||
},
|
||||
"julia": {
|
||||
"revision": "0572cebf7b8e8ef5990b4d1e7f44f0b36f62922c"
|
||||
"revision": "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25"
|
||||
},
|
||||
"kotlin": {
|
||||
"revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
|
||||
|
|
|
|||
|
|
@ -1,96 +1,136 @@
|
|||
;;; Identifiers
|
||||
|
||||
(identifier) @variable
|
||||
|
||||
(operator) @operator
|
||||
(range_expression ":" @operator)
|
||||
(pair_expression "=>" @operator)
|
||||
|
||||
;; 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][^_]"))
|
||||
; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
|
||||
; ((identifier) @type
|
||||
; (match? @type "^[A-Z][^_]")) ; exception: Highlight `A_foo` sort of identifiers as variables
|
||||
|
||||
(macro_identifier) @function.macro
|
||||
(macro_identifier (identifier) @function.macro) ; for any one using the variable highlight
|
||||
(macro_identifier
|
||||
(identifier) @function.macro) ; for any one using the variable highlight
|
||||
|
||||
(macro_definition
|
||||
name: (identifier) @function.macro
|
||||
["macro" "end" @keyword])
|
||||
name: (identifier) @function.macro)
|
||||
|
||||
(quote_expression ":" (identifier)) @symbol
|
||||
|
||||
|
||||
;;; Fields and indexes
|
||||
|
||||
(field_expression
|
||||
(identifier)
|
||||
(identifier) @field .)
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
(call_expression
|
||||
(identifier) @function.call)
|
||||
(call_expression
|
||||
(field_expression (identifier) @method.call .))
|
||||
(broadcast_call_expression
|
||||
(identifier) @function.call)
|
||||
(broadcast_call_expression
|
||||
(field_expression (identifier) @method.call .))
|
||||
(parameter_list
|
||||
(identifier) @parameter)
|
||||
(parameter_list
|
||||
(optional_parameter .
|
||||
(identifier) @parameter))
|
||||
(typed_parameter
|
||||
(identifier) @parameter
|
||||
(identifier) @type)
|
||||
(type_parameter_list
|
||||
(identifier) @type)
|
||||
(typed_parameter
|
||||
(identifier) @parameter
|
||||
(parameterized_identifier) @type)
|
||||
(function_expression
|
||||
. (identifier) @parameter)
|
||||
(spread_parameter) @parameter
|
||||
(spread_parameter
|
||||
(identifier) @parameter)
|
||||
(named_argument
|
||||
. (identifier) @parameter)
|
||||
(argument_list
|
||||
(typed_expression
|
||||
(identifier) @parameter
|
||||
(identifier) @type))
|
||||
(argument_list
|
||||
(typed_expression
|
||||
(identifier) @parameter
|
||||
(parameterized_identifier) @type))
|
||||
|
||||
;; Symbol expressions (:my-wanna-be-lisp-keyword)
|
||||
(quote_expression
|
||||
(identifier)) @symbol
|
||||
|
||||
;; Parsing error! foo (::Type) gets parsed as two quote expressions
|
||||
(argument_list
|
||||
(quote_expression
|
||||
(quote_expression
|
||||
(identifier) @type)))
|
||||
|
||||
(type_argument_list
|
||||
(identifier) @type)
|
||||
(parameterized_identifier (_)) @type
|
||||
(argument_list
|
||||
(typed_expression . (identifier) @parameter))
|
||||
|
||||
(typed_expression
|
||||
(identifier) @type .)
|
||||
(typed_expression
|
||||
(parameterized_identifier) @type .)
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @type)
|
||||
(struct_definition
|
||||
name: (identifier) @type)
|
||||
|
||||
(subscript_expression
|
||||
(_)
|
||||
(range_expression
|
||||
(identifier) @constant.builtin .)
|
||||
(#eq? @constant.builtin "end"))
|
||||
|
||||
|
||||
;;; Function names
|
||||
|
||||
;; definitions
|
||||
|
||||
(function_definition
|
||||
name: (identifier) @function)
|
||||
(short_function_definition
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_definition
|
||||
name: (scoped_identifier (identifier) @function .))
|
||||
(short_function_definition
|
||||
name: (scoped_identifier (identifier) @function .))
|
||||
|
||||
;; calls
|
||||
|
||||
(call_expression
|
||||
(identifier) @function.call)
|
||||
(call_expression
|
||||
(field_expression (identifier) @function.call .))
|
||||
|
||||
(broadcast_call_expression
|
||||
(identifier) @function.call)
|
||||
(broadcast_call_expression
|
||||
(field_expression (identifier) @function.call .))
|
||||
|
||||
|
||||
;;; Parameters
|
||||
|
||||
(parameter_list
|
||||
(identifier) @parameter)
|
||||
(optional_parameter .
|
||||
(identifier) @parameter)
|
||||
(slurp_parameter
|
||||
(identifier) @parameter)
|
||||
|
||||
(typed_parameter
|
||||
parameter: (identifier) @parameter
|
||||
type: (_) @type)
|
||||
(typed_parameter
|
||||
type: (_) @type)
|
||||
|
||||
(function_expression
|
||||
. (identifier) @parameter) ; Single parameter arrow functions
|
||||
|
||||
|
||||
;;; Types
|
||||
|
||||
;; Definitions
|
||||
|
||||
(abstract_definition
|
||||
name: (identifier) @type)
|
||||
(primitive_definition
|
||||
name: (identifier) @type)
|
||||
(struct_definition
|
||||
name: (identifier) @type)
|
||||
|
||||
;; Annotations
|
||||
|
||||
(parameterized_identifier (_) @type)
|
||||
|
||||
(type_parameter_list
|
||||
(identifier) @type)
|
||||
|
||||
(type_argument_list
|
||||
(identifier) @type)
|
||||
|
||||
(typed_expression
|
||||
(identifier) @type .)
|
||||
|
||||
(function_definition
|
||||
return_type: (identifier) @type)
|
||||
(short_function_definition
|
||||
return_type: (identifier) @type)
|
||||
|
||||
(where_clause
|
||||
(identifier) @type) ; where clause without braces
|
||||
|
||||
|
||||
;;; Keywords
|
||||
|
||||
[
|
||||
"abstract"
|
||||
"const"
|
||||
"macro"
|
||||
"primitive"
|
||||
"struct"
|
||||
"type"
|
||||
"mutable"
|
||||
"where"
|
||||
] @keyword
|
||||
|
||||
"end" @keyword
|
||||
|
||||
((identifier) @keyword (#any-of? @keyword "global" "local")) ; Grammar error
|
||||
|
||||
(compound_expression
|
||||
["begin" "end"] @keyword)
|
||||
(quote_statement
|
||||
["quote" "end"] @keyword)
|
||||
(let_statement
|
||||
["let" "end"] @keyword)
|
||||
|
||||
(if_statement
|
||||
["if" "end"] @conditional)
|
||||
(elseif_clause
|
||||
|
|
@ -100,61 +140,68 @@
|
|||
(ternary_expression
|
||||
["?" ":"] @conditional)
|
||||
|
||||
(function_definition ["function" "end"] @keyword.function)
|
||||
|
||||
[
|
||||
"abstract"
|
||||
"const"
|
||||
"macro"
|
||||
"primitive"
|
||||
"struct"
|
||||
"type"
|
||||
"mutable"
|
||||
] @keyword
|
||||
|
||||
"return" @keyword.return
|
||||
|
||||
((identifier) @keyword (#any-of? @keyword "global" "local"))
|
||||
|
||||
(compound_expression
|
||||
["begin" "end"] @keyword)
|
||||
(try_statement
|
||||
["try" "end" ] @exception)
|
||||
["try" "end"] @exception)
|
||||
(finally_clause
|
||||
"finally" @exception)
|
||||
(catch_clause
|
||||
"catch" @exception)
|
||||
(quote_statement
|
||||
["quote" "end"] @keyword)
|
||||
(let_statement
|
||||
["let" "end"] @keyword)
|
||||
|
||||
(for_statement
|
||||
["for" "end"] @repeat)
|
||||
(while_statement
|
||||
["while" "end"] @repeat)
|
||||
(break_statement) @repeat
|
||||
(continue_statement) @repeat
|
||||
(for_clause
|
||||
"for" @repeat)
|
||||
(do_clause
|
||||
["do" "end"] @keyword)
|
||||
|
||||
"in" @keyword.operator
|
||||
|
||||
(export_statement
|
||||
["export"] @include)
|
||||
|
||||
(import_statement
|
||||
["import" "using"] @include)
|
||||
[
|
||||
(break_statement)
|
||||
(continue_statement)
|
||||
] @repeat
|
||||
|
||||
(module_definition
|
||||
["module" "end"] @include)
|
||||
["module" "baremodule" "end"] @include)
|
||||
(import_statement
|
||||
["import" "using"] @include)
|
||||
(export_statement
|
||||
"export" @include)
|
||||
|
||||
((identifier) @include (#eq? @include "baremodule"))
|
||||
(macro_definition
|
||||
["macro" "end" @keyword])
|
||||
|
||||
(function_definition
|
||||
["function" "end"] @keyword.function)
|
||||
(do_clause
|
||||
["do" "end"] @keyword.function)
|
||||
(function_expression
|
||||
"->" @keyword.function)
|
||||
(return_statement
|
||||
"return" @keyword.return)
|
||||
|
||||
|
||||
;;; Operators & Punctuation
|
||||
|
||||
(operator) @operator
|
||||
(for_binding ["in" "=" "∈"] @operator)
|
||||
(pair_expression "=>" @operator)
|
||||
(range_expression ":" @operator)
|
||||
|
||||
(slurp_parameter "..." @operator)
|
||||
(spread_expression "..." @operator)
|
||||
|
||||
"." @operator
|
||||
["::" "<:"] @operator
|
||||
|
||||
["," ";"] @punctuation.delimiter
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
|
||||
|
||||
;;; Literals
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
(integer_literal) @number
|
||||
(float_literal) @float
|
||||
|
||||
|
|
@ -162,9 +209,6 @@
|
|||
(#any-of? @float "NaN" "NaN16" "NaN32"
|
||||
"Inf" "Inf16" "Inf32"))
|
||||
|
||||
((identifier) @boolean
|
||||
(#any-of? @boolean "true" "false"))
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#any-of? @constant.builtin "nothing" "missing"))
|
||||
|
||||
|
|
@ -184,8 +228,3 @@
|
|||
(block_comment)
|
||||
] @comment
|
||||
|
||||
;;; Punctuation
|
||||
|
||||
(quote_expression ":" @symbol)
|
||||
["::" "." "," "..."] @punctuation.delimiter
|
||||
["[" "]" "(" ")" "{" "}"] @punctuation.bracket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue