diff --git a/home/fish/fish.nix b/home/fish/fish.nix index 1bdc677..826cc47 100644 --- a/home/fish/fish.nix +++ b/home/fish/fish.nix @@ -1,9 +1,9 @@ -{ config, pkgs, lib, ... }: +{ config, options, pkgs, lib, ... }: with lib; { imports = [ - ./tide/nix-shell.nix + ./tide ]; options.programs.fish.everywhereAbbrs = mkOption { @@ -86,7 +86,9 @@ with lib; tide = { - nix-shell.enable = true; + enable = true; + leftItems = options.programs.fish.tide.leftItems.default; + rightItems = options.programs.fish.tide.rightItems.default; }; shellAliases = { @@ -183,16 +185,6 @@ with lib; end ''; plugins = [ - { - name = "tide"; - src = pkgs.fetchFromGitHub { - owner = "IlanCosman"; - repo = "tide"; - rev = "v6.0.1"; - # sha256 = lib.fakeSha256; - sha256 = "sha256-oLD7gYFCIeIzBeAW1j62z5FnzWAp3xSfxxe7kBtTLgA="; - }; - } { name = "fzf"; src = pkgs.fetchFromGitHub { diff --git a/home/fish/tide/default.nix b/home/fish/tide/default.nix new file mode 100644 index 0000000..24446c7 --- /dev/null +++ b/home/fish/tide/default.nix @@ -0,0 +1,82 @@ +{ config, pkgs, lib, ... }: + +with lib; +let + cfg = config.programs.fish.tide; +in +{ + options.programs.fish.tide = { + enable = mkEnableOption "Enable tide integrations for fish"; + items = mkOption { + type = types.attrsOf types.str; + description = "Additional item definitions to create"; + default = { }; + }; + rightItems = mkOption { + type = types.listOf types.str; + description = "The list of right-items, note that `time` is not included here and will always appear last"; + default = [ + "status" + "cmd_duration" + "jobs" + "direnv" + "node" + "python" + "rustc" + "java" + "php" + "pulumi" + "ruby" + "go" + "gcloud" + "kubectl" + "distrobox" + "toolbox" + "terraform" + "aws" + "crystal" + "elixir" + "nix_shell" + ]; + }; + leftItems = mkOption { + type = types.listOf types.str; + description = "The list of left-items. Note that `newline` and `character` is not included here and will always appear last"; + default = [ "os" "context" "pwd" "git" ]; + }; + }; + + config.programs.fish = + let + tideItems = attrsets.mapAttrs' (name: def: { name = "_tide_item_${name}"; value = def; }); + in + mkIf cfg.enable { + functions = tideItems ({ + nix_shell = '' + # In a Nix Shell + if test -f $DIRENV_FILE && rg -q "^use flake" $DIRENV_FILE + set -U tide_nix_shell_color "FFA500" + set -U tide_nix_shell_bg_color normal + _tide_print_item nix_shell "❄" + end + ''; + } // cfg.items); + shellInit = '' + # Configure tide items + set -U tide_left_prompt_items ${concatMapStringsSep " " escapeShellArg cfg.leftItems} newline character + set -U tide_right_prompt_items ${concatMapStringsSep " " escapeShellArg cfg.rightItems} time + ''; + plugins = [ + { + name = "tide"; + src = pkgs.fetchFromGitHub { + owner = "IlanCosman"; + repo = "tide"; + rev = "v6.0.1"; + # sha256 = lib.fakeSha256; + sha256 = "sha256-oLD7gYFCIeIzBeAW1j62z5FnzWAp3xSfxxe7kBtTLgA="; + }; + } + ]; + }; +} diff --git a/home/fish/tide/nix-shell.nix b/home/fish/tide/nix-shell.nix deleted file mode 100644 index 28504c0..0000000 --- a/home/fish/tide/nix-shell.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, pkgs, lib, ... }: - -with lib; -let - cfg = config.programs.fish.tide.nix-shell; -in -{ - options.programs.fish.tide.nix-shell = { - enable = mkEnableOption "An indicator of having a `nix shell` environment"; - }; - - config.programs.fish = mkIf cfg.enable { - functions._tide_item_nix_shell = '' - # In a Nix Shell - if string match -q "/nix/store/*" $PATH - set -U tide_nix_shell_color (set -q DIRENV_DIR && echo "FFA500" || echo "blue") - set -U tide_nix_shell_bg_color normal - _tide_print_item nix_shell "❄" - end - ''; - }; -} diff --git a/home/modules/programs/my-kakoune/fish-session.nix b/home/modules/programs/my-kakoune/fish-session.nix index c9a346b..1f497f4 100644 --- a/home/modules/programs/my-kakoune/fish-session.nix +++ b/home/modules/programs/my-kakoune/fish-session.nix @@ -44,14 +44,16 @@ in set -gx EDITOR "kak" alias e="kak" ''; - - _tide_item_kakoune = '' + }; + programs.fish.tide = { + items.kakoune = '' if set -q kak_session set -U tide_kakoune_color FFA500 set -U tide_kakoune_bg_color normal _tide_print_item kakoune " " "e[$kak_session]" end ''; + rightItems = mkAfter [ "kakoune" ]; }; }; }