emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter

Home Page:https://emacs-tree-sitter.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Faces: the inherit from default is problematic in some cases. Does it have benefits?

WJCFerguson opened this issue · comments

Hi - two faces have :inherit default which causes them to render badly if the background is other than the default.

  • tree-sitter-hl-face:embedded
  • tree-sitter-hl-face:punctuation

E.g. in org-mode source blocks, as is probably quite common, I highlight source blocks with a different background color:

image

If I customize away the inherit it becomes:

image

(Note the spacing got slightly messed by it too)

There may be some problem the :inherit default fixes, but I feel like it would be better if they weren't there(?).

The embedded face is for things like string interpolation, where :inherit default is intended to "reset" the background.

I don't remember why punctuation also has it though. Maybe it was an oversight.

The messed spacing is probably due to your org-block and default faces having different sizes.

commented

This is happening for me without tree-sitter-hl-mode ever being called, which in itself feels problematic. I have to not load tree-sitter to prevent it from happening.

Even if these punctuation faces are important, they should not be applied outside of the applicable mode(s)

Edit: Ok these are likely being enabled in the background with the use of a temporary buffer that captures the syntax highlighting. If your org-mode background for codeblocks deviates from the source-code background, you get these weird highlighting errors.

I have some problems when I use variable-pitch-mode in the org mode and fixed-pitch-mode in the blocks. I set "EB Garamond" for variable-pitch and "Fira Code" for fixed-pitch. The brackets and delimiters use the "EB Garamond" fonts instead of "Fira Code", while others are right. I found these two faces inherit from "default" while others are not.

image

How can I solve this?