Skip to content

Weirdness with treesit font lock configuration #41

@1player

Description

@1player

I'm trying to tweak the font lock because I find by default this mode is highlighting every single word compared to elixir-mode, and it's too much for my eyes. I'd rather prefer normal identifier to be black, and color to be a sprinkle on top, not the main course :)

For that reason I'm using the treesit-font-lock-recompute-features function to disable highlighting of a few things and it does not work as expected. This is an example incantation that should disable highlighting of comments and strings:

  (defun fix-elixir-ts-font-lock ()
    (treesit-font-lock-recompute-features '() '(elixir-string elixir-comment)))
 (add-hook 'elixir-ts-mode-hook #'fix-elixir-ts-font-lock)

Yet strings and comments now instead of being unhighlighted (black) get another color. This is because they are also considered heex-attribute for some reason, which seems to be a catch-all rule that matches basically every single token in the document. If I also disable "heex-attribute" highlighting, everything works as expected. Like so:

(treesit-font-lock-recompute-features '() '(elixir-string elixir-comment heex-attribute))

It makes no sense that everything in an Elixir file is also marked as heex-attribute, so I believe there's a hidden bug either in the grammar or this mode, which would cause weird issues like this one. Also, I am testing with a LiveView module, so HEEX highlighting is enabled together with Elixir highlighting. You might not be able to reproduce on a plain Elixir file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions