From fdcd461e65aebc8432e4fbfd51b10856fcb65605 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 14 Apr 2023 11:41:20 -0500 Subject: Update tree-sitter-erlang and highlights A few changes: * 0-arity type specs like the following previously would not have the expected 'variable.parameter' highlighting for the return type: -spec foo() -> Value when Value :: term(). * Highlight module, type and function docs as documentation comments and inject markdown into them. * Replace `#match?` predicates with `#any-of?` where possible. * Remove custom auto-pairs. Now that Erlang uses markdown for documentation, the asciidoc-style backtick-singlequote pair is no longer useful. --- runtime/queries/erlang/highlights.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'runtime/queries/erlang/highlights.scm') diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm index 6d0ec36d..f09f6104 100644 --- a/runtime/queries/erlang/highlights.scm +++ b/runtime/queries/erlang/highlights.scm @@ -3,7 +3,7 @@ (attribute name: (atom) @keyword (arguments (atom) @namespace) - (#match? @keyword "(module|behaviou?r)")) + (#any-of? @keyword "module" "behaviour" "behavior")) (attribute name: (atom) @keyword @@ -50,12 +50,20 @@ name: (atom) @keyword (arguments (_) @keyword.directive) - (#match? @keyword "ifn?def")) + (#any-of? @keyword "ifndef" "ifdef")) (attribute name: (atom) @keyword module: (atom) @namespace - (#match? @keyword "(spec|callback)")) + (#any-of? @keyword "spec" "callback")) + +(attribute + name: (atom) @keyword + (arguments [ + (string) + (sigil) + ] @comment.block.documentation) + (#any-of? @keyword "doc" "moduledoc")) ; Functions (function_clause name: (atom) @function) @@ -84,7 +92,7 @@ ((attribute name: (atom) @keyword (stab_clause - pattern: (arguments (variable) @variable.parameter) + pattern: (arguments (variable)? @variable.parameter) body: (variable)? @variable.parameter)) (#match? @keyword "(spec|callback)")) ; functions -- cgit v1.2.3-70-g09d2