Skip to content

Commit 89e4c3f

Browse files
committed
chore(jj): fix types, warn when jj is not found
chore(defaults): fix lint warnings
1 parent 07795ed commit 89e4c3f

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ function M._default_previewer_fn()
1010
if type(winopts) == "function" then
1111
winopts = winopts() or {}
1212
winopts.preview = type(winopts.preview) == "table" and winopts.preview or {}
13-
winopts.preview.default = winopts.preview.default or M.defaults.winopts.preview.default
13+
winopts.preview.default = winopts.preview.default
14+
or utils.map_get(M.defaults, "winopts.preview.default")
1415
end
15-
local previewer = M.globals.default_previewer or winopts.preview.default
16+
local previewer = M.globals.default_previewer or utils.map_get(winopts, "preview.default")
1617
-- the setup function cannot have a custom previewer as deepcopy
1718
-- fails with stack overflow while trying to copy the custom class
1819
-- the workaround is to define the previewer as a function instead
@@ -894,11 +895,16 @@ M.defaults.git = {
894895
},
895896
}
896897

898+
---Jujutsu pickers parent table.
899+
---@class fzf-lua.config.JJ
900+
---@field files fzf-lua.config.JJFiles
897901
M.defaults.jj = {
898902
---Jujutsu tracked files.
903+
---@diagnostic disable-next-line: param-type-mismatch
904+
---@class fzf-lua.config.JJFiles: fzf-lua.config.GitFiles
899905
files = vim.tbl_deep_extend("force", M.defaults.git.files, {
900-
cmd = "jj file list --ignore-working-copy",
901-
git_icons = false,
906+
cmd = "jj file list --ignore-working-copy",
907+
git_icons = false,
902908
}),
903909
}
904910

lua/fzf-lua/providers/jj.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ local config = require "fzf-lua.config"
66
local M = {}
77

88
local function set_jj_cwd_args(opts)
9+
if vim.fn.executable("jj") ~= 1 then
10+
utils.warn(string.format("'%s' requires jj (https://github.com/jj-vcs/jj).", utils.get_info().cmd))
11+
return
12+
end
913
-- verify cwd is a jj repo, override user supplied
1014
-- cwd if cwd isn't a jj repo, error was already
1115
-- printed to `:messages` by 'path.jj_root'
@@ -16,13 +20,13 @@ local function set_jj_cwd_args(opts)
1620
return opts
1721
end
1822

19-
---@param opts table|{}?
23+
---@param opts fzf-lua.config.JJFiles|{}?
2024
---@return thread?, string?, table?
2125
M.files = function(opts)
2226
opts = config.normalize_opts(opts, "jj.files")
2327
if not opts then return end
2428
opts = set_jj_cwd_args(opts)
25-
if not opts.cwd then return end
29+
if not opts or not opts.cwd then return end
2630
return core.fzf_exec(opts.cmd, opts)
2731
end
2832

0 commit comments

Comments
 (0)