fix(fzf): decouple defaults
from opts
to easy switch profiles (#4190)
## Description This decouples `defaults` from `opts`, so that if users switch to another profile they can take advantage of the profile's default settings and prompts. I use `default-title` either way. I just stumbled upon this when I tried the rest profiles and thought maybe there would be users who would prefer to have the default prompts if they chose another profile. <!-- Describe the big picture of your changes to communicate to the maintainers why we should accept this pull request. --> ## Related Issue(s) No <!-- If this PR fixes any issues, please link to the issue here. - Fixes #<issue_number> --> ## Screenshots <!-- Add screenshots of the changes if applicable. --> ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:

committed by
GitHub

parent
5e485d39b4
commit
0819f9396e
@ -74,18 +74,6 @@ return {
|
||||
config.defaults.actions.files["alt-c"] = config.defaults.actions.files["ctrl-r"]
|
||||
config.set_action_helpstr(config.defaults.actions.files["ctrl-r"], "toggle-root-dir")
|
||||
|
||||
-- use the same prompt for all
|
||||
local defaults = require("fzf-lua.profiles.default-title")
|
||||
local function fix(t)
|
||||
t.prompt = t.prompt ~= nil and " " or nil
|
||||
for _, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
fix(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
fix(defaults)
|
||||
|
||||
local img_previewer ---@type string[]?
|
||||
for _, v in ipairs({
|
||||
{ cmd = "ueberzug", args = {} },
|
||||
@ -98,7 +86,8 @@ return {
|
||||
end
|
||||
end
|
||||
|
||||
return vim.tbl_deep_extend("force", defaults, {
|
||||
return {
|
||||
"default-title",
|
||||
fzf_colors = true,
|
||||
fzf_opts = {
|
||||
["--no-scrollbar"] = true,
|
||||
@ -186,9 +175,24 @@ return {
|
||||
previewer = vim.fn.executable("delta") == 1 and "codeaction_native" or nil,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
if opts[1] == "default-title" then
|
||||
-- use the same prompt for all pickers for profile `default-title` and
|
||||
-- profiles that use `default-title` as base profile
|
||||
local function fix(t)
|
||||
t.prompt = t.prompt ~= nil and " " or nil
|
||||
for _, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
fix(v)
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
opts = vim.tbl_deep_extend("force", fix(require("fzf-lua.profiles.default-title")), opts)
|
||||
opts[1] = nil
|
||||
end
|
||||
require("fzf-lua").setup(opts)
|
||||
end,
|
||||
init = function()
|
||||
|
Reference in New Issue
Block a user