aboutsummaryrefslogtreecommitdiffstats
path: root/queries/elixir
diff options
context:
space:
mode:
authorConnor Lay (Clay) <connorlay@pm.me>2021-10-05 19:35:18 -0700
committerStephan Seitz <stephan.seitz@fau.de>2021-10-13 01:31:49 +0200
commite0125a5a1ca685175e4cb54b416aa6dc2457da18 (patch)
tree4e1a329d79cce4f7e68377fb5f9d1d78ece1065e /queries/elixir
parentSwitch to official elixir-lang parser (diff)
downloadnvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar.gz
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar.bz2
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar.lz
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar.xz
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.tar.zst
nvim-treesitter-e0125a5a1ca685175e4cb54b416aa6dc2457da18.zip
Update highlights for new elixir-lang parser
Diffstat (limited to 'queries/elixir')
-rw-r--r--queries/elixir/highlights.scm235
1 files changed, 140 insertions, 95 deletions
diff --git a/queries/elixir/highlights.scm b/queries/elixir/highlights.scm
index 413ae6cc8..408d271b8 100644
--- a/queries/elixir/highlights.scm
+++ b/queries/elixir/highlights.scm
@@ -1,5 +1,10 @@
-(ERROR) @error
+; Punctuation delimiters
+[
+ "%"
+ ","
+] @punctuation.delimiter
+; Punctuation brackets
[
"("
")"
@@ -11,144 +16,184 @@
"}"
] @punctuation.bracket
+; Operators
[
- ","
- "->"
+ "!"
+ "!="
+ "!=="
+ "&"
+ "&&"
+ "&&&"
+ "*"
+ "**"
+ "+"
+ "++"
+ "+++"
+ "-"
+ "--"
+ "---"
"."
-] @punctuation.delimiter
-
-[
- (sigil_start)
- (sigil_end)
- (heredoc_start)
- (heredoc_end)
-] @punctuation.special
-
-(interpolation ["#{" "}"] @punctuation.special)
+ ".."
+ "/"
+ "//"
+ "::"
+ "<"
+ "<-"
+ "<<<"
+ "<<~"
+ "<="
+ "<>"
+ "<|>"
+ "<~"
+ "<~>"
+ "="
+ "=="
+ "==="
+ "=>"
+ "=~"
+ ">"
+ ">="
+ ">>>"
+ "@"
+ "^"
+ "and"
+ "in"
+ "not"
+ "or"
+ "when"
+ "|"
+ "|>"
+ "||"
+ "|||"
+ "~>"
+ "~>>"
+ "~~~"
+ "~"
+] @operator
+; Do/Fn blocks
[
- "after"
- "and"
- "catch"
"do"
- "else"
"end"
"fn"
- "in"
- "not in"
- "not"
- "or"
- "rescue"
- "when"
] @keyword
+; Exception blocks
[
- (comment)
- (unused_identifier)
-] @comment
-
-[
- (heredoc_content)
- (sigil_content)
- (string)
-] @string
-
-; __MODULE__ and friends
-(special_identifier) @constant.builtin
-
-(map ["%{" "}"] @constructor)
+ "catch"
+ "rescue"
+] @exception
-(struct ["%" "{" "}"] @constructor)
+; Conditional blocks
+[
+ "else"
+] @conditional
-(binary_op operator: _ @operator)
+; Comments
+(comment) @comment
-(unary_op operator: _ @operator)
+; Parser errors
+(ERROR) @error
-(atom) @symbol
+; Sigils
+(sigil (sigil_name) @operator quoted_start: _ @operator quoted_end: _ @operator)
-(keyword) @parameter
+; Modules
+(alias) @type
+; Atoms
[
- (true)
- (false)
-] @boolean
-
-(nil) @constant.builtin
+ (atom)
+ (quoted_atom)
+] @symbol
-(sigil) @string.special
+; Keywords
+(keyword) @symbol
-(identifier) @variable
+; Strings
+(string) @string
-(module) @type
+; Interpolation
+(interpolation "#{" @string.escape (_)? "}" @string.escape)
-(function_identifier) @function
+; Escape sequences
+(escape_sequence) @string.escape
+; Integers
(integer) @number
+; Floats
(float) @float
+; Characters
[
- (sigil_start)
- (sigil_end)
-] @string.special
+ (char)
+ (charlist)
+] @character
-; Module attributes as "attributes"
-(unary_op operator: "@" @attribute [
- (call function: (function_identifier) @attribute)
- (identifier) @attribute
-])
+; Booleans
+(boolean) @boolean
-; Erlang modules (when they are the remote of a function call) are highlighted as Elixir modules
-(dot_call remote: (atom) @type)
+; Nil
+(nil) @constant.builtin
-(call (function_identifier) @keyword.function (#any-of? @keyword.function
- "def"
- "defdelegate"
- "defexception"
- "defguard"
- "defguardp"
- "defimpl"
- "defmacro"
- "defmacrop"
- "defmodule"
- "defoverridable"
- "defp"
- "defprotocol"
- "defstruct"
-) [(identifier) @function (_)]) ; 0-arity function def without parens
+; Calling a local function
+(call target: (identifier) @function)
-(call (function_identifier) @include (#any-of? @include
- "alias"
- "import"
- "require"
- "use"
+; Calling a remote function
+(call target: (dot left: [
+ (atom) @type
+ (_)
+] 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
+(call target: ((identifier) @keyword.function (#match? @keyword.function
+ "^def(.*)?$"
+)) (arguments (identifier) @function)?)
-(call (function_identifier) @conditional (#any-of? @conditional
+; Conditionals
+(call target: (identifier) @conditional (#any-of? @conditional
"case"
"cond"
- "else"
"if"
+ "receive"
"unless"
"with"
- "receive"
))
-(call (function_identifier) @exception (#any-of? @exception
+; Comprehensions
+(call target: (identifier) @repeat (#any-of? @repeat
+ "for"
+))
+
+; Exceptions
+(call target: (identifier) @exception (#any-of? @exception
+ "after"
+ "catch"
+ "else"
"raise"
"reraise"
+ "rescue"
"throw"
"try"
))
-(call (function_identifier) @repeat (#any-of? @repeat
- "for"
-))
-
-(call (function_identifier) @keyword.function (#any-of? @keyword.function
- "describe"
- "setup"
- "setup_all"
- "test"
- "using"
+; Special constants
+((identifier) @constant.builtin (#any-of? @constant.builtin
+ "__CALLER__"
+ "__DIR__"
+ "__ENV__"
+ "__MODULE__"
+ "__STACKTRACE__"
))