Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
;
in
{
kanagawa = import ./kanagawa.nix;
kanagawa = import ./kanagawa;

mkProgramOption =
{
Expand Down
19 changes: 19 additions & 0 deletions lib/kanagawa/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Kanagawa palette + per-flavor semantic theme tables.
#
# `lib.kanagawa` spreads the raw name→hex palette at the top level (so existing
# consumers like `lib.kanagawa.sumiInk3` and `nix eval --file palette.nix` keep
# working) and adds `lib.kanagawa.themes.<flavor>` — the editor/syn/diff/chrome
# role tables consumed by pkgs/yazi-kanagawa-flavor. See themes/mk.nix.
let
palette = import ./palette.nix;
theme = name: import (./themes + "/${name}.nix") { inherit palette; };
in
palette
// {
themes = {
wave = theme "wave";
dragon = theme "dragon";
lotus = theme "lotus";
kris = theme "kris";
};
}
File renamed without changes.
46 changes: 46 additions & 0 deletions lib/kanagawa/themes/dragon.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Canonical Kanagawa "dragon" — transcribed from kanagawa.nvim
# lua/kanagawa/themes.lua (dragon).
{ palette }:
let
p = palette;
in
import ./mk.nix {
ui = {
fg = p.dragonWhite;
fg_dim = p.oldWhite;
nontext = p.dragonBlack6;
bg = p.dragonBlack3;
bg_m1 = p.dragonBlack2;
bg_m3 = p.dragonBlack0;
bg_search = p.waveBlue2;
};
syn = {
string = p.dragonGreen2;
number = p.dragonPink;
constant = p.dragonOrange;
identifier = p.dragonYellow;
parameter = p.dragonGray;
fun = p.dragonBlue2;
keyword = p.dragonViolet;
operator = p.dragonRed;
type = p.dragonAqua;
regex = p.dragonRed;
deprecated = p.katanaGray;
comment = p.dragonAsh;
punct = p.dragonGray2;
special1 = p.dragonTeal;
special2 = p.dragonRed;
special3 = p.dragonRed;
};
vcs = {
added = p.autumnGreen;
removed = p.autumnRed;
changed = p.autumnYellow;
};
diff = {
add = p.winterGreen;
delete = p.winterRed;
change = p.winterBlue;
};
diag.hint = p.waveAqua1;
}
70 changes: 70 additions & 0 deletions lib/kanagawa/themes/kris.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Kanagawa "kris" — the personal flavor. NOT a canonical kanagawa.nvim variant:
# wave editor + wave syntax, but a dragon-family UI chrome (with a couple of
# deliberate cross-family picks, e.g. sumiInk0 for the status bar). Written as
# explicit literals rather than via ./mk.nix so it reproduces the long-standing
# flavor byte-for-byte; the canonical flavors recolor the same yazi layout.
{ palette }:
let
p = palette;
in
{
editor = {
background = p.sumiInk3;
foreground = p.fujiWhite;
caret = p.oldWhite;
invisibles = p.sumiInk6;
lineHighlight = p.waveBlue2;
selection = p.waveBlue2;
findHighlight = p.waveBlue2;
selectionBorder = p.dragonBlack2; # closest palette match to #222218
gutterForeground = p.sumiInk6;
};

# wave syn table (matches the user's neovim treesitter highlighting).
syn = {
string = p.springGreen;
number = p.sakuraPink;
constant = p.surimiOrange;
identifier = p.carpYellow;
parameter = p.oniViolet2;
fun = p.crystalBlue;
keyword = p.oniViolet;
operator = p.boatYellow2;
type = p.waveAqua2;
regex = p.boatYellow2;
deprecated = p.katanaGray;
comment = p.fujiGray;
punct = p.springViolet2;
special1 = p.springBlue;
special2 = p.waveRed;
special3 = p.peachRed;
variable = p.fujiWhite;
};

diff = {
add = p.winterGreen;
delete = p.winterRed;
change = p.winterBlue;
};

chrome = {
fg = p.dragonWhite;
on_accent = p.dragonBlack3;
bg_deep = p.dragonBlack0;
status_bg = p.sumiInk0;
accent = p.dragonBlue2;
green = p.dragonGreen2;
red = p.waveRed;
pink = p.dragonPink;
yellow = p.carpYellow;
blue = p.springBlue;
border = p.dragonAqua;
teal = p.waveAqua2;
peach = p.peachRed;
docs = p.waveAqua1;
gray = p.dragonGray;
faint = p.sumiInk6;
orphan = p.dragonRed;
exec = p.autumnGreen;
};
}
47 changes: 47 additions & 0 deletions lib/kanagawa/themes/lotus.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Canonical Kanagawa "lotus" (LIGHT) — transcribed from kanagawa.nvim
# lua/kanagawa/themes.lua (lotus). Light background; the shared mapper reads
# bg/fg from ui so the tmTheme inverts correctly.
{ palette }:
let
p = palette;
in
import ./mk.nix {
ui = {
fg = p.lotusInk1;
fg_dim = p.lotusInk2;
nontext = p.lotusViolet1;
bg = p.lotusWhite3;
bg_m1 = p.lotusWhite2;
bg_m3 = p.lotusWhite0;
bg_search = p.lotusBlue2;
};
syn = {
string = p.lotusGreen;
number = p.lotusPink;
constant = p.lotusOrange;
identifier = p.lotusYellow;
parameter = p.lotusBlue5;
fun = p.lotusBlue4;
keyword = p.lotusViolet4;
operator = p.lotusYellow2;
type = p.lotusAqua;
regex = p.lotusYellow2;
deprecated = p.lotusGray3;
comment = p.lotusGray3;
punct = p.lotusTeal1;
special1 = p.lotusTeal2;
special2 = p.lotusRed;
special3 = p.lotusRed;
};
vcs = {
added = p.lotusGreen2;
removed = p.lotusRed2;
changed = p.lotusYellow3;
};
diff = {
add = p.lotusGreen3;
delete = p.lotusRed4;
change = p.lotusCyan;
};
diag.hint = p.lotusAqua2;
}
60 changes: 60 additions & 0 deletions lib/kanagawa/themes/mk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Shared mapping from a Kanagawa flavor's semantic role tables (transcribed from
# kanagawa.nvim's lua/kanagawa/themes/*.lua) to the four sections the yazi flavor
# builder consumes:
#
# editor — tmTheme global editor colors (background, caret, selection, …)
# syn — tmTheme per-scope syntax foregrounds
# diff — tmTheme markup.{inserted,deleted,changed} backgrounds
# chrome — yazi UI element accents (mgr/mode/status/pick/which/… in flavor.toml)
#
# `ui`/`syn`/`vcs`/`diff`/`diag` are the kanagawa.nvim role tables for one flavor.
# The chrome mapping (which kanagawa role drives each yazi accent) is defined ONCE
# here and shared by the canonical wave/dragon/lotus flavors; kris overrides it.
{
ui,
syn,
vcs,
diff,
diag,
}:
{
editor = {
background = ui.bg;
foreground = ui.fg;
caret = ui.fg_dim;
invisibles = ui.nontext;
lineHighlight = ui.bg_search;
selection = ui.bg_search;
findHighlight = ui.bg_search;
selectionBorder = ui.bg_m1;
gutterForeground = ui.nontext;
};

# kanagawa.nvim sets syn.variable = "none" (inherit fg); resolve to ui.fg here.
syn = syn // {
variable = ui.fg;
};

diff = { inherit (diff) add delete change; };

chrome = {
inherit (ui) fg; # borders' default, fallback file, help footer
on_accent = ui.bg; # text drawn on a colored bg (counts, mode, find)
bg_deep = ui.bg_m3; # deepest bg: alt mode, progress label
status_bg = ui.bg_m3; # status bar / which-key mask
accent = syn.fun; # primary accent: normal mode, dirs, which cand
green = syn.string; # copy/created markers, info
red = syn.special2; # cut/selected markers, archives
pink = syn.number; # marked, select mode, media, tasks
yellow = syn.identifier; # cwd, unset mode, images, warn, read perm
blue = syn.special1; # status bar fg
border = syn.type; # pick/input/completion/tasks borders
teal = syn.type; # exec perm, help "on"
peach = syn.special3; # write perm, error
docs = diag.hint; # document filetype
gray = ui.fg_dim; # which-key separator/rest
faint = ui.nontext; # which-key desc, gutter find line-number
orphan = syn.special2; # broken symlinks
exec = vcs.added; # executable files
};
}
47 changes: 47 additions & 0 deletions lib/kanagawa/themes/wave.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Canonical Kanagawa "wave" — transcribed from kanagawa.nvim
# lua/kanagawa/themes.lua (wave). Only the roles the yazi builder consumes are
# included; the shared mapper (./mk.nix) turns them into editor/syn/diff/chrome.
{ palette }:
let
p = palette;
in
import ./mk.nix {
ui = {
fg = p.fujiWhite;
fg_dim = p.oldWhite;
nontext = p.sumiInk6;
bg = p.sumiInk3;
bg_m1 = p.sumiInk2;
bg_m3 = p.sumiInk0;
bg_search = p.waveBlue2;
};
syn = {
string = p.springGreen;
number = p.sakuraPink;
constant = p.surimiOrange;
identifier = p.carpYellow;
parameter = p.oniViolet2;
fun = p.crystalBlue;
keyword = p.oniViolet;
operator = p.boatYellow2;
type = p.waveAqua2;
regex = p.boatYellow2;
deprecated = p.katanaGray;
comment = p.fujiGray;
punct = p.springViolet2;
special1 = p.springBlue;
special2 = p.waveRed;
special3 = p.peachRed;
};
vcs = {
added = p.autumnGreen;
removed = p.autumnRed;
changed = p.autumnYellow;
};
diff = {
add = p.winterGreen;
delete = p.winterRed;
change = p.winterBlue;
};
diag.hint = p.waveAqua1;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 43 additions & 6 deletions modules/home-manager/yazi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,39 @@
inputs,
...
}:
let
stateDir = "${config.xdg.stateHome}/yazi";
# Default flavor for a fresh machine; the theme-switcher plugin overwrites
# this file at runtime, and it's only seeded when absent (below), so a
# rebuild never clobbers a saved selection. yazi picks the slot matching the
# terminal's color mode at startup, so `light` is the light-terminal fallback.
defaultThemeToml = pkgs.writeText "yazi-theme-default.toml" ''
[flavor]
dark = "kanagawa-kris"
light = "kanagawa-lotus"
'';
in
{
options.kriswill.yazi.enable = lib.mkEnableOption "yazi";
config = lib.mkIf config.kriswill.yazi.enable {
# `magick` (ImageMagick 7) is required by the font previewer.
home.packages = [ pkgs.imagemagick ];

# theme.toml is intentionally NOT managed by programs.yazi (so it isn't a
# read-only store symlink): point it at a writable file in yazi's state
# dir that the theme-switcher plugin rewrites. yazi reads it at startup.
xdg.configFile."yazi/theme.toml".source =
config.lib.file.mkOutOfStoreSymlink "${stateDir}/theme.toml";

# Seed the default selection once; preserve any runtime choice thereafter.
home.activation.yaziThemeSeed = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
run mkdir -p ${lib.escapeShellArg stateDir}
if [ ! -e ${lib.escapeShellArg "${stateDir}/theme.toml"} ]; then
run cp ${defaultThemeToml} ${lib.escapeShellArg "${stateDir}/theme.toml"}
run chmod u+w ${lib.escapeShellArg "${stateDir}/theme.toml"}
fi
'';

programs.yazi = {
enable = lib.mkDefault true;
shellWrapperName = "y";
Expand All @@ -29,17 +56,27 @@
# Wired via explicit preloader + previewer rules below — yazi
# won't let a user plugin named `font` override the preset.
font-dark = ./font-dark.yazi;
# Picks a Kanagawa flavor and writes it to the (writable) theme.toml
# in yazi's state dir; bound to `T` below.
theme-switcher = ./theme-switcher.yazi;
};
initLua = ''
require("git"):setup()
'';

flavors = {
kanagawa-dragon = import ./_themes/kanagawa-dragon { inherit lib pkgs; };
};
theme = {
flavor.dark = "kanagawa-dragon";
};
# All four flavors installed simultaneously (flavors/<name>.yazi). The
# active one is selected by theme.toml's [flavor], which is NOT managed
# here — see the writable out-of-store symlink + seed below — so the
# theme-switcher plugin can persist a runtime choice.
flavors = import ../../../pkgs/yazi-kanagawa-flavor/all.nix { inherit lib pkgs; };

keymap.mgr.prepend_keymap = [
{
on = [ "T" ];
run = "plugin theme-switcher";
desc = "Switch Kanagawa flavor";
}
];
settings = {
mgr.ratio = [
1
Expand Down
5 changes: 5 additions & 0 deletions modules/home-manager/yazi/theme-switcher.yazi/.luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
"workspace.library": ["~/.config/yazi/plugins/types.yazi"]
}
Loading