Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use init.lua instead of init.vim

Tags:

lua

neovim

My friend wrote a config for me in init.lua but as I am new , I only know how to configure init.vim with vim-plug .. If I got init.lua then how Do i install the package using neovim ?

like image 752
Anish Shah Avatar asked Aug 08 '26 11:08

Anish Shah


1 Answers

What you could do, is source your vim script file with your vim-plug block from within init.lua using vim.cmd (see: neovim docs).

To source your vim-plug file from your nvim config location, which in my case on macOS and Debian is $HOME/.config/nvim/ you could place the following in your init.lua:

vim.cmd [[source ~/.config/nvim/vimplugconfig.vim]]

And then ~/.config/nvim/vimplugconfig.vim could look like:

call plug#begin()

Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }

call plug#end()

If you are using vim-plug for both vim and neovim, here's an example plugin that was already installed with vim-plug in vim, so that you don't have to install it twice. Following the above example here's what you'd have in your ~/.config/nvim/vimplugconfig.vim:

call plug#begin()

Plug 'junegunn/limelight.vim', {'dir': '~/.vim/plugged/limelight.vim'}

Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }

call plug#end()

Just make sure you don't put the neovim plugin specific lines (e.g. semshi) in your .vimrc, because then vim-plug will try to manage it, and it may fail.

Finally, vim-plug README.md does mention how to install it when it comes to neovim either with curl or flatpak (on Unix/Linux), but they don't actually mention how to do anything in lua specifically when calling vim-plug, so I've personally stuck with the above method while using vim-plug.

like image 150
JesseBot Avatar answered Aug 10 '26 18:08

JesseBot