2021-10-16 03:03:56 +00:00
|
|
|
# Configuration
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
xplr can be configured using [Lua][1] via a special file named `init.lua`,
|
2022-02-27 08:40:17 +00:00
|
|
|
which can be placed in `~/.config/xplr/` (local to user) or `/etc/xplr/`
|
|
|
|
(global) depending on the use case.
|
2021-06-22 11:52:46 +00:00
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
When xplr loads, it first executes the [built-in init.lua][2] to set the
|
2022-02-27 08:40:17 +00:00
|
|
|
default values, which is then overwritten by another config file, if found
|
2021-06-22 11:52:46 +00:00
|
|
|
using the following lookup order:
|
|
|
|
|
2022-02-27 08:40:17 +00:00
|
|
|
1. `--config /path/to/init.lua`
|
|
|
|
2. `~/.config/xplr/init.lua`
|
|
|
|
3. `/etc/xplr/init.lua`
|
2021-06-24 03:33:28 +00:00
|
|
|
|
2022-02-27 08:40:17 +00:00
|
|
|
The first one found will be loaded by xplr and the lookup will stop.
|
2021-06-24 16:17:01 +00:00
|
|
|
|
2022-02-27 08:40:17 +00:00
|
|
|
The loaded config can be further extended using the `-C` or `--extra-config`
|
|
|
|
command-line option.
|
2021-06-24 16:17:01 +00:00
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
[1]: https://www.lua.org
|
|
|
|
[2]: https://github.com/sayanarijit/xplr/blob/main/src/init.lua
|
|
|
|
[3]: https://xplr.dev/en/upgrade-guide
|
2021-07-03 09:24:37 +00:00
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
## Config
|
|
|
|
|
|
|
|
The xplr configuration, exposed via `xplr.config` Lua API contains the
|
|
|
|
following sections.
|
|
|
|
|
|
|
|
See:
|
|
|
|
|
|
|
|
- [xplr.config.general](https://xplr.dev/en/general-config)
|
|
|
|
- [xplr.config.node_types](https://xplr.dev/en/node_types)
|
|
|
|
- [xplr.config.layouts](https://xplr.dev/en/layouts)
|
|
|
|
- [xplr.config.modes](https://xplr.dev/en/modes)
|
|
|
|
|
|
|
|
## Function
|
|
|
|
|
|
|
|
While `xplr.config` defines all the static parts of the configuration,
|
|
|
|
`xplr.fn` defines all the dynamic parts using functions.
|
|
|
|
|
|
|
|
See: [Lua Function Calls](https://xplr.dev/en/lua-function-calls)
|
2022-04-09 11:36:37 +00:00
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
As always, `xplr.fn.builtin` is where the built-in functions are defined
|
|
|
|
that can be overwritten.
|
|
|
|
|
2022-06-03 16:04:49 +00:00
|
|
|
#### xplr.fn.builtin.try_complete_path
|
|
|
|
|
|
|
|
Tries to auto complete the path in the input buffer
|
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
#### xplr.fn.builtin.fmt_general_table_row_cols_0
|
|
|
|
|
|
|
|
Renders the first column in the table
|
|
|
|
|
|
|
|
#### xplr.fn.builtin.fmt_general_table_row_cols_1
|
|
|
|
|
2023-01-06 22:05:21 +00:00
|
|
|
Renders the second column in the table
|
|
|
|
|
2022-04-09 09:15:39 +00:00
|
|
|
#### xplr.fn.builtin.fmt_general_table_row_cols_2
|
|
|
|
|
|
|
|
Renders the third column in the table
|
|
|
|
|
|
|
|
#### xplr.fn.builtin.fmt_general_table_row_cols_3
|
|
|
|
|
|
|
|
Renders the fourth column in the table
|
|
|
|
|
|
|
|
#### xplr.fn.builtin.fmt_general_table_row_cols_4
|
|
|
|
|
|
|
|
Renders the fifth column in the table
|
|
|
|
|
2022-04-09 11:34:43 +00:00
|
|
|
#### xplr.fn.custom
|
2022-04-09 09:15:39 +00:00
|
|
|
|
|
|
|
This is where the custom functions can be added.
|
|
|
|
|
|
|
|
There is currently no restriction on what kind of functions can be defined
|
|
|
|
in `xplr.fn.custom`.
|
|
|
|
|
|
|
|
You can also use nested tables such as
|
|
|
|
`xplr.fn.custom.my_plugin.my_function` to define custom functions.
|
2022-10-26 18:54:18 +00:00
|
|
|
|
|
|
|
## Hooks
|
|
|
|
|
|
|
|
This section of the configuration cannot be overwritten by another config
|
2022-10-27 05:52:36 +00:00
|
|
|
file or plugin, since this is an optional lua return statement specific to
|
|
|
|
each config file. It can be used to define things that should be explicit
|
|
|
|
for reasons like performance concerns, such as hooks.
|
|
|
|
|
|
|
|
Plugins should expose the hooks, and require users to subscribe to them
|
|
|
|
explicitly.
|
2022-10-26 18:54:18 +00:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
return {
|
2022-10-27 05:52:36 +00:00
|
|
|
-- Add messages to send when the xplr loads.
|
2022-10-26 18:54:18 +00:00
|
|
|
-- This is similar to the `--on-load` command-line option.
|
|
|
|
--
|
|
|
|
-- Type: list of [Message](https://xplr.dev/en/message#message)s
|
|
|
|
on_load = {
|
|
|
|
{ LogSuccess = "Configuration successfully loaded!" },
|
2022-10-27 05:52:36 +00:00
|
|
|
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_load" },
|
|
|
|
},
|
|
|
|
|
|
|
|
-- Add messages to send when the directory changes.
|
|
|
|
--
|
|
|
|
-- Type: list of [Message](https://xplr.dev/en/message#message)s
|
|
|
|
on_directory_change = {
|
|
|
|
{ LogSuccess = "Changed directory" },
|
|
|
|
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_directory_change" },
|
|
|
|
},
|
|
|
|
|
|
|
|
-- Add messages to send when the focus changes.
|
|
|
|
--
|
|
|
|
-- Type: list of [Message](https://xplr.dev/en/message#message)s
|
|
|
|
on_focus_change = {
|
|
|
|
{ LogSuccess = "Changed focus" },
|
|
|
|
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_focus_change" },
|
2022-10-26 18:54:18 +00:00
|
|
|
}
|
2023-01-06 22:02:27 +00:00
|
|
|
|
|
|
|
-- Add messages to send when the mode is switched.
|
|
|
|
--
|
|
|
|
-- Type: list of [Message](https://xplr.dev/en/message#message)s
|
|
|
|
on_mode_switch = {
|
|
|
|
{ LogSuccess = "Switched mode" },
|
|
|
|
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_mode_switch" },
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Add messages to send when the layout is switched
|
|
|
|
--
|
|
|
|
-- Type: list of [Message](https://xplr.dev/en/message#message)s
|
|
|
|
on_layout_switch = {
|
|
|
|
{ LogSuccess = "Switched layout" },
|
|
|
|
{ CallLuaSilently = "custom.some_plugin_with_hooks.on_layout_switch" },
|
|
|
|
}
|
2023-01-09 11:12:15 +00:00
|
|
|
}
|
2022-10-26 18:54:18 +00:00
|
|
|
```
|
2023-04-26 12:59:01 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
> Note:
|
|
|
|
>
|
|
|
|
> It's not recommended to copy the entire configuration, unless you want to
|
|
|
|
> freeze it and miss out on useful updates to the defaults.
|
|
|
|
>
|
|
|
|
> Instead, you can use this as a reference to overwrite only the parts you
|
|
|
|
> want to update.
|
|
|
|
>
|
|
|
|
> If you still want to copy the entire configuration, make sure to put your
|
|
|
|
> customization before the return statement.
|