Skip to content

Sanitize /nix/store/* paths in saved .window_states[*].tabs[*].pane_tree.process.argv for vim/nvim/gvim#128

Open
andreystepanov wants to merge 1 commit into
MLFlexer:mainfrom
andreystepanov:nix-process-argv
Open

Sanitize /nix/store/* paths in saved .window_states[*].tabs[*].pane_tree.process.argv for vim/nvim/gvim#128
andreystepanov wants to merge 1 commit into
MLFlexer:mainfrom
andreystepanov:nix-process-argv

Conversation

@andreystepanov
Copy link
Copy Markdown

This change improves session saving by sanitizing the executable path and command-line arguments (argv) for nix-wrapped Vim/Neovim executables.

  • Replaces full /nix/store/... executable paths with the corresponding basename (process_info.name) to avoid unstable paths across sessions.`
  • Cleans specific command flags (--cmd and -c) followed by nix store paths from process_info.argv to prevent pollution of shell history and improve session portability.
  • Applies this cleanup only for known Vim-related executables (vim, nvim, gvim).
  • Leaves all other arguments and executables untouched for general compatibility.
  • Ensures the first element of argv is always the sanitized executable name.
  • Overall results in cleaner, more stable session JSON with fewer environment-specific artifacts.

This targeted fix addresses issues with restoring nix-wrapper influenced sessions, improving usability on NixOS setups without affecting other platforms or applications.

.window_states[*].tabs[*].pane_tree.process before:

{
  "argv": [
    "/nix/store/jx332jllgyrqbnzi8svnk8xbygc9nbmp-neovim-unwrapped-0.11.5/bin/nvim",
    "--cmd",
    "lua vim.g.loaded_node_provider=0;vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog='/nix/store/252cmdyhmr8ai7qz266yrawgmx7nfz5h-neovim-0.11.5/bin/nvim-python3';vim.g.ruby_host_prog='/nix/store/252cmdyhmr8ai7qz266yrawgmx7nfz5h-neovim-0.11.5/bin/nvim-ruby'",
    "--cmd",
    "set packpath^=/nix/store/g0f4d93y9q79q84qq4g41lyfcw3i1z7h-vim-pack-dir",
    "--cmd",
    "set rtp^=/nix/store/g0f4d93y9q79q84qq4g41lyfcw3i1z7h-vim-pack-dir",
    "Cargo.toml"
  ],
  "cwd": "/home/user/project",
  "executable": "/nix/store/jx332jllgyrqbnzi8svnk8xbygc9nbmp-neovim-unwrapped-0.11.5/bin/nvim",
  "name": "nvim",
  "start_time": 6840603,
  "status": "Sleep"
}

.window_states[*].tabs[*].pane_tree.process after:

{
  "argv": [
    "nvim",
    "Cargo.toml"
  ],
  "cwd": "/home/user/project",
  "executable": "nvim",
  "name": "nvim",
  "start_time": 6840603,
  "status": "Sleep"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant