diff --git a/flake.nix b/flake.nix index 5d979f6..17d2b33 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ # DO-NOT-EDIT. This file was auto-generated using github:vic/flake-file. # Use `nix run .#write-flake` to regenerate it. { - outputs = inputs: inputs.flake-parts.lib.mkFlake {inherit inputs;} (inputs.import-tree ./modules); + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); inputs = { authentik-nix = { diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index fd9c768..d930ee1 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -75,8 +75,8 @@ git jujutsu nur - sops shellAbbreviations + sops # keep-sorted end # CLI diff --git a/modules/programs/cli/starship/jujutsu.nix b/modules/programs/cli/starship/jujutsu.nix index 2d5909c..473124f 100644 --- a/modules/programs/cli/starship/jujutsu.nix +++ b/modules/programs/cli/starship/jujutsu.nix @@ -9,13 +9,21 @@ }: let inherit (lib) getExe; inherit (lib.self) starshipJjTrueColor; + stylixColors = config.lib.stylix.colors.withHashtag; + + ansiColor = value: let + color = starshipJjTrueColor value; + in "${toString color.TrueColor.r};${toString color.TrueColor.g};${toString color.TrueColor.b}"; + + changeUniqueStyle = "1;48;2;${ansiColor stylixColors.base01};38;2;${ansiColor stylixColors.base0E}"; + changeRestStyle = "1;48;2;${ansiColor stylixColors.base01};38;2;${ansiColor stylixColors.base04}"; + inherit - (builtins.mapAttrs (_: starshipJjTrueColor) config.lib.stylix.colors.withHashtag) + (builtins.mapAttrs (_: starshipJjTrueColor) stylixColors) # keep-sorted start base01 base08 base0A - base0B base0E # keep-sorted end ; @@ -30,14 +38,6 @@ reset_color = false; module = [ - { - type = "Symbol"; - symbol = " "; - color = base0E; - bg_color = base01; - bold = true; - } - { type = "Bookmarks"; separator = " "; @@ -50,31 +50,6 @@ surround_with_quotes = false; } - { - type = "Commit"; - color = base0B; - bg_color = base01; - bold = true; - - change = { - color = base0B; - bg_color = base01; - bold = true; - }; - - commit = { - color = base0B; - bg_color = base01; - bold = true; - }; - - empty_text = "(no description set)"; - max_length = 24; - previous_message_symbol = "⇣"; - show_previous_if_empty = false; - surround_with_quotes = false; - } - { type = "State"; separator = " "; @@ -94,6 +69,7 @@ }; empty = { + disabled = true; text = "empty"; color = base0A; bg_color = base01; @@ -101,6 +77,7 @@ }; hidden = { + disabled = true; text = "hidden"; color = base0A; bg_color = base01; @@ -108,6 +85,7 @@ }; immutable = { + disabled = true; text = "immutable"; color = base0A; bg_color = base01; @@ -145,13 +123,34 @@ } ]; }; + + starshipJjPrompt = pkgs.writeShellApplication { + name = "starship-jj-prompt"; + runtimeInputs = [ + pkgs.jujutsu + pkgs.starship-jj + ]; + text = '' + unique="$(jj log --ignore-working-copy --no-graph -r @ -T 'change_id.shortest()' 2>/dev/null)" + display="$(jj log --ignore-working-copy --no-graph -r @ -T 'change_id.shortest(8)' 2>/dev/null)" + rest="''${display#"$unique"}" + + printf '\033[${changeUniqueStyle}m%s' "$unique" + printf '\033[${changeRestStyle}m%s ' "$rest" + exec starship-jj --ignore-working-copy starship prompt --starship-config ${starshipJjConfig} + ''; + }; in { programs.starship.settings = { # keep-sorted start block=yes newline_separated=yes custom.jj = { - command = "${getExe pkgs.starship-jj} --ignore-working-copy starship prompt --starship-config ${starshipJjConfig}"; + command = getExe starshipJjPrompt; format = "[ ](#00000000)[ ](bg:base01)[$output]($style)[ ](bg:base01)"; ignore_timeout = true; + shell = [ + "${getExe pkgs.fish}" + "-c" + ]; style = "bg:base01 fg:base0E bold"; use_stdin = false; when = "${getExe pkgs.starship-jj} root --quiet"; diff --git a/modules/programs/delta.nix b/modules/programs/delta.nix index 9ae329c..84a14e5 100644 --- a/modules/programs/delta.nix +++ b/modules/programs/delta.nix @@ -13,6 +13,7 @@ programs.delta = { enable = true; enableGitIntegration = true; + enableJujutsuIntegration = true; options = with colors; { true-color = "always"; diff --git a/modules/programs/tui/neovim/components/dashboard.nix b/modules/programs/tui/neovim/components/dashboard.nix index def6455..4ee66ec 100644 --- a/modules/programs/tui/neovim/components/dashboard.nix +++ b/modules/programs/tui/neovim/components/dashboard.nix @@ -9,10 +9,65 @@ }: let inherit (lib) getExe; inherit (lib.generators) mkLuaInline; + inherit + (pkgs) + #keep-sorted start + writeText + writeShellApplication + #keep-sorted end + ; colors = config.lib.stylix.colors.withHashtag; - dashboardGhNotify = pkgs.writeShellApplication { + dashboardStatusFilter = writeText "dashboard-status-filter.lua" '' + local function truncate_ansi(line, max) + local out = {} + local visible = 0 + local i = 1 + + while i <= #line do + local char = line:sub(i, i) + + if char == "\27" then + local finish = line:find("m", i, true) + if not finish then + break + end + + out[#out + 1] = line:sub(i, finish) + i = finish + 1 + else + if visible >= max then + out[#out + 1] = "...\27[0m" + break + end + + out[#out + 1] = char + visible = visible + 1 + i = i + 1 + end + end + + return table.concat(out) + end + + local seen = 0 + for line in io.lines() do + if seen == 6 then + break + end + + local plain = line:gsub("\27%[[0-9;]*m", "") + print(#plain > 48 and truncate_ansi(line, 45) or line) + seen = seen + 1 + end + + if seen == 0 then + print("No jj changes") + end + ''; + + dashboardGhNotify = writeShellApplication { name = "dashboard-gh-notify"; runtimeInputs = [pkgs.coreutils]; text = '' @@ -21,6 +76,28 @@ exec "${getExe pkgs.gh-notify}" "$@" ''; }; + + dashboardVcsStatus = writeShellApplication { + name = "dashboard-vcs-status"; + runtimeInputs = with pkgs; [ + # keep-sorted start + gawk + git + jujutsu + lua + # keep-sorted end + ]; + text = '' + if jj root >/dev/null 2>&1; then + jj --color always status | lua ${dashboardStatusFilter} + elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + git -c color.status=always status --short --branch --renames \ + | awk 'NR <= 6 { print; seen = 1 } END { if (!seen) print "No git changes" }' + else + printf '\n\n\n\n\n\n' + fi + ''; + }; in { # keep-sorted start block=yes newline_separated=yes # Capture dashboard metrics once so the footer can read cached values. @@ -319,27 +396,7 @@ icon = ""; title = "VCS Status"; section = "terminal"; - cmd = getExe (pkgs.writeShellApplication { - name = "dashboard-vcs-status"; - runtimeInputs = with pkgs; [ - # keep-sorted start - gawk - git - jujutsu - # keep-sorted end - ]; - text = '' - if jj root >/dev/null 2>&1; then - jj --color always status \ - | awk 'NR <= 6 { print; seen = 1 } END { if (!seen) print "No jj changes" }' - elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then - git -c color.status=always status --short --branch --renames \ - | awk 'NR <= 6 { print; seen = 1 } END { if (!seen) print "No git changes" }' - else - printf '\n\n\n\n\n\n' - fi - ''; - }); + cmd = getExe dashboardVcsStatus; height = 6; padding = 1; indent = 3; @@ -354,7 +411,6 @@ } ]; }; - }; # keep-sorted end };