Sweets
Configuration

Splitting Your Config

Break a large sweets.lua into multiple files with sweets.include.

sweets.include(...) loads another Lua file inline, as if its contents were pasted at that point. Use it to split a growing config across several files.

sweets.include("bindings.lua")
sweets.include("rules.lua")
sweets.include("monitors.lua")

A common layout is a small top-level sweets.lua that pulls in focused files:

~/.config/sweets/sweets.lua
sweets.general({ mod_key = "SUPER" })

sweets.include("layout.lua")
sweets.include("bindings.lua")
sweets.include("autostart.lua")
~/.config/sweets/bindings.lua
sweets.bind("MOD+Return", "spawn", "foot")
sweets.bind("MOD+q", "close")
for i = 1, 9 do
  sweets.bind("MOD+" .. i, "workspace", i)
end

Included files share the same sweets table and global scope. Variables and functions defined before an include are visible inside it, and vice versa.

Path resolution

Paths resolve relative to the file that calls include, not the working directory.

  • A relative path like "bindings.lua" is looked up next to the including file.
  • An absolute path ("/etc/sweets/shared.lua") is used as-is.
  • A leading ~ expands to your home directory.

Nested includes work naturally: a file in parts/ that includes "extra.lua" finds parts/extra.lua.

Safe by design

  • Missing files are an error. The load fails, the on-screen error bar appears, and Sweets keeps the last good config. Typos surface immediately.
  • Cycles and repeats are ignored. Each file loads at most once per load, so mutual includes cannot loop. Nesting depth is capped as a final safeguard.
  • Errors point at the real file. Problems inside an included file report that file's name and line number.

Hot reload watches every included file, not just sweets.lua. Saving any file in the tree triggers a fail-safe reload.

On this page