mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 02:10:15 -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"
|
"revision": "0475a5017ad7dc84845d1d33187f2321abcb261d"
|
||||||
},
|
},
|
||||||
"julia": {
|
"julia": {
|
||||||
"revision": "0572cebf7b8e8ef5990b4d1e7f44f0b36f62922c"
|
"revision": "8fb38abff74652c4faddbf04d2d5bbbc6b4bae25"
|
||||||
},
|
},
|
||||||
"kotlin": {
|
"kotlin": {
|
||||||
"revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
|
"revision": "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569"
|
||||||
|
|
|
||||||
|
|
@ -1,96 +1,136 @@
|
||||||
|
;;; Identifiers
|
||||||
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
(operator) @operator
|
; ;; If you want type highlighting based on Julia naming conventions (this might collide with mathematical notation)
|
||||||
(range_expression ":" @operator)
|
; ((identifier) @type
|
||||||
(pair_expression "=>" @operator)
|
; (match? @type "^[A-Z][^_]")) ; exception: Highlight `A_foo` sort of identifiers as variables
|
||||||
|
|
||||||
;; 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][^_]"))
|
|
||||||
|
|
||||||
(macro_identifier) @function.macro
|
(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
|
(macro_definition
|
||||||
name: (identifier) @function.macro
|
name: (identifier) @function.macro)
|
||||||
["macro" "end" @keyword])
|
|
||||||
|
(quote_expression ":" (identifier)) @symbol
|
||||||
|
|
||||||
|
|
||||||
|
;;; Fields and indexes
|
||||||
|
|
||||||
(field_expression
|
(field_expression
|
||||||
(identifier)
|
|
||||||
(identifier) @field .)
|
(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
|
(subscript_expression
|
||||||
(_)
|
(_)
|
||||||
(range_expression
|
(range_expression
|
||||||
(identifier) @constant.builtin .)
|
(identifier) @constant.builtin .)
|
||||||
(#eq? @constant.builtin "end"))
|
(#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
|
"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_statement
|
||||||
["if" "end"] @conditional)
|
["if" "end"] @conditional)
|
||||||
(elseif_clause
|
(elseif_clause
|
||||||
|
|
@ -100,61 +140,68 @@
|
||||||
(ternary_expression
|
(ternary_expression
|
||||||
["?" ":"] @conditional)
|
["?" ":"] @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_statement
|
||||||
["try" "end" ] @exception)
|
["try" "end"] @exception)
|
||||||
(finally_clause
|
(finally_clause
|
||||||
"finally" @exception)
|
"finally" @exception)
|
||||||
(catch_clause
|
(catch_clause
|
||||||
"catch" @exception)
|
"catch" @exception)
|
||||||
(quote_statement
|
|
||||||
["quote" "end"] @keyword)
|
|
||||||
(let_statement
|
|
||||||
["let" "end"] @keyword)
|
|
||||||
(for_statement
|
(for_statement
|
||||||
["for" "end"] @repeat)
|
["for" "end"] @repeat)
|
||||||
(while_statement
|
(while_statement
|
||||||
["while" "end"] @repeat)
|
["while" "end"] @repeat)
|
||||||
(break_statement) @repeat
|
|
||||||
(continue_statement) @repeat
|
|
||||||
(for_clause
|
(for_clause
|
||||||
"for" @repeat)
|
"for" @repeat)
|
||||||
(do_clause
|
[
|
||||||
["do" "end"] @keyword)
|
(break_statement)
|
||||||
|
(continue_statement)
|
||||||
"in" @keyword.operator
|
] @repeat
|
||||||
|
|
||||||
(export_statement
|
|
||||||
["export"] @include)
|
|
||||||
|
|
||||||
(import_statement
|
|
||||||
["import" "using"] @include)
|
|
||||||
|
|
||||||
(module_definition
|
(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
|
;;; Literals
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
(integer_literal) @number
|
(integer_literal) @number
|
||||||
(float_literal) @float
|
(float_literal) @float
|
||||||
|
|
||||||
|
|
@ -162,9 +209,6 @@
|
||||||
(#any-of? @float "NaN" "NaN16" "NaN32"
|
(#any-of? @float "NaN" "NaN16" "NaN32"
|
||||||
"Inf" "Inf16" "Inf32"))
|
"Inf" "Inf16" "Inf32"))
|
||||||
|
|
||||||
((identifier) @boolean
|
|
||||||
(#any-of? @boolean "true" "false"))
|
|
||||||
|
|
||||||
((identifier) @constant.builtin
|
((identifier) @constant.builtin
|
||||||
(#any-of? @constant.builtin "nothing" "missing"))
|
(#any-of? @constant.builtin "nothing" "missing"))
|
||||||
|
|
||||||
|
|
@ -184,8 +228,3 @@
|
||||||
(block_comment)
|
(block_comment)
|
||||||
] @comment
|
] @comment
|
||||||
|
|
||||||
;;; Punctuation
|
|
||||||
|
|
||||||
(quote_expression ":" @symbol)
|
|
||||||
["::" "." "," "..."] @punctuation.delimiter
|
|
||||||
["[" "]" "(" ")" "{" "}"] @punctuation.bracket
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue