Skip to content

Commit

Permalink
Apply comment face after function faces
Browse files Browse the repository at this point in the history
Function faces are more specific, so moving comment face matches to
after the function matches means we don't apply comment-face to
function names. This fixes issue #40.
  • Loading branch information
wkirschbaum committed Nov 24, 2023
1 parent d56d591 commit 7025435
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions elixir-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,6 @@ This variable is obsolete. Use elixir-ts-sigil-name-face instead."

(defvar elixir-ts--font-lock-settings
(treesit-font-lock-rules
:language 'elixir
:feature 'elixir-comment
'((comment) @font-lock-comment-face
((identifier) @font-lock-comment-face
(:match "^_" @font-lock-comment-face)))

:language 'elixir
:feature 'elixir-function-name
`((call target: (identifier) @target-identifier
Expand Down Expand Up @@ -414,6 +408,14 @@ This variable is obsolete. Use elixir-ts-sigil-name-face instead."
(do_block)
(:match ,elixir-ts--definition-keywords-re @target-identifier)))

;; A function definition like 'def _foo' is valid, but we should
;; not apply the comment-face unless its a non-function identifier.
:language 'elixir
:feature 'elixir-comment
'((comment) @font-lock-comment-face
((identifier) @font-lock-comment-face
(:match "^_" @font-lock-comment-face)))

:language 'elixir
:feature 'elixir-function-call
`((call target: (identifier)
Expand Down

0 comments on commit 7025435

Please sign in to comment.