Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Lua 'require' loading modules #38

Closed
BigfootN opened this issue Jan 30, 2021 · 4 comments
Closed

Lua 'require' loading modules #38

BigfootN opened this issue Jan 30, 2021 · 4 comments

Comments

@BigfootN
Copy link

Hello,

I am having troubles loading modules from init.lua.

For all my plugins I use vim-plug. I recently decided to use completion-nvim. Unfortunately, when loading the module:

local completion = require'completion'

I get:

E5113: Error while calling lua chunk: ~/.config/nvim/init.lua:6: module 'completion' not found:
        no field package.preload['completion']
        no file './completion.lua'
        no file '/usr/share/luajit-2.0.5/completion.lua'
        no file '/usr/local/share/lua/5.1/completion.lua'
        no file '/usr/local/share/lua/5.1/completion/init.lua'
        no file '/usr/share/lua/5.1/completion.lua'
        no file '/usr/share/lua/5.1/completion/init.lua'
        no file './completion.so'
        no file '/usr/local/lib/lua/5.1/completion.so'
        no file '/usr/lib/lua/5.1/completion.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'

I know the files modules are loaded via the paths contained in package.path but since it is impossible (if I'm not mistaken) to have recursive patterns in lua, I don't wish to add every package/neovim extensions paths in package.path.

Is there a more simple way ?

Thank you very much in advance for any help.

@nanotee
Copy link
Owner

nanotee commented Jan 30, 2021

Hello!

I'm not sure what the issue is here, I can't reproduce on my end. Are you calling require'completion' before call plug#end()?

@BigfootN
Copy link
Author

BigfootN commented Jan 30, 2021

Thank you for your quick response.

In fact I call vim-plug from init.vim and load/require modules from init.lua.

Thank you for your help.

@nanotee
Copy link
Owner

nanotee commented Jan 30, 2021

Mhh, it's kind of hard to debug without knowing what your config looks like

In fact I call vim-plug from init.vim and load/require from init.lua.

Do you mean you have both a ~/.config/nvim/init.vim file and a ~/.config/nvim/init.lua file?
:help config says it's an error to use both at the same time

If that's not the case, make sure the call to require'completion' happens after call plug#end() in your init.vim

(The Neovim Gitter channel and the Neovim discussions page are probably more appropriate for these kinds of support questions, it's likely you'll get more eyeballs on your problem 🙂)

@BigfootN
Copy link
Author

Thank you very much for your precious help.

Do you mean you have both a ~/.config/nvim/init.vim file and a ~/.config/nvim/init.lua file?
:help config says it's an error to use both at the same time

Indeed, I think that's the problem. Thank you for your time 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants