From cdd6c8d91e7b29e9587babce5919af800400f28d Mon Sep 17 00:00:00 2001
From: Michael Davis
Date: Tue, 20 Dec 2022 09:27:51 -0600
Subject: Update Erlang highlights

* Macros that start with underscore were incorrectly marked as
  'comment.unused' rather than 'keyword.directive' due to an ordering
  issue of those two patterns.
* Recognize escripts as Erlang by the shebang.
---
 languages.toml                        |  1 +
 runtime/queries/erlang/highlights.scm | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/languages.toml b/languages.toml
index 83a09b0b..2e6f5f95 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1317,6 +1317,7 @@ scope = "source.erlang"
 injection-regex = "erl(ang)?"
 file-types = ["erl", "hrl", "app", "rebar.config", "rebar.lock"]
 roots = ["rebar.config"]
+shebangs = ["escript"]
 comment-token = "%%"
 indent = { tab-width = 4, unit = "    " }
 language-server = { command = "erlang_ls" }
diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm
index 3f4ef4cb..741f5e54 100644
--- a/runtime/queries/erlang/highlights.scm
+++ b/runtime/queries/erlang/highlights.scm
@@ -65,6 +65,16 @@
 (function_capture module: (atom) @namespace)
 (function_capture function: (atom) @function)
 
+; Macros
+(macro
+  "?"+ @constant
+  name: (_) @constant
+  !arguments)
+
+(macro
+  "?"+ @keyword.directive
+  name: (_) @keyword.directive)
+
 ; Ignored variables
 ((variable) @comment.discard
  (#match? @comment.discard "^_"))
@@ -125,16 +135,6 @@
 (unary_operator operator: _ @operator)
 ["/" ":" "->"] @operator
 
-; Macros
-(macro
-  "?"+ @constant
-  name: (_) @constant
-  !arguments)
-
-(macro
-  "?"+ @keyword.directive
-  name: (_) @keyword.directive)
-
 ; Comments
 (tripledot) @comment.discard
 
-- 
cgit v1.2.3-70-g09d2