dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
22.74k stars 380 forks source link

🐛 Emacs lisp incorrect highlighting #1580

Closed gekoke closed 10 months ago

gekoke commented 10 months ago

I don't know how delta is implemented and I'm assuming this is likely an upstream issue - so forgive me in advance if that is the case.

When diffing Emacs lisp, hyphens in identifiers are highlighted as if they were (subtraction) operators.

image

In the example above, I would expect scroll-bar-mode to be uniform in color, as the - characters are part of the function's identifier.

The - operator is highlighted correctly when used for negative values like -1.

dandavison commented 10 months ago

Hi @gekoke, yes I see the same thing. In addition I see that / when used in a variable name is highlighted in red, and also (even worse?) strings like and and replace that are names of (emacs) lisp functions.

image

The chain of dependencies is slightly convoluted, but I believe these must be bugs in the sublime syntax definition: https://github.com/sublimehq/Packages/tree/759d6eed9b4beed87e602a23303a121c3a6c2fb3/Lisp

For the record: delta uses a Rust library called syntect to apply syntax highlighting, and syntect uses these syntax definitions written in a YAML DSL format that is associated with the Sublime text editor. (And also associated with TextMate?). https://github.com/sharkdp/bat/ is a Rust tool that takes the same approach (in fact delta just followed bat's lead here). Furthermore, the bat project has put together a very convenient collection of syntax definitions (and theme definitions): https://github.com/sharkdp/bat/tree/master/assets and delta contains code shared with the bat project to build and use those asset collection).

If you could address this upstream that would be fantastic. Maybe .el shouldn't map to a generic Lisp syntax and someone has created a separate Emacs-Lisp syntax definition? But then again, Emacs-Lisp authors aren't known for being fans of Sublime or TextMate. I'll close this since I think there is no direct delta development indicated.