From 27c6f221c1af05921dcd2482b56cd66dcfce58c0 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Fri, 6 Dec 2024 16:46:02 +0700 Subject: [PATCH] Add support for Deno --- functions/_tide_item_deno.fish | 6 +++++ functions/_tide_remove_unusable_items.fish | 2 +- functions/tide/configure/configs/classic.fish | 6 +++-- .../configure/configs/classic_16color.fish | 2 ++ functions/tide/configure/configs/lean.fish | 6 +++-- .../tide/configure/configs/lean_16color.fish | 2 ++ functions/tide/configure/configs/rainbow.fish | 6 +++-- .../configure/configs/rainbow_16color.fish | 2 ++ functions/tide/configure/icons.fish | 1 + tests/_tide_item_deno.test.fish | 22 +++++++++++++++++++ 10 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 functions/_tide_item_deno.fish create mode 100644 tests/_tide_item_deno.test.fish diff --git a/functions/_tide_item_deno.fish b/functions/_tide_item_deno.fish new file mode 100644 index 00000000..18a65c2d --- /dev/null +++ b/functions/_tide_item_deno.fish @@ -0,0 +1,6 @@ +function _tide_item_deno + if path is $_tide_parent_dirs/deno.json + deno --version | string match -qr "deno (?.*) \(.*\)" + _tide_print_item deno $tide_deno_icon' ' $v + end +end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index b1d9b283..38b41526 100644 --- a/functions/_tide_remove_unusable_items.fish +++ b/functions/_tide_remove_unusable_items.fish @@ -1,7 +1,7 @@ function _tide_remove_unusable_items # Remove tool-specific items for tools the machine doesn't have installed set -l removed_items - for item in aws bun crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig + for item in aws bun crystal deno direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig contains $item $tide_left_prompt_items $tide_right_prompt_items || continue set -l cli_names $item diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 6f09bbaf..2a7613e5 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -16,6 +16,8 @@ tide_context_color_ssh D7AF87 tide_context_hostname_parts 1 tide_crystal_bg_color 444444 tide_crystal_color FFFFFF +tide_deno_bg_color 444444 +tide_deno_color FFFFFF tide_direnv_bg_color 444444 tide_direnv_bg_color_denied 444444 tide_direnv_color $_tide_color_gold @@ -79,11 +81,11 @@ tide_pwd_bg_color 444444 tide_pwd_color_anchors $_tide_color_light_blue tide_pwd_color_dirs $_tide_color_dark_blue tide_pwd_color_truncated_dirs 8787AF -tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod deno.json package.json build.zig tide_python_bg_color 444444 tide_python_color 00AFAF tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun deno node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix  tide_right_prompt_separator_diff_color  tide_right_prompt_separator_same_color  diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index fe730c5f..3dbbbd0a 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -12,6 +12,8 @@ tide_context_color_root bryellow tide_context_color_ssh yellow tide_crystal_bg_color black tide_crystal_color brwhite +tide_deno_bg_color black +tide_deno_color white tide_direnv_bg_color black tide_direnv_bg_color_denied black tide_direnv_color bryellow diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index db3f1d20..dc81504e 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -16,6 +16,8 @@ tide_context_color_ssh D7AF87 tide_context_hostname_parts 1 tide_crystal_bg_color normal tide_crystal_color FFFFFF +tide_deno_bg_color normal +tide_deno_color FFFFFF tide_direnv_bg_color normal tide_direnv_bg_color_denied normal tide_direnv_color $_tide_color_gold @@ -79,11 +81,11 @@ tide_pwd_bg_color normal tide_pwd_color_anchors $_tide_color_light_blue tide_pwd_color_dirs $_tide_color_dark_blue tide_pwd_color_truncated_dirs 8787AF -tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod deno.json package.json build.zig tide_python_bg_color normal tide_python_color 00AFAF tide_right_prompt_frame_enabled false -tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun deno node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix ' ' tide_right_prompt_separator_diff_color ' ' tide_right_prompt_separator_same_color ' ' diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 699ce45a..9380c15d 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -12,6 +12,8 @@ tide_context_color_root bryellow tide_context_color_ssh yellow tide_crystal_bg_color normal tide_crystal_color brwhite +tide_deno_bg_color normal +tide_deno_color white tide_direnv_bg_color normal tide_direnv_bg_color_denied normal tide_direnv_color bryellow diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 79e9cb4a..e5c74b0b 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -16,6 +16,8 @@ tide_context_color_ssh D7AF87 tide_context_hostname_parts 1 tide_crystal_bg_color FFFFFF tide_crystal_color 000000 +tide_deno_bg_color FFFFFF +tide_deno_color 000000 tide_direnv_bg_color $_tide_color_gold tide_direnv_bg_color_denied FF0000 tide_direnv_color 000000 @@ -79,11 +81,11 @@ tide_pwd_bg_color 3465A4 tide_pwd_color_anchors E4E4E4 tide_pwd_color_dirs E4E4E4 tide_pwd_color_truncated_dirs BCBCBC -tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod package.json build.zig +tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform bun.lockb Cargo.toml composer.json CVS go.mod deno.json package.json build.zig tide_python_bg_color 444444 tide_python_color 00AFAF tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs direnv bun node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig +tide_right_prompt_items status cmd_duration context jobs direnv bun deno node python rustc java php pulumi ruby go gcloud kubectl distrobox toolbox terraform aws nix_shell crystal elixir zig tide_right_prompt_prefix  tide_right_prompt_separator_diff_color  tide_right_prompt_separator_same_color  diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index 5d206115..03d48bf6 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -12,6 +12,8 @@ tide_context_color_root yellow tide_context_color_ssh yellow tide_crystal_bg_color brwhite tide_crystal_color black +tide_deno_bg_color white +tide_deno_color black tide_direnv_bg_color bryellow tide_direnv_bg_color_denied brred tide_direnv_color black diff --git a/functions/tide/configure/icons.fish b/functions/tide/configure/icons.fish index a687bed2..70b545b7 100644 --- a/functions/tide/configure/icons.fish +++ b/functions/tide/configure/icons.fish @@ -6,6 +6,7 @@ tide_character_vi_icon_replace ▶ tide_character_vi_icon_visual V tide_cmd_duration_icon tide_crystal_icon  +tide_deno_icon  tide_direnv_icon ▼ tide_distrobox_icon 󰆧 tide_docker_icon  diff --git a/tests/_tide_item_deno.test.fish b/tests/_tide_item_deno.test.fish new file mode 100644 index 00000000..285f464c --- /dev/null +++ b/tests/_tide_item_deno.test.fish @@ -0,0 +1,22 @@ +# RUN: %fish %s +_tide_parent_dirs + +function _deno + _tide_decolor (_tide_item_deno) +end + +set -l tmpdir (mktemp -d) +cd $tmpdir + +mock deno --version "echo deno 2.1.2 (stable, release, x86_64-unknown-linux-gnu) +v8 13.0.245.12-rusty +typescript 5.6.2 +" +set -lx tide_deno_icon  + +_deno # CHECK: + +touch deno.json +_deno # CHECK:  2.1.2 + +command rm -r $tmpdir