0

In my init.lua I call:

require('plugins')
require('theme')

This works when editing in the ~/.config/nvim directory, where init.lua, plugins.lua and theme.lua are located.

But when I run vim outside of this directory, I get the following error:

E5113: Error while calling lua chunk: /home/miki/.config/nvim/init.lua:5: module 'plugins' n
ot found:
        no field package.preload['plugins']
        no file './plugins.lua'
        no file '/usr/share/luajit-2.1.0-beta3/plugins.lua'
        no file '/usr/local/share/lua/5.1/plugins.lua'
        no file '/usr/local/share/lua/5.1/plugins/init.lua'
        no file '/usr/share/lua/5.1/plugins.lua'
        no file '/usr/share/lua/5.1/plugins/init.lua'
        no file './plugins.so'
        no file '/usr/local/lib/lua/5.1/plugins.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/plugins.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'

How do I add ~/.config/nvim to the places Lua looks for modules?

I also tried to put these modules into ~/.config/nvim/lua folder, but then they were not found even in the init.lua.

1

Removing the following lines from my init.lua

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=~/.local/share/nvim/site]]

and placing all my .lua modules (except init.lua) into ~/.config/nvim/lua fixed the issue.

2
  • Welcome to Vi and Vim! For the record, rather than delete and post a modified answer, we encourage you to make use of the edit button.
    – D. Ben Knoble
    Oct 4 at 23:13
  • I didn't modify it. I thought my change work, posted it, immediately realized I celebrated prematurely, deleted the answer and later found a new solution which I posted... Oct 6 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.