feat(functions): helper fish_reload, env per-dir, vv e stormcode

This commit is contained in:
2026-09-29 18:25:51 +02:00
parent a4f3f73dc1
commit d8e5342375
5 changed files with 134 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
function vv -d "nvim: vv [nome] [file] — unico client TUI connesso al server persistente"
set -l name default
if set -q argv[1]; set name $argv[1]; end
# Sanitizza: solo alfanumerici, '-' e '_' (niente path traversal)
if not string match -qr '^[A-Za-z0-9_-]+$' -- $name
echo "vv: nome server non valido: '$name'" >&2
return 1
end
set -l dir /tmp/nvim-servers
set -l sock "$dir/$name.sock"
set -l log "$dir/$name.log"
mkdir -p $dir
# Stale socket: esiste ma nessun nvim dietro -> rimuovi
if test -S $sock
set -l pid (command nvim --server $sock --remote-expr 'getpid()' 2>/dev/null)
if not test -n "$pid"; or not kill -0 "$pid" 2>/dev/null
rm -f $sock
end
end
# Avvia il server headless in trasparenza se manca (distaccato dalla shell)
if not test -S $sock
nohup nvim --headless --listen $sock >$log 2>&1 &
disown $last_pid 2>/dev/null; or disown
for i in (seq 1 100)
test -S $sock; and break
sleep 0.1
end
end
if not test -S $sock
echo "vv: server '$name' non avviato (vedi $log)" >&2
return 1
end
# Modello 1: apri UN client nvim connesso al server (TUI visibile).
# Con file -> il file in una nuova tab; senza -> riaggancia la vista.
if set -q argv[2]
command nvim --server $sock --remote-tab $argv[2]
else
command nvim --server $sock
end
end