Skip to content

config.lua

config.lua is an optional Lua file loaded at startup before the UI appears. Use it for programmatic configuration — conditional settings, loading plugins, and anything that benefits from real code instead of TOML.

File location:

  • ~/.config/jjui/config.lua
  • $JJUI_CONFIG_DIR/config.lua

Define a top-level setup(config) function and jjui will call it at startup with a config object for registering actions, adding bindings, and setting colors.

function setup(config)
-- register actions and bindings here
end

The config object exposes config.action(...) and config.bind(...) for registering actions and bindings. For the full API, see Actions and Bindings.


These fields are available on config inside setup and are read-only:

ValueTypeDescription
config.repostringAbsolute path of the current repository
config.terminal.dark_modeboolWhether the terminal reports dark mode
config.terminal.bgstringTerminal background color (hex, if detectable)
config.terminal.fgstringTerminal foreground color (hex, if detectable)

config.lua and [[actions]].lua scripts in config.toml run in the same Lua VM. Any global function defined in config.lua is available to TOML action scripts:

-- config.lua
function current_diff()
return jj("diff", "-r", context.change_id(), "--git")
end
config.toml
[[actions]]
name = "copy-diff"
lua = '''
copy_to_clipboard(current_diff())
'''

require(...) resolves modules from your config directory in addition to the standard Lua path. Place Lua files under ~/.config/jjui/ and load them with require("plugins.name").

local my_plugin = require("plugins.my_plugin")
function setup(config)
my_plugin.setup(config)
end

For practical examples, see the Lua Cookbook. For the full runtime API (context, revisions, jj, flash, etc.), see Lua Scripting.

Contribute Community