Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finer syntax highlighting #49

Open
aciceri opened this issue Oct 11, 2024 · 2 comments
Open

Finer syntax highlighting #49

aciceri opened this issue Oct 11, 2024 · 2 comments

Comments

@aciceri
Copy link

aciceri commented Oct 11, 2024

After a brief period using Helix and coming back to Emacs I noticed that Helix highlights more stuff than this mode.

Helix:
image
Emacs:
image

(there could be other differences I didn't notice, I tried looking for where this is defined in the Helix source without luck)

What do you think about supporting this? Personally I believe I prefer the Helix way.
I tried adding the following font lock rules and it seems to behave as Helix.

   :language 'nix
   :feature '<feature-name>
   :override t
   `((formal) @font-lock-type-face)

   :language 'nix
   :feature '<feature-name>
   :override t
   `((attrpath) @font-lock-function-name-face)

My questions are:

  • Should I create new features or use an existing one? Two new ones?
  • In case, should we add a new list to treesit-font-lock-feature-list or add these features to the last one?
  • Which faces? Looking at the default font lock faces I can't find anything that makes sense with "formal" nodes (function arguments) and "attrpath" nodes so in the example above I used two faces that shouldn't be used for Nix

@remi-gelinas @purcell I can open PR if you like this

EDIT: just noticed that there other finer highlights provided by Helix, if you like the idea I'll prepare a draft PR with all the ones I find

@purcell
Copy link
Member

purcell commented Oct 12, 2024

The more highlighting, the better, IMO. Emacs treesit supports configurable font lock levels via the standard treesit-font-lock-level variable, so my view is that when that variable is set to 4 (the max) we should highlight as much as possible — there's an entry in treesit-font-lock-feature-list for each level, so the approach here would be to add more items to that final (4th) list. The faces you picked seem fine to me, and defining new features is the way to go.

@remi-gelinas
Copy link
Collaborator

100% agree with @purcell - the more the better. I'd accept a PR with these additions and tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants