Open WhyNotHugo opened 6 months ago
Hi, I recently came across this issue and I believe I found a solution.
According to the documentation, delta
is able to read .tmTheme
files if you use bat
to build the theme for you. If you have bat
installed, try following these steps:
bat
's theme config folder. On macOS, this would be ~/.config/bat/themes
(refer to the "Adding new themes" section in the README).$ mkdir -p "$(bat --config-dir)/themes"
$ cd "$(bat --config-dir)/themes"
$ git clone https://github.com/obergodmar/kanagawa-tmTheme.git kanagawa
bat
to update the binary cache with the new theme:$ bat cache --build
bat
, run the following:$ bat --list-themes
... omitted lines ...
Theme: Kanagawa
// Output the square of a number.
fn print_square(num: f64) {
let result = f64::powf(num, 2.0);
println!("The square of {:.2} is {:.2}.", num, result);
}
... omitted lines ...
delta
should be able to pick up this theme. You can verify this by running the following:$ delta --show-syntax-themes
... omitted lines ...
Syntax theme: Kanagawa
example.rs
──────────
───┐
1: │
───┘
// Output the square of a number.
fn print_square(num: f64) {
let result = f64::powf(num, 2.0);
println!("The square of {:.2} is {:.2}.", num, result);
// Output the cube of a number.
fn print_cube(num: f64) {
let result = f64::powf(num, 3.0);
println!("The cube of {:.2} is {:.2}.", num, result);
... omitted lines ...
~/.gitconfig
or ~/.config/git/config
file with the following changes: [delta]
navigate = true
+ syntax-theme = Kanagawa
delta
should now have this theme applied the next time you run it.Hope this helps 🙂
delta distinguishes between "syntax themes" and "themes" (or styles). While syntax themes can be read from bat
, styles can not. Syntax themes only apply to the foreground color (the actual syntax) while the style can apply diff-related styling such as added/removed.
It would be great if there was a delta style that matches the syntax theme (on my current machine the default style has bad contrast with the kanagawa syntax theme).
The README refers to the tmTheme for delta:
https://github.com/rebelot/kanagawa.nvim/blob/bfa818c7bf6259152f1d89cf9fbfba3554c93695/README.md?plain=1#L371
It's an XML file:
https://github.com/rebelot/kanagawa.nvim/blob/bfa818c7bf6259152f1d89cf9fbfba3554c93695/extras/kanagawa.tmTheme#L1-L450
But themes for delta are not XML or anything similar at all:
https://github.com/dandavison/delta/blob/main/themes.gitconfig