mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 18:30:06 -04:00
Update injections & highlights, add folds
This commit is contained in:
parent
ec5341a773
commit
886261a96b
3 changed files with 154 additions and 123 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
[
|
[
|
||||||
(do_block)
|
|
||||||
(anonymous_function)
|
(anonymous_function)
|
||||||
(map)
|
(arguments)
|
||||||
(struct)
|
(block)
|
||||||
|
(do_block)
|
||||||
(list)
|
(list)
|
||||||
(keyword_list)
|
(map)
|
||||||
(heredoc)
|
(tuple)
|
||||||
] @fold
|
] @fold
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
; Punctuation delimiters
|
; Punctuation
|
||||||
[
|
[
|
||||||
"%"
|
|
||||||
","
|
","
|
||||||
|
";"
|
||||||
] @punctuation.delimiter
|
] @punctuation.delimiter
|
||||||
|
|
||||||
; Punctuation brackets
|
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
")"
|
")"
|
||||||
|
|
@ -16,105 +15,37 @@
|
||||||
"}"
|
"}"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
; Operators
|
|
||||||
[
|
[
|
||||||
"!"
|
"%"
|
||||||
"!="
|
] @punctuation.special
|
||||||
"!=="
|
|
||||||
"&"
|
|
||||||
"&&"
|
|
||||||
"&&&"
|
|
||||||
"*"
|
|
||||||
"**"
|
|
||||||
"+"
|
|
||||||
"++"
|
|
||||||
"+++"
|
|
||||||
"-"
|
|
||||||
"--"
|
|
||||||
"---"
|
|
||||||
"."
|
|
||||||
".."
|
|
||||||
"/"
|
|
||||||
"//"
|
|
||||||
"::"
|
|
||||||
"<"
|
|
||||||
"<-"
|
|
||||||
"<<<"
|
|
||||||
"<<~"
|
|
||||||
"<="
|
|
||||||
"<>"
|
|
||||||
"<|>"
|
|
||||||
"<~"
|
|
||||||
"<~>"
|
|
||||||
"="
|
|
||||||
"=="
|
|
||||||
"==="
|
|
||||||
"=>"
|
|
||||||
"=~"
|
|
||||||
">"
|
|
||||||
">="
|
|
||||||
">>>"
|
|
||||||
"@"
|
|
||||||
"^"
|
|
||||||
"and"
|
|
||||||
"in"
|
|
||||||
"not"
|
|
||||||
"or"
|
|
||||||
"when"
|
|
||||||
"|"
|
|
||||||
"|>"
|
|
||||||
"||"
|
|
||||||
"|||"
|
|
||||||
"~>"
|
|
||||||
"~>>"
|
|
||||||
"~~~"
|
|
||||||
"~"
|
|
||||||
] @operator
|
|
||||||
|
|
||||||
; Do/Fn blocks
|
; Identifiers
|
||||||
[
|
(identifier) @variable
|
||||||
"do"
|
|
||||||
"end"
|
|
||||||
"fn"
|
|
||||||
] @keyword
|
|
||||||
|
|
||||||
; Exception blocks
|
; Unused identifiers
|
||||||
[
|
((identifier) @comment (#match? @comment
|
||||||
"catch"
|
"^_"
|
||||||
"rescue"
|
))
|
||||||
] @exception
|
|
||||||
|
|
||||||
; Conditional blocks
|
|
||||||
[
|
|
||||||
"else"
|
|
||||||
] @conditional
|
|
||||||
|
|
||||||
; Comments
|
; Comments
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
; Parser errors
|
; Strings
|
||||||
(ERROR) @error
|
(string) @string
|
||||||
|
|
||||||
; Sigils
|
|
||||||
(sigil (sigil_name) @operator quoted_start: _ @operator quoted_end: _ @operator)
|
|
||||||
|
|
||||||
; Modules
|
; Modules
|
||||||
(alias) @type
|
(alias) @type
|
||||||
|
|
||||||
; Atoms
|
; Atoms & Keywords
|
||||||
[
|
[
|
||||||
(atom)
|
(atom)
|
||||||
(quoted_atom)
|
(quoted_atom)
|
||||||
|
(keyword)
|
||||||
|
(quoted_keyword)
|
||||||
] @symbol
|
] @symbol
|
||||||
|
|
||||||
; Keywords
|
|
||||||
(keyword) @symbol
|
|
||||||
|
|
||||||
; Strings
|
|
||||||
(string) @string
|
|
||||||
|
|
||||||
; Interpolation
|
; Interpolation
|
||||||
(interpolation "#{" @string.escape (_)? "}" @string.escape)
|
(interpolation "#{" @string.escape "}" @string.escape)
|
||||||
|
|
||||||
; Escape sequences
|
; Escape sequences
|
||||||
(escape_sequence) @string.escape
|
(escape_sequence) @string.escape
|
||||||
|
|
@ -137,6 +68,21 @@
|
||||||
; Nil
|
; Nil
|
||||||
(nil) @constant.builtin
|
(nil) @constant.builtin
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
(operator_identifier) @operator
|
||||||
|
|
||||||
|
(unary_operator
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
|
(binary_operator
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
|
(dot
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
|
(stab_clause
|
||||||
|
operator: _ @operator)
|
||||||
|
|
||||||
; Calling a local function
|
; Calling a local function
|
||||||
(call target: (identifier) @function)
|
(call target: (identifier) @function)
|
||||||
|
|
||||||
|
|
@ -146,48 +92,51 @@
|
||||||
(_)
|
(_)
|
||||||
] right: (identifier) @function) (arguments))
|
] right: (identifier) @function) (arguments))
|
||||||
|
|
||||||
; Module attributes
|
|
||||||
(unary_operator operator: "@" @constant operand: [
|
|
||||||
(identifier) @constant
|
|
||||||
(call target: (identifier) @constant)
|
|
||||||
])
|
|
||||||
|
|
||||||
; Unused identifiers
|
|
||||||
((identifier) @comment (#match? @comment
|
|
||||||
"^_([^_].*)?$"
|
|
||||||
))
|
|
||||||
|
|
||||||
; Calling a local def function
|
; Calling a local def function
|
||||||
(call target: ((identifier) @keyword.function (#match? @keyword.function
|
(call target: ((identifier) @keyword.function (#any-of? @keyword.function
|
||||||
"^def(.*)?$"
|
"def"
|
||||||
)) (arguments (identifier) @function)?)
|
"defdelegate"
|
||||||
|
"defexception"
|
||||||
|
"defguard"
|
||||||
|
"defguardp"
|
||||||
|
"defimpl"
|
||||||
|
"defmacro"
|
||||||
|
"defmacrop"
|
||||||
|
"defmodule"
|
||||||
|
"defn"
|
||||||
|
"defnp"
|
||||||
|
"defoverridable"
|
||||||
|
"defp"
|
||||||
|
"defprotocol"
|
||||||
|
"defstruct"
|
||||||
|
)) (arguments [
|
||||||
|
(identifier) @function
|
||||||
|
(binary_operator left: (identifier) @function operator: "when")
|
||||||
|
])?)
|
||||||
|
|
||||||
; Conditionals
|
; Kernel Keywords & Special Forms
|
||||||
(call target: (identifier) @conditional (#any-of? @conditional
|
(call target: ((identifier) @keyword (#any-of? @keyword
|
||||||
|
"alias"
|
||||||
"case"
|
"case"
|
||||||
"cond"
|
"cond"
|
||||||
"if"
|
|
||||||
"receive"
|
|
||||||
"unless"
|
|
||||||
"with"
|
|
||||||
))
|
|
||||||
|
|
||||||
; Comprehensions
|
|
||||||
(call target: (identifier) @repeat (#any-of? @repeat
|
|
||||||
"for"
|
|
||||||
))
|
|
||||||
|
|
||||||
; Exceptions
|
|
||||||
(call target: (identifier) @exception (#any-of? @exception
|
|
||||||
"after"
|
|
||||||
"catch"
|
|
||||||
"else"
|
"else"
|
||||||
|
"for"
|
||||||
|
"if"
|
||||||
|
"import"
|
||||||
|
"quote"
|
||||||
"raise"
|
"raise"
|
||||||
|
"receive"
|
||||||
|
"require"
|
||||||
"reraise"
|
"reraise"
|
||||||
"rescue"
|
"super"
|
||||||
"throw"
|
"throw"
|
||||||
"try"
|
"try"
|
||||||
))
|
"unless"
|
||||||
|
"unquote"
|
||||||
|
"unquote_splicing"
|
||||||
|
"use"
|
||||||
|
"with"
|
||||||
|
)))
|
||||||
|
|
||||||
; Special constants
|
; Special constants
|
||||||
((identifier) @constant.builtin (#any-of? @constant.builtin
|
((identifier) @constant.builtin (#any-of? @constant.builtin
|
||||||
|
|
@ -197,3 +146,78 @@
|
||||||
"__MODULE__"
|
"__MODULE__"
|
||||||
"__STACKTRACE__"
|
"__STACKTRACE__"
|
||||||
))
|
))
|
||||||
|
|
||||||
|
; Reserved Keywords
|
||||||
|
[
|
||||||
|
"after"
|
||||||
|
"and"
|
||||||
|
"catch"
|
||||||
|
"do"
|
||||||
|
"end"
|
||||||
|
"fn"
|
||||||
|
"in"
|
||||||
|
"not"
|
||||||
|
"or"
|
||||||
|
"rescue"
|
||||||
|
"when"
|
||||||
|
"else"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; Capture Operator
|
||||||
|
(unary_operator
|
||||||
|
operator: "&"
|
||||||
|
operand: [
|
||||||
|
(integer) @operator
|
||||||
|
(binary_operator
|
||||||
|
left: [
|
||||||
|
(call target: (dot left: (_) right: (identifier) @function))
|
||||||
|
(identifier) @function
|
||||||
|
]
|
||||||
|
operator: "/"
|
||||||
|
right: (integer) @operator
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
|
; Module attributes
|
||||||
|
(unary_operator
|
||||||
|
operator: "@" @constant
|
||||||
|
operand: [
|
||||||
|
(identifier) @constant
|
||||||
|
(call target: (identifier) @constant)
|
||||||
|
])
|
||||||
|
|
||||||
|
; Documentation
|
||||||
|
(unary_operator
|
||||||
|
operator: "@" @comment
|
||||||
|
operand: (call
|
||||||
|
target: ((identifier) @comment) @_identifier
|
||||||
|
(arguments
|
||||||
|
[
|
||||||
|
(string) @comment
|
||||||
|
(charlist) @comment
|
||||||
|
(sigil
|
||||||
|
quoted_start: _ @comment
|
||||||
|
quoted_end: _ @comment) @comment
|
||||||
|
(boolean) @comment
|
||||||
|
]))
|
||||||
|
(#any-of? @_identifier "moduledoc" "typedoc" "doc"))
|
||||||
|
|
||||||
|
; Sigils
|
||||||
|
(sigil
|
||||||
|
"~" @string.special
|
||||||
|
((sigil_name) @string.special) @_sigil_name
|
||||||
|
quoted_start: _ @string.special
|
||||||
|
quoted_end: _ @string.special
|
||||||
|
((sigil_modifiers) @string.special)?
|
||||||
|
(#not-any-of? @_sigil_name "s" "S"))
|
||||||
|
|
||||||
|
(sigil
|
||||||
|
"~" @string
|
||||||
|
((sigil_name) @string) @_sigil_name
|
||||||
|
quoted_start: _ @string
|
||||||
|
quoted_end: _ @string
|
||||||
|
((sigil_modifiers) @string)?
|
||||||
|
(#any-of? @_sigil_name "s" "S")) @string
|
||||||
|
|
||||||
|
; Parser errors
|
||||||
|
(ERROR) @error
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,10 @@
|
||||||
(sigil_name) @_sigil_name
|
(sigil_name) @_sigil_name
|
||||||
(quoted_content) @zig
|
(quoted_content) @zig
|
||||||
(#eq? @_sigil_name "Z"))
|
(#eq? @_sigil_name "Z"))
|
||||||
|
|
||||||
|
(sigil
|
||||||
|
(sigil_name) @_sigil_name
|
||||||
|
(quoted_content) @regex
|
||||||
|
(#any-of? @_sigil_name "r" "R"))
|
||||||
|
|
||||||
|
(comment) @comment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue