version = "1.0.0" -- This needs to be global; ignore diagnostics that say otherwise

---@diagnostic disable
local xplr = xplr
---@diagnostic enable

-- General config
xplr.config.general.show_hidden = true

-- This is necessary to be able to source lua files from within ~/.config/xplr
local home = os.getenv("HOME")
package.path = home
    .. "/.config/xplr/?.lua;"
    .. package.path

-- Plugins
require("plugins")

-- Preview
local preview = require("preview")
local split_preview = {
    Horizontal = {
        config = {
            constraints = {
                { Percentage = 60 },
                { Percentage = 40 },
            },
        },
        splits = {
            "Table",
            preview.preview_pane,
        },
    },
}
xplr.config.layouts.builtin.default =
    xplr.util.layout_replace(xplr.config.layouts.builtin.default, "Table", split_preview)

xplr.config.modes.builtin.default.key_bindings.on_key['*'] = {
    help = "toggle exe",
    messages = {
        {
            BashExecSilently0 = [===[
                f="$XPLR_FOCUS_PATH"
                if [ -x "$f" ]; then
                    chmod -x "$f"
                else
                    chmod +x "$f"
                fi
                "$XPLR" -m 'ExplorePwd'
                "$XPLR" -m 'FocusPath: %q' "$f"
            ]===],
        },
    },
}

-- Fzf
require("fzf")
