From 2c2d4d89fd8111a1001603879af68d35dbf57739 Mon Sep 17 00:00:00 2001 From: Ɓukasz Niemier Date: Wed, 20 Oct 2021 13:20:05 +0200 Subject: fix: Elixir non-doc sigils will no longer be flickering It also adds support for colouring documentation metadata attributes (ex. `@doc foo: :bar`). --- queries/elixir/highlights.scm | 34 +++++++++++++++------------------- queries/elixir/injections.scm | 24 ++++++++++++------------ 2 files changed, 27 insertions(+), 31 deletions(-) (limited to 'queries') diff --git a/queries/elixir/highlights.scm b/queries/elixir/highlights.scm index dff497dbf..b69bdbcdd 100644 --- a/queries/elixir/highlights.scm +++ b/queries/elixir/highlights.scm @@ -40,7 +40,7 @@ ; Atoms & Keywords [ (atom) - (quoted_atom) + (quoted_atom) (keyword) (quoted_keyword) ] @symbol @@ -84,11 +84,11 @@ (stab_clause operator: _ @operator) ; Local Function Calls -(call target: (identifier) @function) +(call target: (identifier) @function) ; Remote Function Calls (call target: (dot left: [ - (atom) @type + (atom) @type (_) ] right: (identifier) @function) (arguments)) @@ -154,7 +154,7 @@ "do" "end" "fn" - "rescue" + "rescue" "when" "else" ] @keyword @@ -181,38 +181,34 @@ ]) ; Module attributes -(unary_operator - operator: "@" @constant +(unary_operator + operator: "@" @constant operand: [ (identifier) @constant (call target: (identifier) @constant)]) ; Sigils -(sigil +(sigil "~" @string.special ((sigil_name) @string.special) @_sigil_name - quoted_start: _ @string.special + quoted_start: _ @string.special quoted_end: _ @string.special ((sigil_modifiers) @string.special)? (#not-any-of? @_sigil_name "s" "S")) -(sigil +(sigil "~" @string ((sigil_name) @string) @_sigil_name - quoted_start: _ @string + quoted_start: _ @string (quoted_content) @string quoted_end: _ @string ((sigil_modifiers) @string)? (#any-of? @_sigil_name "s" "S")) ; Documentation -(unary_operator - operator: "@" @comment - operand: (call - target: (((identifier) @comment) @_identifier) - (arguments [ - (string) @comment - (charlist) @comment - (boolean) @comment - ])) +(unary_operator + operator: "@" @comment + operand: (call + target: ((identifier) @_identifier) + _) @comment (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) diff --git a/queries/elixir/injections.scm b/queries/elixir/injections.scm index 0451ec8d2..00d98b32e 100644 --- a/queries/elixir/injections.scm +++ b/queries/elixir/injections.scm @@ -1,21 +1,21 @@ -(sigil - (sigil_name) @_sigil_name - (quoted_content) @surface +(sigil + (sigil_name) @_sigil_name + (quoted_content) @surface (#eq? @_sigil_name "F")) -(sigil - (sigil_name) @_sigil_name - (quoted_content) @heex +(sigil + (sigil_name) @_sigil_name + (quoted_content) @heex (#eq? @_sigil_name "H")) -(sigil - (sigil_name) @_sigil_name - (quoted_content) @zig +(sigil + (sigil_name) @_sigil_name + (quoted_content) @zig (#eq? @_sigil_name "Z")) -(sigil - (sigil_name) @_sigil_name - (quoted_content) @regex +(sigil + (sigil_name) @_sigil_name + (quoted_content) @regex (#any-of? @_sigil_name "r" "R")) (comment) @comment -- cgit v1.2.3-70-g09d2