nvim: wrapper script for persistent+remote control

This commit is contained in:
Daniel Lundin 2025-01-02 10:55:43 +01:00
parent 9ee84b89e6
commit 311cd9042e
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
3 changed files with 17 additions and 2 deletions

View file

@ -53,7 +53,7 @@
description = "Open a file in already running nvim"; description = "Open a file in already running nvim";
argumentNames = [ "file" ]; argumentNames = [ "file" ];
body = '' body = ''
nvim --server "$XDG_RUNTIME_DIR/nvim-persistent.sock" --remote (readlink -f "$file") nvim-remote --remote (readlink -f "$file")
''; '';
}; };

View file

@ -33,6 +33,7 @@
unfocused-split-opacity = 1.0; unfocused-split-opacity = 1.0;
shell-integration = "fish"; shell-integration = "fish";
initial-command = "nvim-remote";
window-decoration = true; window-decoration = true;
gtk-single-instance = true; gtk-single-instance = true;
@ -112,7 +113,9 @@
"System" "System"
"TerminalEmulator" "TerminalEmulator"
]; ];
exec = ''ghostty --class=com.mitchellh.ghostty-nemo --command="ssh -t nemo"''; exec = ''
ghostty --class=com.mitchellh.ghostty-nemo --command="ssh -t nemo" --initial-command="ssh -t nemo nvim-remote"
'';
genericName = "Ghostty (nemo)"; genericName = "Ghostty (nemo)";
icon = "com.mitchellh.ghostty"; icon = "com.mitchellh.ghostty";
name = "Ghostty (nemo)"; name = "Ghostty (nemo)";

View file

@ -4,11 +4,23 @@
pkgs, pkgs,
... ...
}: }:
let
nvim-remote = pkgs.writeShellApplication {
name = "nvim-remote";
text = ''
_sess=$(echo -n "$USER@''${SSH_CONNECTION:-$HOSTNAME}" | tr -c '[:alnum:]@.' '_')
_nvim_sock="''${XDG_RUNTIME_DIR:-/tmp}/nvim.$_sess.sock"
exec nvim --listen "$_nvim_sock" --server "$_nvim_sock" "$@"
'';
};
in
{ {
imports = [ imports = [
./treesitter.nix ./treesitter.nix
]; ];
home.packages = [ nvim-remote ];
programs.man.generateCaches = false; programs.man.generateCaches = false;
programs.neovim = { programs.neovim = {