dandavison / magit-delta

Use delta (https://github.com/dandavison/delta) when viewing diffs in Magit
MIT License
288 stars 10 forks source link

Disabling magit-delta-mode breaks normal magit highlighting #15

Open The-Compiler opened 4 years ago

The-Compiler commented 4 years ago

Last one for now, I promise! :see_no_evil:

This might actually be an issue in my config somehow, though I'd appreciate some pointers on what's going wrong.

Same setup as in #12 again - I have (magit-delta-mode) in my Doom emacs config.el to enable it by default. When I then run M-x (magit-delta-mode) to disable it, magit's normal highlighting doesn't work anymore:

image

When I remove (magit-delta-mode) from my config entirely and restart emacs, it does work however:

image

dandavison commented 4 years ago

Thanks! Hm, I'll think about how to debug this. I just double-checked and this is not happening for me.

innerout commented 3 years ago

I have been trying to use magit-delta and I encountered the same problem. I am using doom-emacs with the magit module enabled and this problem is reproduced even with the vanilla config of doom-emacs. Also when there are many staged and unstaged files and I try to unstage a staged file the magit-status buffer becomes borked with magit-delta. If magit-delta is unloaded everything works as it should.

My gitconfig

[core]
    editor = emacs
    pager = delta
[interactive]
        diffFilter = delta --color-only
[delta]
        features = side-by-side line-numbers decorations
        whitespace-error-style = 22 reverse
[delta "decorations"]
        commit-decoration-style = bold yellow box ul
        file-style = bold yellow ul
        file-decoration-style = none
[color "status"]
    header = green normal
    added = green normal bold
    updated = green normal bold
    changed = yellow normal bold
    untracked = cyan normal bold
    branch = magenta normal bold
    nobranch = normal normal bold
    unmerged = red normal bold
willbush commented 3 years ago

Does magit-refresh after disabling magit-delta-mode fix the syntax highlighting for you guys?

For me either I lose all color or the color doesn't look right until I magit-refresh when toggling magit-delta-mode interactively.

I just made this function and bound it to a key to solve the issue:

(defun my/magit-delta-toggle ()
  "Toggle magit-delta-mode and refresh magit."
  (interactive)
  (progn
    (call-interactively 'magit-delta-mode)
    (magit-refresh)))

I mainly want to be able to disable magit-delta-mode in order to copy the + / - signs in front of the diff sometimes. Is there a way to retain + / - functionality with magit-delta-mode?

I'm using default delta settings with the only delta related thing in my git config being:

[interactive]
    diffFilter = "delta --color-only"

I haven't messed with the default value for magit-delta-delta-args either. Here's my entire magit-delta config in vanilla emacs:

(use-package magit-delta
  :if (executable-find "delta")
  :hook (magit-mode . magit-delta-mode)
  :config

  (defun my/magit-delta-toggle ()
    "Toggle magit-delta-mode and refresh magit."
    (interactive)
    (progn
      (call-interactively 'magit-delta-mode)
      (magit-refresh)))

  (general-def
    :prefix ","
    :states 'normal
    :keymaps 'magit-mode-map
    "t" '(my/magit-delta-toggle :wk "toggle magit-delta")))