Lua Config Directory Structure¶
Example Structure¶
~/.config/nvim
|-- after/
| |-- plugin/
|-- ftplugin/
|-- lua/
| |-- myluamodule.lua
| |-- other_modules/
| |-- anothermodule.lua
| |-- init.lua
|-- plugin/
|-- syntax/
|-- init.lua
~/.config/nvim/
¶
~/.config/nvim/lua
¶
The directory structure for lua files:
~/.config/nvim
|-- after/
|-- lua/
| |-- myluamodule.lua
| |-- other_modules/
| |-- anothermodule.lua
| |-- init.lua
|-- init.lua
Anything that goes in ~/.config/nvim/lua
can be loaded with require
Then the following Lua code will load myluamodule.lua
:
.lua
extension.
Loading other modules in subdirectories (other_modules/anothermodule.lua
) is done with /
or .
:
Any directory that has an init.lua
file can be require
d directly, without
having to specify the name of the file:
So, this structure:
~/.config/nvim
|-- after/
|-- ftplugin/
|-- lua/
| |-- myluamodule.lua
| |-- kolkhis/
| |-- set.lua
| |-- remap.lua
| |-- init.lua
|-- plugin/
|-- syntax/
|-- init.lua
~/.config/nvim/lua/kolkhis/init.lua
:
You can require
it in ~/.config/nvim/init.lua
require
d in lua/kolkhis/init.lua
will be loaded.
~/.config/nvim/after/plugin/
¶
Anything in this directory will be automatically loaded after everything else.
Run Config Files from a Different Location¶
Set the $NVIM_APPNAME
variable to the location that you want nvim to look for
config files.
$XDG_CONFIG_HOME/nvim
, but will allow you to switch to a different configuration. Useful for testing.