current commit
260325.4 · docs(jj): fix jj for gen_option
local core = require "fzf-lua.core"
local path = require "fzf-lua.path"
local utils = require "fzf-lua.utils"
local config = require "fzf-lua.config"

local M = {}

local function set_jj_cwd_args(opts)
  if vim.fn.executable("jj") ~= 1 then
    utils.warn(string.format("'%s' requires jj (https://github.com/jj-vcs/jj).", utils.get_info().cmd))
    return
  end
  -- verify cwd is a jj repo, override user supplied
  -- cwd if cwd isn't a jj repo, error was already
  -- printed to `:messages` by 'path.jj_root'
  local jj_root = path.jj_root(opts)
  if not opts.cwd or not jj_root then
    opts.cwd = jj_root
  end
  return opts
end

---@param opts fzf-lua.config.JjFiles|{}?
---@return thread?, string?, table?
M.files = function(opts)
  opts = config.normalize_opts(opts, "jj.files")
  if not opts then return end
  opts = set_jj_cwd_args(opts)
  if not opts or not opts.cwd then return end
  return core.fzf_exec(opts.cmd, opts)
end

return M