mirror of
https://github.com/sxyazi/yazi.git
synced 2024-09-11 18:38:19 +03:00
Compare commits
6 Commits
e3426a14eb
...
888bdee1bb
Author | SHA1 | Date | |
---|---|---|---|
|
888bdee1bb | ||
|
4aaca4c432 | ||
|
f865910481 | ||
|
a930638109 | ||
|
8300ddb9ca | ||
|
feec48b752 |
11
.github/ISSUE_TEMPLATE/bug.yml
vendored
11
.github/ISSUE_TEMPLATE/bug.yml
vendored
@ -29,16 +29,7 @@ body:
|
||||
attributes:
|
||||
label: "`yazi --debug` output"
|
||||
description: Please run `yazi --debug` and paste the debug information here.
|
||||
value: |
|
||||
<details>
|
||||
|
||||
```sh
|
||||
##### ↓↓↓ Paste the output here: ↓↓↓ #####
|
||||
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
render: Shell
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
|
11
.github/ISSUE_TEMPLATE/feature.yml
vendored
11
.github/ISSUE_TEMPLATE/feature.yml
vendored
@ -8,16 +8,7 @@ body:
|
||||
attributes:
|
||||
label: "`yazi --debug` output"
|
||||
description: Please run `yazi --debug` and paste the debug information here.
|
||||
value: |
|
||||
<details>
|
||||
|
||||
```sh
|
||||
##### ↓↓↓ Paste the output here: ↓↓↓ #####
|
||||
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
render: Shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
4
.github/workflows/cachix.yml
vendored
4
.github/workflows/cachix.yml
vendored
@ -1,8 +1,8 @@
|
||||
name: Cachix
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
31
.github/workflows/draft.yml
vendored
31
.github/workflows/draft.yml
vendored
@ -4,6 +4,9 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- "v[0-9]+.[0-9]+.[0-9]+"
|
||||
schedule:
|
||||
- cron: "0 */6 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-unix:
|
||||
@ -145,3 +148,31 @@ jobs:
|
||||
yazi-*.zip
|
||||
yazi-*.snap
|
||||
generate_release_notes: true
|
||||
|
||||
nightly:
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-unix, build-windows, build-musl, build-snap]
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
merge-multiple: true
|
||||
|
||||
- run: |
|
||||
echo 'NIGHTLY_BODY<<EOF' >> $GITHUB_ENV
|
||||
echo "From commit: ${GITHUB_SHA:0:8}" >> $GITHUB_ENV
|
||||
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
|
||||
- name: Nightly
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
||||
with:
|
||||
tag_name: nightly
|
||||
prerelease: true
|
||||
files: |
|
||||
yazi-*.zip
|
||||
yazi-*.snap
|
||||
name: Nightly Build
|
||||
body: ${{ env.NIGHTLY_BODY }}
|
||||
|
@ -46,7 +46,7 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265
|
||||
| WezTerm | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
|
||||
| Mintty (Git Bash) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
|
||||
| foot | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
|
||||
| Ghostty | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adapter/src/kitty_old.rs) | ✅ Built-in |
|
||||
| Ghostty | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in |
|
||||
| Black Box | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in |
|
||||
| VSCode | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
|
||||
| Tabby | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in |
|
||||
|
46
flake.lock
46
flake.lock
@ -1,30 +1,12 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1722141560,
|
||||
"narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
|
||||
"lastModified": 1722415718,
|
||||
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
|
||||
"rev": "c3392ad349a5227f4a3464dce87bcc5046692fce",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -36,7 +18,6 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
@ -48,11 +29,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722133294,
|
||||
"narHash": "sha256-XKSVN+lmjVEFPjMa5Ui0VTay2Uvqa74h0MQT0HU1pqw=",
|
||||
"lastModified": 1722391647,
|
||||
"narHash": "sha256-JTi7l1oxnatF1uX/gnGMlRnyFMtylRw4MqhCUdoN2K4=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "9803f6e04ca37a2c072783e8297d2080f8d0e739",
|
||||
"rev": "0fd4a5d2098faa516a9b83022aec7db766cd1de8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -60,21 +41,6 @@
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
102
flake.nix
102
flake.nix
@ -1,13 +1,9 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
flake-utils.follows = "flake-utils";
|
||||
};
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
@ -15,47 +11,77 @@
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
...
|
||||
}@inputs:
|
||||
}:
|
||||
let
|
||||
# Nixpkgs overlays
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
(final: _: {
|
||||
rustToolchain = final.rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; };
|
||||
})
|
||||
systems = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
forEachSystem =
|
||||
f:
|
||||
(lib.listToAttrs (
|
||||
map (system: {
|
||||
name = system;
|
||||
value = f {
|
||||
inherit system;
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
|
||||
(
|
||||
final: prev:
|
||||
let
|
||||
toolchain = final.rust-bin.stable.latest.default;
|
||||
in
|
||||
{
|
||||
rustPlatform = prev.makeRustPlatform {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
};
|
||||
}) systems
|
||||
));
|
||||
|
||||
rev = self.shortRev or self.dirtyShortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
version =
|
||||
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
rev = self.shortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
version =
|
||||
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
||||
{
|
||||
packages = forEachSystem (
|
||||
{ pkgs, system }:
|
||||
{
|
||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit (self.packages.${system}) yazi-unwrapped; };
|
||||
default = self.packages.${system}.yazi;
|
||||
}
|
||||
);
|
||||
|
||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
inherit yazi-unwrapped yazi;
|
||||
default = yazi;
|
||||
};
|
||||
devShells = forEachSystem (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
default = pkgs.callPackage ./nix/shell.nix { };
|
||||
}
|
||||
);
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
||||
|
||||
devShells.default = import ./nix/shell.nix { inherit pkgs inputs; };
|
||||
}
|
||||
)
|
||||
// {
|
||||
overlays = rec {
|
||||
default = yazi;
|
||||
yazi = final: _: { inherit (self.packages."${final.system}") yazi yazi-unwrapped; };
|
||||
overlays = {
|
||||
default = self.overlays.yazi;
|
||||
yazi = _: prev: { inherit (self.packages.${prev.stdenv.system}) yazi yazi-unwrapped; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,28 +1,24 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustToolchain
|
||||
rust-analyzer
|
||||
{
|
||||
callPackage,
|
||||
rust-bin,
|
||||
nodePackages,
|
||||
}:
|
||||
let
|
||||
mainPkg = callPackage ./yazi.nix { };
|
||||
in
|
||||
mainPkg.overrideAttrs (oa: {
|
||||
nativeBuildInputs = [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"rustfmt"
|
||||
"rust-analyzer"
|
||||
"clippy"
|
||||
];
|
||||
})
|
||||
|
||||
nodePackages.cspell
|
||||
] ++ (oa.nativeBuildInputs or [ ]);
|
||||
|
||||
file
|
||||
jq
|
||||
poppler_utils
|
||||
unar
|
||||
ffmpegthumbnailer
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
zoxide
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
|
||||
env = {
|
||||
RUST_BACKTRACE = "1";
|
||||
};
|
||||
}
|
||||
env.RUST_BACKTRACE = "1";
|
||||
})
|
||||
|
@ -1,67 +1,76 @@
|
||||
{
|
||||
makeRustPlatform,
|
||||
rustToolchain,
|
||||
rustPlatform,
|
||||
version ? "git",
|
||||
rev,
|
||||
date,
|
||||
rev ? "unknown",
|
||||
date ? "19700101",
|
||||
lib,
|
||||
|
||||
installShellFiles,
|
||||
stdenv,
|
||||
darwin,
|
||||
rust-jemalloc-sys,
|
||||
|
||||
imagemagick,
|
||||
}:
|
||||
let
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
|
||||
lib.fileset.unions [
|
||||
../assets
|
||||
../Cargo.toml
|
||||
../Cargo.lock
|
||||
(lib.fileset.fileFilter (file: file.hasExt "rs" || file.hasExt "toml") ../.)
|
||||
]
|
||||
);
|
||||
};
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "yazi";
|
||||
inherit version src;
|
||||
|
||||
(makeRustPlatform {
|
||||
cargo = rustToolchain;
|
||||
rustc = rustToolchain;
|
||||
}).buildRustPackage
|
||||
{
|
||||
pname = "yazi";
|
||||
inherit version;
|
||||
|
||||
src = ../.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
};
|
||||
cargoLock = {
|
||||
lockFile = "${src}/Cargo.lock";
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
};
|
||||
};
|
||||
|
||||
env = {
|
||||
YAZI_GEN_COMPLETIONS = true;
|
||||
VERGEN_GIT_SHA = rev;
|
||||
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||
};
|
||||
env = {
|
||||
YAZI_GEN_COMPLETIONS = true;
|
||||
VERGEN_GIT_SHA = rev;
|
||||
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
imagemagick
|
||||
];
|
||||
buildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
imagemagick
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd yazi \
|
||||
--bash ./yazi-boot/completions/yazi.bash \
|
||||
--fish ./yazi-boot/completions/yazi.fish \
|
||||
--zsh ./yazi-boot/completions/_yazi
|
||||
buildInputs = [
|
||||
rust-jemalloc-sys
|
||||
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
|
||||
# Resize logo
|
||||
for RES in 16 24 32 48 64 128 256; do
|
||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||
done
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd yazi \
|
||||
--bash ./yazi-boot/completions/yazi.bash \
|
||||
--fish ./yazi-boot/completions/yazi.fish \
|
||||
--zsh ./yazi-boot/completions/_yazi
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
install -m644 assets/yazi.desktop $out/share/applications/
|
||||
'';
|
||||
# Resize logo
|
||||
for RES in 16 24 32 48 64 128 256; do
|
||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||
done
|
||||
|
||||
meta = {
|
||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||
homepage = "https://github.com/sxyazi/yazi";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "yazi";
|
||||
};
|
||||
}
|
||||
mkdir -p $out/share/applications
|
||||
install -m644 assets/yazi.desktop $out/share/applications/
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||
homepage = "https://github.com/sxyazi/yazi";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "yazi";
|
||||
};
|
||||
}
|
||||
|
95
nix/yazi.nix
95
nix/yazi.nix
@ -1,41 +1,89 @@
|
||||
{
|
||||
lib,
|
||||
formats,
|
||||
runCommand,
|
||||
makeWrapper,
|
||||
|
||||
extraPackages ? [ ],
|
||||
optionalDeps ? [
|
||||
jq
|
||||
poppler_utils
|
||||
unar
|
||||
ffmpegthumbnailer
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
zoxide
|
||||
],
|
||||
|
||||
# deps
|
||||
file,
|
||||
yazi-unwrapped,
|
||||
|
||||
withFile ? true,
|
||||
file,
|
||||
withJq ? true,
|
||||
# optional deps
|
||||
jq,
|
||||
withPoppler ? true,
|
||||
poppler_utils,
|
||||
withUnar ? true,
|
||||
unar,
|
||||
withFfmpegthumbnailer ? true,
|
||||
ffmpegthumbnailer,
|
||||
withFd ? true,
|
||||
fd,
|
||||
withRipgrep ? true,
|
||||
ripgrep,
|
||||
withFzf ? true,
|
||||
fzf,
|
||||
withZoxide ? true,
|
||||
zoxide,
|
||||
}:
|
||||
|
||||
settings ? { },
|
||||
plugins ? { },
|
||||
flavors ? { },
|
||||
initLua ? null,
|
||||
}:
|
||||
let
|
||||
inherit (lib) optional makeBinPath;
|
||||
runtimePaths =
|
||||
optional withFile file
|
||||
++ optional withJq jq
|
||||
++ optional withPoppler poppler_utils
|
||||
++ optional withUnar unar
|
||||
++ optional withFfmpegthumbnailer ffmpegthumbnailer
|
||||
++ optional withFd fd
|
||||
++ optional withRipgrep ripgrep
|
||||
++ optional withFzf fzf
|
||||
++ optional withZoxide zoxide;
|
||||
inherit (lib)
|
||||
concatStringsSep
|
||||
concatMapStringsSep
|
||||
optionalString
|
||||
makeBinPath
|
||||
mapAttrsToList
|
||||
;
|
||||
|
||||
runtimePaths = [ file ] ++ optionalDeps ++ extraPackages;
|
||||
|
||||
settingsFormat = formats.toml { };
|
||||
|
||||
files = [
|
||||
"yazi"
|
||||
"theme"
|
||||
"keymap"
|
||||
];
|
||||
|
||||
configHome =
|
||||
if (settings == { } && initLua == null && plugins == { } && flavors == { }) then
|
||||
null
|
||||
else
|
||||
runCommand "YAZI_CONFIG_HOME" { } ''
|
||||
mkdir -p $out
|
||||
${concatMapStringsSep "\n" (
|
||||
name:
|
||||
optionalString (settings ? ${name} && settings.${name} != { }) ''
|
||||
ln -s ${settingsFormat.generate "${name}.toml" settings.${name}} $out/${name}.toml
|
||||
''
|
||||
) files}
|
||||
|
||||
mkdir $out/plugins
|
||||
${optionalString (plugins != { }) ''
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList (name: value: "ln -s ${value} $out/plugins/${name}") plugins
|
||||
)}
|
||||
''}
|
||||
|
||||
mkdir $out/flavors
|
||||
${optionalString (flavors != { }) ''
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList (name: value: "ln -s ${value} $out/flavors/${name}") flavors
|
||||
)}
|
||||
''}
|
||||
|
||||
|
||||
${optionalString (initLua != null) "ln -s ${initLua} $out/init.lua"}
|
||||
'';
|
||||
in
|
||||
runCommand yazi-unwrapped.name
|
||||
{
|
||||
@ -48,5 +96,6 @@ runCommand yazi-unwrapped.name
|
||||
ln -s ${yazi-unwrapped}/share $out/share
|
||||
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
||||
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
||||
--prefix PATH : "${makeBinPath runtimePaths}"
|
||||
--prefix PATH : "${makeBinPath runtimePaths}" \
|
||||
${optionalString (configHome != null) "--set YAZI_CONFIG_HOME ${configHome}"}
|
||||
''
|
||||
|
@ -58,8 +58,8 @@ impl Adapter {
|
||||
pub fn image_erase(self, area: Rect) -> Result<()> {
|
||||
match self {
|
||||
Self::Kitty => Kitty::image_erase(area),
|
||||
Self::Iterm2 => Iterm2::image_erase(area),
|
||||
Self::KittyOld => KittyOld::image_erase(area),
|
||||
Self::Iterm2 => Iterm2::image_erase(area),
|
||||
Self::Sixel => Sixel::image_erase(area),
|
||||
Self::X11 | Self::Wayland => Ueberzug::image_erase(area),
|
||||
Self::Chafa => Chafa::image_erase(area),
|
||||
|
@ -37,7 +37,7 @@ impl Emulator {
|
||||
Self::Iterm2 => vec![Adapter::Iterm2, Adapter::Sixel],
|
||||
Self::WezTerm => vec![Adapter::Iterm2, Adapter::Sixel],
|
||||
Self::Foot => vec![Adapter::Sixel],
|
||||
Self::Ghostty => vec![Adapter::KittyOld],
|
||||
Self::Ghostty => vec![Adapter::Kitty],
|
||||
Self::BlackBox => vec![Adapter::Sixel],
|
||||
Self::VSCode => vec![Adapter::Iterm2, Adapter::Sixel],
|
||||
Self::Tabby => vec![Adapter::Iterm2, Adapter::Sixel],
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::{path::PathBuf, str::FromStr, time::{SystemTime, UNIX_EPOCH}};
|
||||
use std::{borrow::Cow, path::PathBuf, str::FromStr, time::{SystemTime, UNIX_EPOCH}};
|
||||
|
||||
use anyhow::Context;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -29,6 +29,22 @@ impl Preview {
|
||||
let time = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards");
|
||||
self.cache_dir.join(format!("{prefix}-{}", time.as_nanos() / 1000))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn indent(&self) -> Cow<'static, str> {
|
||||
match self.tab_size {
|
||||
0 => Cow::Borrowed(""),
|
||||
1 => Cow::Borrowed(" "),
|
||||
2 => Cow::Borrowed(" "),
|
||||
3 => Cow::Borrowed(" "),
|
||||
4 => Cow::Borrowed(" "),
|
||||
5 => Cow::Borrowed(" "),
|
||||
6 => Cow::Borrowed(" "),
|
||||
7 => Cow::Borrowed(" "),
|
||||
8 => Cow::Borrowed(" "),
|
||||
n => Cow::Owned(" ".repeat(n as usize)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Preview {
|
||||
|
@ -25,7 +25,7 @@ impl<'a> Input<'a> {
|
||||
if let Some(syntax) = syntaxes.find_syntax_by_name("Bourne Again Shell (bash)") {
|
||||
let mut h = HighlightLines::new(syntax, theme);
|
||||
let regions = h.highlight_line(self.cx.input.value(), syntaxes)?;
|
||||
return Ok(Highlighter::to_line_widget(regions, &" ".repeat(PREVIEW.tab_size as usize)));
|
||||
return Ok(Highlighter::to_line_widget(regions, &PREVIEW.indent()));
|
||||
}
|
||||
bail!("Failed to find syntax")
|
||||
}
|
||||
|
@ -34,15 +34,13 @@ function Status:style()
|
||||
end
|
||||
|
||||
function Status:mode()
|
||||
local mode = tostring(self._tab.mode):upper()
|
||||
if mode == "UNSET" then
|
||||
mode = "UN-SET"
|
||||
end
|
||||
local mode = tostring(self._tab.mode):sub(1, 3):upper()
|
||||
|
||||
local style = self:style()
|
||||
return ui.Line {
|
||||
ui.Span(THEME.status.separator_open):fg(style.bg),
|
||||
ui.Span(" " .. mode .. " "):style(style),
|
||||
ui.Span(THEME.status.separator_close):fg(style.bg):bg(THEME.status.separator_style.fg),
|
||||
}
|
||||
end
|
||||
|
||||
@ -106,11 +104,11 @@ function Status:percentage()
|
||||
end
|
||||
|
||||
if percent == 0 then
|
||||
percent = " Top "
|
||||
percent = " Top "
|
||||
elseif percent == 100 then
|
||||
percent = " Bot "
|
||||
percent = " Bot "
|
||||
else
|
||||
percent = string.format(" %3d%% ", percent)
|
||||
percent = string.format(" %2d%% ", percent)
|
||||
end
|
||||
|
||||
local style = self:style()
|
||||
@ -126,6 +124,7 @@ function Status:position()
|
||||
|
||||
local style = self:style()
|
||||
return ui.Line {
|
||||
ui.Span(THEME.status.separator_open):fg(style.bg):bg(THEME.status.separator_style.fg),
|
||||
ui.Span(string.format(" %2d/%-2d ", cursor + 1, length)):style(style),
|
||||
ui.Span(THEME.status.separator_close):fg(style.bg),
|
||||
}
|
||||
|
26
yazi-plugin/src/external/highlighter.rs
vendored
26
yazi-plugin/src/external/highlighter.rs
vendored
@ -60,9 +60,9 @@ impl Highlighter {
|
||||
let mut reader = BufReader::new(File::open(&self.path).await?);
|
||||
|
||||
let syntax = Self::find_syntax(&self.path).await;
|
||||
let mut plain = syntax.is_err();
|
||||
let mut plain = syntax.is_err() as u8;
|
||||
|
||||
let mut before = Vec::with_capacity(if plain { 0 } else { skip });
|
||||
let mut before = Vec::with_capacity(if plain == 0 { skip } else { 0 });
|
||||
let mut after = Vec::with_capacity(limit);
|
||||
|
||||
let mut i = 0;
|
||||
@ -73,8 +73,11 @@ impl Highlighter {
|
||||
break;
|
||||
}
|
||||
|
||||
if !plain && (buf.len() > 5000 || buf.contains(&0x1b)) {
|
||||
plain = true;
|
||||
if plain == 0 && buf.len() > 5000 {
|
||||
plain = 1;
|
||||
drop(mem::take(&mut before));
|
||||
} else if plain == 0 && buf.contains(&0x1b) {
|
||||
plain = 2;
|
||||
drop(mem::take(&mut before));
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ impl Highlighter {
|
||||
|
||||
if i > skip {
|
||||
after.push(String::from_utf8_lossy(&buf).into_owned());
|
||||
} else if !plain {
|
||||
} else if plain == 0 {
|
||||
before.push(String::from_utf8_lossy(&buf).into_owned());
|
||||
}
|
||||
buf.clear();
|
||||
@ -96,11 +99,14 @@ impl Highlighter {
|
||||
return Err(PeekError::Exceed(i.saturating_sub(limit)));
|
||||
}
|
||||
|
||||
if plain {
|
||||
let indent = " ".repeat(PREVIEW.tab_size as usize);
|
||||
Ok(Text::from(after.join("").replace('\x1b', "^[").replace('\t', &indent)))
|
||||
} else {
|
||||
if plain == 0 {
|
||||
Self::highlight_with(before, after, syntax.unwrap()).await
|
||||
} else if plain == 1 {
|
||||
Ok(Text::from(after.join("").replace('\t', &PREVIEW.indent())))
|
||||
} else if plain == 2 {
|
||||
Ok(Text::from(after.join("").replace('\x1b', "^[").replace('\t', &PREVIEW.indent())))
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +127,7 @@ impl Highlighter {
|
||||
h.highlight_line(&line, syntaxes).map_err(|e| anyhow!(e))?;
|
||||
}
|
||||
|
||||
let indent = " ".repeat(PREVIEW.tab_size as usize);
|
||||
let indent = PREVIEW.indent();
|
||||
let mut lines = Vec::with_capacity(after.len());
|
||||
for line in after {
|
||||
if ticket != INCR.load(Ordering::Relaxed) {
|
||||
|
Loading…
Reference in New Issue
Block a user