Splitting Your Config
Split sweets.lua into smaller files
sweets.include(path) runs another Lua file in place. Use it to keep bindings,
rules, and monitors in separate files.
Example
~/.config/sweets/
├── sweets.lua
├── bindings.lua
├── rules.lua
└── parts/
├── general.lua
└── startup.luasweets.include("parts/general.lua")
sweets.include("bindings.lua")
sweets.include("rules.lua")
sweets.include("parts/startup.lua")Each file uses the normal API:
sweets.bind("MOD+D", "spawn", { "fuzzel" })
for number = 1, 9 do
sweets.bind("MOD+" .. number, "workspace", number)
endFiles run in include order.
Optional files
For machine-specific settings that may not exist:
sweets.include("machine.lua", { optional = true })Sweets still watches the path, so creating, editing, or removing the file reloads the config. Existing files must be readable and valid; errors keep the last valid config active. Symlinks must stay inside the configuration root, even when their targets are missing.
Omit the options table, or use optional = false, to require the file. The
32-source limit includes absent optional paths.
Rules
- Paths are relative to the file that includes them.
- Absolute paths,
.., and~don't work. Includes stay inside~/.config/sweets/. - Each file can be included only once, and files can't include each other in a loop.
- A section like
sweets.generalcan appear only once across all your files.
Sharing values
Files share globals, not locals. Set the global before the include that uses it:
palette = { accent = "#C27AFF" }
sweets.include("parts/border.lua")sweets.border({ focused = palette.accent })Reload and errors
Saving any included file reloads the whole config. Errors name the file and the line.
sweets --check-config