I have structured my neovim config files like this
~/.config/nvim
├── init.lua
└── lua
└── [username]
├── core
│ └── options.lua
├── init.lua
└── plugins
These are the contents of my files
-- init.lua
require("[username]")
-- ./lua/[username]/init.lua
print("hello world")
require("core.options")
-- ./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
core.options
to[username].core.options
.