This commit is contained in:
elwrcl committed 2026-09-03 22:08:55 +03:00
1 parent 7c5d9f44a8
commit 71e8016094
8 files changed
+167 -62

No files matched your search

+13 -30
View File
@@ -1,35 +1,12 @@
{ ... }:
{
flake.homeModules.home-helix-keys =
{ config, pkgs, ... }:
{ ... }:
let
float = cmd: ":sh zellij run --floating --close-on-exit -- ${cmd}";
floatKeep = cmd: ":sh zellij run --floating -- ${cmd}";
pick = pkgs.writeShellApplication {
name = "hx-pick";
runtimeInputs = [
pkgs.yazi
config.programs.zellij.finalPackage
pkgs.coreutils
];
text = ''
chooser=$(mktemp -t hx-pick.XXXXXX)
trap 'rm -f "$chooser"' EXIT
yazi "''${1:-.}" --chooser-file="$chooser"
picked=$(head -n 1 "$chooser")
[ -n "$picked" ] || exit 0
zellij action toggle-floating-panes
zellij action write-chars ":open '$picked'"
zellij action write 13
'';
};
in
{
home.packages = [ pick ];
programs.helix.settings.keys = {
normal = {
esc = [
@@ -37,14 +14,16 @@
"keep_primary_selection"
];
"A-s" = ":sh hx-sidebar-toggle";
"A-S" = "split_selection_on_newline";
"C-f" = "search";
"C-tab" = "goto_next_buffer";
"C-S-tab" = "goto_previous_buffer";
space = {
q = ":buffer-close";
Q = ":quit";
t = float "nu";
e = float "hx-pick";
E = float "hx-pick %{buffer_name}";
n = ":sh zellij action new-tab";
z = ":sh zellij action toggle-floating-panes";
v = {
v = float "lazyjj";
@@ -72,7 +51,6 @@
f = ":toggle auto-format";
};
# language server
l = {
r = ":lsp-restart";
s = ":lsp-stop";
@@ -82,6 +60,11 @@
};
};
};
insert."C-f" = [
"normal_mode"
"search"
];
};
};
}
@@ -0,0 +1,86 @@
{ ... }:
{
flake.homeModules.home-helix-sidebar =
{ config, pkgs, ... }:
let
sidebarConfig = pkgs.writeTextDir "yazi.toml" ''
[mgr]
ratio = [ 0, 1, 0 ]
show_hidden = false
show_symlink = false
linemode = "none"
scrolloff = 4
'';
sidebar = pkgs.writeShellApplication {
name = "hx-sidebar";
runtimeInputs = [
pkgs.yazi
config.programs.zellij.finalPackage
pkgs.coreutils
];
text = ''
cd "''${1:-.}"
export YAZI_CONFIG_HOME=${sidebarConfig}
marker="''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME:-none}"
chooser=$(mktemp -t hx-sidebar.XXXXXX)
trap 'rm -f "$chooser" "$marker"' EXIT
echo $$ > "$marker"
while true; do
: > "$chooser"
yazi . --chooser-file="$chooser"
picked=$(head -n 1 "$chooser")
[ -n "$picked" ] || break
zellij action move-focus right
zellij action write 27
zellij action write-chars ":open '$picked'"
zellij action write 13
done
'';
};
toggle = pkgs.writeShellApplication {
name = "hx-sidebar-toggle";
runtimeInputs = [
config.programs.zellij.finalPackage
pkgs.coreutils
];
text = ''
if [ -z "''${ZELLIJ_SESSION_NAME:-}" ]; then
echo "hx-sidebar-toggle: not inside a zellij session" >&2
exit 1
fi
marker="''${XDG_RUNTIME_DIR:-/tmp}/hx-sidebar.''${ZELLIJ_SESSION_NAME}"
if [ -e "$marker" ] && kill -0 "$(cat "$marker")" 2>/dev/null; then
zellij action toggle-fullscreen
else
rm -f "$marker"
id=$(zellij action new-pane \
--direction right \
--name files \
--close-on-exit \
-- ${sidebar}/bin/hx-sidebar "$PWD")
zellij action move-pane --pane-id "$id" left
for _ in 1 2 3 4 5; do
zellij action resize --pane-id "$id" decrease right
done
fi
'';
};
in
{
home.packages = [
sidebar
toggle
];
};
}