dandavison / delta

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

🚀 How can I wire `delta` into my COMMIT_EDITMSG? #517

Closed dycw closed 3 years ago

dycw commented 3 years ago

Hi, delta is amazing! However, is it possible to wire it into my COMMIT_EDITMSG so that I get the same amazing-ness when I have to write my commit message? I'm using vim in case that helps.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch test
# Your branch is ahead of 'master' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
#>      new file:   arst
#>      modified:   environment.yml
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/arst b/arst
new file mode 100644
index 0000000..bb397ef
--- /dev/null
+++ b/arst
@@ -0,0 +1 @@
+arst
diff --git a/environment.yml b/environment.yml
index f2df9e5..5dc12e9 100644
--- a/environment.yml
+++ b/environment.yml
@@ -2,6 +2,7 @@ name: dotfiles
-
 channels:
   - conda-forge
+  - anaconda
-
 dependencies:
   - python = 3.9
dandavison commented 3 years ago

Hi @dycw, thanks. Essentially, delta is a program that takes git/diff plain text input and returns it with ANSI color escape codes. So to get the colors etc in your text editor when it's displaying the commit message, your text editor would have to handle the color escape codes, like a terminal emulator does. I've implemented that for emacs, but I'm not a vim user, so I'm unclear how possible this is in vim. Could you try asking your question in this delta issue thread: https://github.com/dandavison/delta/issues/338, where there are several knowledgable delta+vim users?

dycw commented 3 years ago

Absolutely, thank you @dandavison for delta; one of my best finds in a decade of programming!

jessevdp commented 4 months ago

Hey, did anyone ever figure this out?

I'm really no expert in customizing vim, but I am used to the motions etc. so I use it as my editor of choice for CLI Git usage.

I think #338 spun off into a thread around much more advanced usage within Nvim etc.

But what about just simply using Delta to display the diffs when you git commit with EDITOR=vim?

dycw commented 4 months ago

I am using https://github.com/rhysd/committia.vim and it seems to work fine for me. @jessevdp