Can anyone provide some guidance on how to load Vim (Vim Script) plugins in Neovim?
Up till now, I’ve only ever used plugins written in Lua in Nvim and installed them using Packer, but now I’m trying to install a few Vim plugins like vim-expand-region and vindent which are written in Vim Script.
My current config is organized like this:
~/.config/nvim/
├── init.lua
├── lua
│ └── user
│ ├── alpha.lua
│ ├── autocommands.lua
│ ├── autopairs.lua
│ ├── bufferline.lua
│ ├── cmp.lua
│ ├── colorscheme.lua
│ ├── comment.lua
│ ├── dap
│ │ ├── dap.lua
│ │ ├── dap-python.lua
│ │ ├── init.lua
│ │ └── osv.lua
│ ├── gitsigns.lua
│ ├── hop.lua
│ ├── icons.lua
│ ├── illuminate.lua
│ ├── impatient.lua
│ ├── indentline.lua
│ ├── keymaps.lua
│ ├── lsp
│ │ ├── handlers.lua
│ │ ├── init.lua
│ │ ├── mason.lua
│ │ ├── null-ls.lua
│ │ ├── package-lock.json
│ │ └── settings
│ │ ├── pyright.lua
│ │ └── sumneko_lua.lua
│ ├── lualine.lua
│ ├── navic.lua
│ ├── neoclip.lua
│ ├── nvim-surround.lua
│ ├── nvim-tree.lua
│ ├── options.lua
│ ├── plugins.lua
│ ├── symbols-outline.lua
│ ├── tabnine.lua
│ ├── telescope.lua
│ ├── toggleterm.lua
│ ├── treesitter.lua
│ ├── vim-expand-region.lua
│ └── whichkey.lua
└── plugin
└── packer_compiled.lua
As described in the nanotee guide, to load a .lua plugin, I run require "user.plugin"
in my init.lua file. Then, in the plugin.lua file, I require the plugin itself with code like:
local status_ok, plugin = pcall(require, "plugin")
if not status_ok then
vim.notify("WARNING: plugin.lua failed to load.")
return
end
As I understand it, the require function searches the runtime path looking for a file called “plugin.lua” to load. In my case, my runtime path includes ~/.local/share/nvim/site/pack/*/start/*
and each of the lua plugins installed with Packer contains a lua directory with a plugin.lua file (e.g. ~/.local/share/nvim/site/pack/*/start/plugin/lua/plugin.lua
) which I assume gets sourced when the require function is called.
I tried installing vim-expand-region with Packer, which resulted in this structure:
~/.local/share/nvim/site/pack/packer/start/vim-expand-region/
├── autoload
│ └── expand_region.vim
├── doc
│ ├── expand_region.txt
│ └── tags
├── expand-region.gif
├── MIT-LICENSE.txt
├── plugin
│ └── expand_region.vim
└── README.md
From some of the instructions listed here it seems like the expand_region.vim file needs to be sourced. For Vim, it seems like the plugin should be added to ~/.vim/pack/bundle/start
but that’s not where it gets installed with Packer.
In Vim, it seems like many people use the Plug package manager, but I’m not sure if it’s a good idea to mix multiple package managers (Packer + Plug) in one config.
Anyway, I’m clearly a little confused and would be grateful for any tips.