Skip to content

Commit accfef9

Browse files
phanenibhagwan
authored andcommitted
chore(luals): more config typings
fzf-lua.config.Base inherit config.Base generated from vim macro fix config.Git config.BufferLines opts.{_bufnr,_bufname} -> local var fix luals dedup file_icons color_icons _types multiprocess git_icons fzf_colors dedup continue dedup d winopts d _actions d fzf_opts cwd_prompt silent line_query is files opts cached_hls? previewer actions can be false fix: changes extends jumps opts.preview opts.mark opts.complete luals fixes git pickers set headers colorschems opts._cur.. remove useless options opts._packpath opts._live daps opts._frames opts._cfgs diagnosics opts.__signs ui_select grep helptags tmux meta oldfile tags lsp api rename unsilent deprecated
1 parent 5d393ba commit accfef9

24 files changed

Lines changed: 992 additions & 187 deletions

lua/fzf-lua/complete.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ local set_cmp_opts_path = function(opts)
7979
end
8080

8181
M.path = function(opts)
82+
---@type fzf-lua.config.CompletePath
8283
opts = config.normalize_opts(opts, "complete_path")
8384
if not opts then return end
8485
opts.cmd = opts.cmd or (function()
@@ -97,9 +98,9 @@ M.path = function(opts)
9798
end
9899

99100
M.file = function(opts)
101+
---@type fzf-lua.config.CompleteFile
100102
opts = config.normalize_opts(opts, "complete_file")
101103
if not opts then return end
102-
opts.cmp_is_file = true
103104
opts.cmd = opts.cmd or (function()
104105
if vim.fn.executable("fdfind") == 1 then
105106
return "fdfind --strip-cwd-prefix --type f --exclude .git"
@@ -118,6 +119,7 @@ M.file = function(opts)
118119
end
119120

120121
M.line = function(opts)
122+
---@type fzf-lua.config.CompleteLine
121123
opts = config.normalize_opts(opts, "complete_line")
122124
if not opts then return end
123125
opts.query = (function()
@@ -133,6 +135,7 @@ M.line = function(opts)
133135
end
134136

135137
M.bline = function(opts)
138+
---@type fzf-lua.config.CompleteBline
136139
opts = opts or {}
137140
opts.current_buffer_only = true
138141
return M.line(opts)

lua/fzf-lua/config.lua

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ local eval = function(v, ...)
142142
return v
143143
end
144144

145-
---@param opts table<string, unknown>|fun():table?
145+
---@param opts fzf-lua.config.Base|{}|fun():table?
146146
---@param globals string|table?
147147
---@param __resume_key string?
148148
---@return fzf-lua.Config?
@@ -272,10 +272,7 @@ function M.normalize_opts(opts, globals, __resume_key)
272272
-- Backward compat: merge `winopts` with outputs from `winopts_fn`
273273
local winopts_fn = opts.winopts_fn or M.globals.winopts_fn
274274
if type(winopts_fn) == "function" then
275-
if not opts.silent then
276-
utils.warn(
277-
"Deprecated option: 'winopts_fn' -> 'winopts'. Add 'silent=true' to hide this message.")
278-
end
275+
vim.deprecate("winopts_fn", "winopts", "Jan 2026", "FzfLua")
279276
local ret = winopts_fn(opts) or {}
280277
if not utils.tbl_isempty(ret) and (not opts.winopts or type(opts.winopts) == "table") then
281278
opts.winopts = vim.tbl_deep_extend("force", opts.winopts or {}, ret)
@@ -445,11 +442,7 @@ function M.normalize_opts(opts, globals, __resume_key)
445442
utils.map_set(opts, new_key, old_val)
446443
end
447444
utils.map_set(opts, old_key, nil)
448-
if not opts.silent then
449-
utils.warn(string.format(
450-
"Deprecated option: '%s' -> '%s'. Add 'silent=true' to hide this message.",
451-
old_key, new_key))
452-
end
445+
vim.deprecate(old_key, new_key, "Jan 2026", "FzfLua")
453446
end
454447
end
455448

lua/fzf-lua/core.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142
-- Main API, see:
143143
-- https://github.com/ibhagwan/fzf-lua/wiki/Advanced
144144
---@param contents content
145-
---@param opts? {fn_transform: function}
145+
---@param opts? fzf-lua.config.Base|{}
146146
---@return thread?, string?, table?
147147
M.fzf_exec = function(contents, opts)
148148
opts = config.normalize_opts(opts or {}, {})
@@ -158,7 +158,7 @@ M.fzf_exec = function(contents, opts)
158158
-- command is independent, most of it's options are serialized as strings and the
159159
-- rest are read from the main instance config over RPC
160160
local mt = (opts.multiprocess and type(contents) == "string")
161-
local cmd = mt and shell.stringify_mt(contents, opts)
161+
local cmd = mt and shell.stringify_mt(contents --[[@as string]], opts)
162162
or shell.stringify(contents, opts, nil)
163163
-- Contents sent to fzf can only be nil or a shell command (string)
164164
-- the API accepts both tables and functions which we "stringify"

lua/fzf-lua/defaults.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ function M._man_cmd_fn(bat_pager)
3939
return string.format("%s %%s 2>/dev/null | %s", cmd, pager)
4040
end
4141

42+
---missing fields are injected later, not sure how to tell luals about it
43+
---@diagnostic disable: missing-fields
44+
---@type fzf-lua.config.Defaults
4245
M.defaults = {
4346
nbsp = utils.nbsp,
4447
winopts = {
@@ -360,6 +363,7 @@ M.defaults.files = {
360363
winopts = { preview = { winopts = { cursorline = false } } },
361364
}
362365

366+
---@diagnostic disable-next-line: assign-type-mismatch
363367
M.defaults.global = vim.tbl_deep_extend("force", M.defaults.files, {
364368
silent = true,
365369
-- TODO: lsp_workspace_symbols locate, not working yet
@@ -596,6 +600,7 @@ M.defaults.grep = {
596600
_treesitter = true,
597601
}
598602

603+
---@diagnostic disable-next-line: assign-type-mismatch
599604
M.defaults.grep_curbuf = vim.tbl_deep_extend("force", M.defaults.grep, {
600605
rg_glob = false, -- meaningless for single file rg
601606
exec_empty_query = true, -- makes sense to display lines immediately
@@ -764,6 +769,7 @@ M.defaults.lines = {
764769
_ctx = { includeBuflist = true },
765770
}
766771

772+
---@diagnostic disable-next-line: assign-type-mismatch
767773
M.defaults.blines = vim.tbl_deep_extend("force", M.defaults.lines, {
768774
show_bufname = false,
769775
show_unloaded = true,
@@ -1126,8 +1132,10 @@ M.defaults.marks = {
11261132
}
11271133

11281134
M.defaults.changes = {
1129-
cmd = "changes",
1130-
h1 = "change",
1135+
cmd = "changes",
1136+
h1 = "change",
1137+
actions = { ["enter"] = actions.goto_jump },
1138+
previewer = { _ctor = previewers.builtin.jumps },
11311139
}
11321140

11331141
M.defaults.jumps = {

0 commit comments

Comments
 (0)