here 2 scripts are provided:
- nvim-wrap
- nvim-send
nvim-wrap: a paper thin wrapper to ensure that every instance of neovim we launch will always be
listening to the pipe that nvim-send sends commands to, you can use this wrapper to set
and unset environment variables if you want or to launch neovim with another wrapper, your
imagination is the limit.
nvim-send: sends neovim commands into all nvim RTC pipes, if you provide the script with arguments
it will send them like a single command, if you do not it will instead run the send_comms
function which can be overriden from the config with whatever you want inside.
The RTC pipes will be defined as $XDG_RUNTIME_DIR/nvim/nvim.PID.timestamp, where PID is the
process ID of the nvim-wrap script which is then inherited to the neovim instance by running it with
exec, the timestamp is the amount of seconds since unix epoch at the time before the nvim instance
is exec'd, if for whatever reason $XDG_RUNTIME_DIR was not set in the environment the script falls
back to /tmp following the behaviour from upstream.
The location for the RTC pipe can be set on ${XDG_CONFIG_HOME:-${HOME}/.config}/nvim-wrap/configrc
by setting the var pipe_loc to a different dir.
installation:
# clone the repo
git clone https://github.com/eylles/nvim-wrap.git
# to install just run
make install clean
# by default this will put both scripts in:
# $HOME/.local/bin
# you can configure that in config.mkNow add some alias like this to your shell's rc (bashrc, zshrc, .profile)
alias nvim="nvim-wrap"or even link the nvim-wrap script to /usr/bin/editor if you are using the debian alternatives
system, just edit the config.mk and change PREFIX to /usr/local, install and then run this
command to register nvim-wrap onto the alternatives system:
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/nvim-wrap 30
# or if you want something more "complete", set "ZIP_MAN = true" in config.mk then run this command
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/nvim-wrap 30 --slave /usr/share/man/man1/editor.1.gz editor.1.gz /usr/local/man/man1/nvim-wrap.1.gz
# you will get the zipped manpage as editor.1.gz and accessible from man editorhave fun!!!
These scripts are a more general version from the nvim-colo-reload scripts found in the pywal-extra repo.
A couple of reasons i've found through the years:
-
pywal integration: one common pitfal for pywal integration was/is that even if the colorscheme is able to perform dynamic reload when the base colors change like neopywal some other elements like the statusline colorscheme may not be reloaded so additional commands have to bee hooked on to the colorscheme change.
-
bad vertical scrolling on splits: an old bug that has existed since neovim 0.5 and was "fixed" on neovim 0.6, it tends to happen more on a true xterm since neovim has some wrong assumptions about scroll handling, to simplify neovim expects the
sgmlpandsgmrpsequences to be set when the environment variable of a true xtermXTERM_VERSIONexists within the environment, for xterm to have those specific scrolling sequences it has to use thedecTerminalIDvt420, but that is usually NOT the default terminal id configured for xterm as distributions usually set it tovt100for compatibility while users tend to set it tovt340for sixel graphics support, the real fix is for neovim to use theDECRQSScontrol sequence to get the correct scrolling method instead relaying on env vars, but until that happens (still a bug in neovim 0.10, gotta check on 0.11 yet) the workaround is to use a neovim wrapper that unsets theXTERM_VERSIONvariable before running neovim, with nvim-wrap just putunset XTERM_VERSIONinside your config and it will work.