fix: Elixir non-doc sigils will no longer be flickering

It also adds support for colouring documentation metadata attributes
(ex. `@doc foo: :bar`).
This commit is contained in:
Łukasz Niemier 2021-10-20 13:20:05 +02:00 committed by Santos Gallegos
parent cfce9a58f3
commit 2c2d4d89fd
2 changed files with 27 additions and 31 deletions

View file

@ -40,7 +40,7 @@
; Atoms & Keywords ; Atoms & Keywords
[ [
(atom) (atom)
(quoted_atom) (quoted_atom)
(keyword) (keyword)
(quoted_keyword) (quoted_keyword)
] @symbol ] @symbol
@ -84,11 +84,11 @@
(stab_clause operator: _ @operator) (stab_clause operator: _ @operator)
; Local Function Calls ; Local Function Calls
(call target: (identifier) @function) (call target: (identifier) @function)
; Remote Function Calls ; Remote Function Calls
(call target: (dot left: [ (call target: (dot left: [
(atom) @type (atom) @type
(_) (_)
] right: (identifier) @function) (arguments)) ] right: (identifier) @function) (arguments))
@ -154,7 +154,7 @@
"do" "do"
"end" "end"
"fn" "fn"
"rescue" "rescue"
"when" "when"
"else" "else"
] @keyword ] @keyword
@ -181,38 +181,34 @@
]) ])
; Module attributes ; Module attributes
(unary_operator (unary_operator
operator: "@" @constant operator: "@" @constant
operand: [ operand: [
(identifier) @constant (identifier) @constant
(call target: (identifier) @constant)]) (call target: (identifier) @constant)])
; Sigils ; Sigils
(sigil (sigil
"~" @string.special "~" @string.special
((sigil_name) @string.special) @_sigil_name ((sigil_name) @string.special) @_sigil_name
quoted_start: _ @string.special quoted_start: _ @string.special
quoted_end: _ @string.special quoted_end: _ @string.special
((sigil_modifiers) @string.special)? ((sigil_modifiers) @string.special)?
(#not-any-of? @_sigil_name "s" "S")) (#not-any-of? @_sigil_name "s" "S"))
(sigil (sigil
"~" @string "~" @string
((sigil_name) @string) @_sigil_name ((sigil_name) @string) @_sigil_name
quoted_start: _ @string quoted_start: _ @string
(quoted_content) @string (quoted_content) @string
quoted_end: _ @string quoted_end: _ @string
((sigil_modifiers) @string)? ((sigil_modifiers) @string)?
(#any-of? @_sigil_name "s" "S")) (#any-of? @_sigil_name "s" "S"))
; Documentation ; Documentation
(unary_operator (unary_operator
operator: "@" @comment operator: "@" @comment
operand: (call operand: (call
target: (((identifier) @comment) @_identifier) target: ((identifier) @_identifier)
(arguments [ _) @comment
(string) @comment
(charlist) @comment
(boolean) @comment
]))
(#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc"))

View file

@ -1,21 +1,21 @@
(sigil (sigil
(sigil_name) @_sigil_name (sigil_name) @_sigil_name
(quoted_content) @surface (quoted_content) @surface
(#eq? @_sigil_name "F")) (#eq? @_sigil_name "F"))
(sigil (sigil
(sigil_name) @_sigil_name (sigil_name) @_sigil_name
(quoted_content) @heex (quoted_content) @heex
(#eq? @_sigil_name "H")) (#eq? @_sigil_name "H"))
(sigil (sigil
(sigil_name) @_sigil_name (sigil_name) @_sigil_name
(quoted_content) @zig (quoted_content) @zig
(#eq? @_sigil_name "Z")) (#eq? @_sigil_name "Z"))
(sigil (sigil
(sigil_name) @_sigil_name (sigil_name) @_sigil_name
(quoted_content) @regex (quoted_content) @regex
(#any-of? @_sigil_name "r" "R")) (#any-of? @_sigil_name "r" "R"))
(comment) @comment (comment) @comment