Skip to content

Commit 4555533

Browse files
zyd2001ibhagwan
authored andcommitted
feat: fzf.vim's global history folder (#1127)
Use fzf.vim's `g:fzf_history_dir` to store a history file per command.
1 parent e6b2bb6 commit 4555533

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/fzf-lua/config.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ function M.normalize_opts(opts, globals, __resume_key)
222222
opts.fzf_opts["--delimiter"] = string.format("[%s]", utils.nbsp)
223223
end
224224

225+
-- fzf.vim's `g:fzf_history_dir` (#1127)
226+
if vim.g.fzf_history_dir and opts.fzf_opts["--history"] == nil then
227+
local histdir = vim.fn.expand(vim.g.fzf_history_dir)
228+
if vim.fn.isdirectory(histdir) == 0 then
229+
pcall(vim.fn.mkdir, histdir)
230+
end
231+
if vim.fn.isdirectory(histdir) == 1 and type(opts.__resume_key) == "string" then
232+
opts.fzf_opts["--history"] = path.join({ histdir, opts.__resume_key })
233+
end
234+
end
235+
225236
-- prioritize fzf-tmux split pane flags over the
226237
-- popup flag `-p` from fzf-lua defaults (#865)
227238
opts._is_fzf_tmux_popup = true

0 commit comments

Comments
 (0)