iTranslated by AI
How to Create a Minimal vimrc for Reproducing Neovim Plugin Issues
Something seems off after updating my Neovim plugins... Well, based on the error messages and recent updates, I suspect this plugin! Here's what to do next once you've reached that point.
First and Foremost, Look for Issues
Many Neovim users update their plugins daily, so first, check if there are similar reports for that plugin.
Opening an issue requires effort, as it's important to provide quick responses and conduct further investigation after posting. If someone else has already reported it, join that discussion. Avoid "Same here!" comments as they can be noisy; instead, just leave a +1 ( 👍 ) reaction.
If the original reporter hasn't provided reproduction steps, or if no issue has been raised yet, it's best to create a minimal vimrc (init.vim or init.lua) like the following.
Creating a Minimal vimrc for Reproduction
To set up a reproduction environment easily, it is convenient to create a shell function in your .bashrc or .zshrc.
Here is the version for init.vim + vim-plug:
function nvim-minimal-env() {
cd "$(mktemp -d)"
export HOME=$PWD
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CACHE_HOME=$HOME/.cache
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
mkdir -p ~/.config/nvim
cat << EOF > ~/.config/nvim/init.vim
syntax enable
filetype plugin indent on
call plug#begin(stdpath('data') . '/plugged')
" Plug ''
call plug#end()
EOF
pwd
ls -la
}
Here is the version for init.lua + packer.nvim:
function nvim-minimal-env-packer() {
cd "$(mktemp -d)"
export HOME=$PWD
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CACHE_HOME=$HOME/.cache
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
mkdir -p ~/.config/nvim
cat << EOF > ~/.config/nvim/init.lua
vim.cmd [[syntax enable]]
vim.cmd [[filetype plugin indent on]]
local execute = vim.api.nvim_command
local install_path = vim.fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
end
vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function()
use {'wbthomason/packer.nvim', opt = true}
end)
EOF
--- do not write under this line because it was returned
pwd
ls -la
}
After that, you can simply run nvim-minimal-env or nvim-minimal-env-packer as a command to create a reproduction environment under /tmp.
Then, establish a procedure to reproduce the bug in that environment. Copy and paste settings from your own vimrc if necessary. Aim to build the setup with the minimum number of lines required to reproduce the issue.
By the way, for zsh plugins
function zsh-minimal-env() {
cd "$(mktemp -d)"
ZDOTDIR=$PWD HOME=$PWD zsh -df
}
The quickest way is to run this and then source the target plugin.
Discussion