From 638986587fdd7ee86a8070810d150d7e171801ef Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Tue, 11 Aug 2026 15:12:09 -0400 Subject: [PATCH] =?UTF-8?q?feat(scripts):=20add=20yazi=E2=80=91nvim?= =?UTF-8?q?=E2=80=91open=20executable=20for=20Neovim=20integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dot_local/bin/executable_yazi-nvim-open | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 dot_local/bin/executable_yazi-nvim-open diff --git a/dot_local/bin/executable_yazi-nvim-open b/dot_local/bin/executable_yazi-nvim-open new file mode 100644 index 0000000..87db127 --- /dev/null +++ b/dot_local/bin/executable_yazi-nvim-open @@ -0,0 +1,26 @@ +#!/bin/sh +# Yazi `edit` opener. Inside a Neovim terminal ($NVIM set) files open in the +# HOST instance via _G.EditFromYazi (see ~/.config/nvim/lua/config/yazi_session.lua) +# and the yazi window hides itself; standalone yazi gets a regular blocking nvim. +# +# usage: nvim-open.sh [vsplit|split|tabedit] file... (default mode: edit) + +case "$1" in + vsplit | split | tabedit) mode="$1"; shift ;; + *) mode="edit" ;; +esac + +[ -n "$YAZI_OPEN_TRACE" ] && printf 'NVIM=%s MODE=%s ARGS=%s\n' "$NVIM" "$mode" "$*" >> "$YAZI_OPEN_TRACE" + +if [ -z "$NVIM" ]; then + # split modes are meaningless outside an nvim terminal — quiet no-op + [ "$mode" = "edit" ] || exit 0 + exec nvim "$@" +fi + +for f in "$@"; do + abs=$(realpath -- "$f") || continue + # escape for a vimscript double-quoted string + esc=$(printf '%s' "$abs" | sed 's/[\\"]/\\&/g') + nvim --server "$NVIM" --remote-expr "v:lua.EditFromYazi(\"$mode\", \"$esc\")" +done