How to run nvim in an “isolated” environment?

Hello!

I was recently writing a “minimal” init.lua for a friend to try out Neovim nightly with LSP, and I’m curious as to the best way to test it.

I know you can run something like nvim -u path/to/config . to use a specific config file, but I’m wanting to make sure that things like the packer.nvim bootstrapping itself and using different plugins without having to blow away my own environment.

Thanks!

1 Like

The minimal init.lua I provide in nvim-lspconfig both bootstraps itself and installs itself in /tmp

3 Likes

What is the difference between the nvim_command on line 10 and the vim.cmds on lines 12-14? Also isn’t line 10 the same as line 12?

Never promised it was a non-rendundant/perfect config :slight_smile: Edit: now it is

vim.cmd = vim.api.nvim_command

1 Like

Since Neovim reads XDG base directory environment variables, I have wrapper shell script that I keep in its own folder for when I want an isolated environment

local_nvim.sh
#!/usr/bin/env sh

REAL_HOME="$HOME"
NVIM_SRC_DIR="$REAL_HOME/.local/bin/neovim-src"
NVIM_BIN="$NVIM_SRC_DIR/build/bin/nvim"
export VIMRUNTIME="$NVIM_SRC_DIR/runtime"
export HOME="$PWD"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"

exec "$NVIM_BIN" "$@"

It’s probably not 100% isolated but it’s served me well for simple testing/troubleshooting

Now it’s even more minimal :grinning:

I think this is what I was looking for! I’ll try something like this out and see if it works for me. Thanks!