I have structured my neovim config files like this

├── init.lua
└── lua
    └── [username]
        ├── core
        │   └── options.lua
        ├── init.lua
        └── plugins

These are the contents of my files

-- init.lua

-- ./lua/[username]/init.lua

print("hello world")
-- ./lua/[username]/core/options.lua

local opt = vim.opt -- aliasing

-- line number
opt.number = true

-- tabs & intendation
opt.tabstop = 4
opt.shiftwidth = 4
opt.expandtab = true
opt.autoindent = true

-- search
opt.ignorecase = true
opt.smartcase = true

-- appearance
opt.termguicolors = false
opt.background = "dark"

When I open neovim, I get this error

hello world
Error detected while processing /home/[username]/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/[username]/.config/nvim/lua/[username]/init.lua:2: module 'core.options' not found:
        no field package.preload['core.options']
        no file './core/options.lua'
        no file '/usr/share/luajit-2.1.0-beta3/core/options.lua'
        no file '/usr/local/share/lua/5.1/core/options.lua'
        no file '/usr/local/share/lua/5.1/core/options/init.lua'
        no file '/usr/share/lua/5.1/core/options.lua'
        no file '/usr/share/lua/5.1/core/options/init.lua'
        no file './core/options.so'
        no file '/usr/local/lib/lua/5.1/core/options.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/core/options.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './core.so'
        no file '/usr/local/lib/lua/5.1/core.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/core.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /home/[username]/.config/nvim/lua/[username]/init.lua:2: in main chunk
        [C]: in function 'require'
        /home/[username]/.config/nvim/init.lua:1: in main chunk
Press ENTER or type command to continue
  • I did find a solution, seems like every require call in lua/neovim starts from the lua directory. So changed core.options to [username].core.options.
    – me.nkr
    Jun 10, 2023 at 18:03
  • Exactly. I just wanna point out that this is how Lua works, Neovim doesn't deviate from it
    – Tae
    Jun 10, 2023 at 18:34
  • @me.nkr please post answers down below in the "Answers" section, not in comments.
    – D. Ben Knoble
    Jun 12, 2023 at 13:57
  • @D.BenKnoble I would like to but I still have not idea why that works, If anyone knows why that does, it would be a better answer I guess.
    – me.nkr
    Jun 13, 2023 at 8:13

1 Answer 1


The solution was to change core.options to [username].core.options, since every require call in Lua looks for the file from the lua/ directory.

The reason is not completely clear to me yet. But a simple reason would be, as @Tae said in comments,

This is how Lua works.

I believe documentation of Lua require function can shed some light.

If someone can explain it better, please do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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