From 63ebeec96d4a48f4a2a9cfa5e0c06ad12cdb4c4c Mon Sep 17 00:00:00 2001 From: Feng Kaiyu Date: Wed, 6 May 2026 16:38:45 +0800 Subject: [PATCH] fix: support custom NVIM_APPNAME in XDG_RUNTIME_DIR socket discovery Neovim uses $NVIM_APPNAME (default "nvim") as the socket filename prefix (e.g. "lazynvim.12345.0" instead of "nvim.12345.0"). The hardcoded "nvim.*.0" glob fails to discover sockets when NVIM_APPNAME is set. --- bin/nvim-socket.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/nvim-socket.sh b/bin/nvim-socket.sh index a61971d..8cac3f5 100755 --- a/bin/nvim-socket.sh +++ b/bin/nvim-socket.sh @@ -79,15 +79,16 @@ find_nvim_socket() { # 4. Scan XDG_RUNTIME_DIR paths (NixOS, systemd-based distros) # Complements step 3; on these systems sockets live in $XDG_RUNTIME_DIR, not /tmp local _xdg_dir="${XDG_RUNTIME_DIR:-}" + local _appname="${NVIM_APPNAME:-nvim}" if [[ -z "$_xdg_dir" ]]; then _xdg_dir="/run/user/$(id -u)" fi local _xdg_glob_out - _xdg_glob_out="$(compgen -G "$_xdg_dir/nvim.*.0" 2>/dev/null)" || true + _xdg_glob_out="$(compgen -G "$_xdg_dir/${_appname}.*.0" 2>/dev/null)" || true if [[ -n "$_xdg_glob_out" ]]; then while IFS= read -r socket; do if [[ -S "$socket" ]]; then - pid=$(echo "$socket" | grep -oE 'nvim\.[0-9]+' | grep -oE '[0-9]+') + pid=$(echo "$socket" | grep -oE "${_appname}\\.[0-9]+" | grep -oE '[0-9]+') if [[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null; then live_sockets+=("$pid:$socket") fi