diff --git a/README.md b/README.md index 1fb69ff0..694cd600 100644 --- a/README.md +++ b/README.md @@ -717,7 +717,13 @@ require'fzf-lua'.setup { -- ext_ft_override = { ["ksql"] = "sql", ... }, }, }, - -- provider setup + -- PROVIDERS SETUP + -- use `defaults` (table or function) if you wish to set "global-provider" defaults + -- for exmaple, disabling file icons globally and open the quickfix list at the top + -- defaults = { + -- file_icons = false, + -- copen = "topleft copen", + -- }, files = { -- previewer = "bat", -- uncomment to override previewer -- (name from 'previewers' table) diff --git a/lua/fzf-lua/actions.lua b/lua/fzf-lua/actions.lua index c080d1d1..c8afc5e4 100644 --- a/lua/fzf-lua/actions.lua +++ b/lua/fzf-lua/actions.lua @@ -202,7 +202,9 @@ local sel_to_qf = function(selected, opts, is_loclist) items = qf_list, title = title, }) - vim.cmd(opts.lopen or "lopen") + if opts.lopen ~= false then + vim.cmd(opts.lopen or "botright lopen") + end else -- Set the quickfix title to last query and -- append a new list to end of the stack (#635) @@ -212,7 +214,9 @@ local sel_to_qf = function(selected, opts, is_loclist) title = title, -- nr = nr, }) - vim.cmd(opts.copen or "copen") + if opts.copen ~= false then + vim.cmd(opts.copen or "botright copen") + end end end diff --git a/lua/fzf-lua/config.lua b/lua/fzf-lua/config.lua index 6e978558..a6d25f31 100644 --- a/lua/fzf-lua/config.lua +++ b/lua/fzf-lua/config.lua @@ -132,7 +132,14 @@ function M.normalize_opts(opts, defaults) defaults._actions()) end - -- First, merge with provider defaults + -- First merge with the users' "provider-global" defaults + if type(M.globals.defaults) == "table" then + opts = vim.tbl_deep_extend("keep", opts, utils.tbl_deep_clone(M.globals.defaults)) + elseif type(M.globals.defaults) == "function" then + opts = vim.tbl_deep_extend("keep", opts, utils.tbl_deep_clone(M.globals.defaults())) + end + + -- Then merge with provider defaults "keeping" provider-globals -- we must clone the 'defaults' tbl, otherwise 'opts.actions.default' -- overrides 'config.globals.lsp.actions.default' in neovim 6.0 -- which then prevents the default action of all other LSP providers @@ -220,6 +227,7 @@ function M.normalize_opts(opts, defaults) -- Merge global resume options opts.global_resume = get_opt("global_resume", opts, M.globals) + -- DEPRECATED: use `defaults` (provider-defaults) table -- global option overrides. If exists, these options will -- be used in a "LOGICAL AND" against the local option (#188) -- e.g.: diff --git a/lua/fzf-lua/profiles/borderless.lua b/lua/fzf-lua/profiles/borderless.lua index f50d235e..cfd7d89f 100644 --- a/lua/fzf-lua/profiles/borderless.lua +++ b/lua/fzf-lua/profiles/borderless.lua @@ -3,11 +3,9 @@ local hls = { sel = "PmenuSel", } return { - desc = "borderless and minimalistic", - global_git_icons = false, - global_file_icons = false, - fzf_opts = {}, - winopts = { + desc = "borderless and minimalistic", + fzf_opts = {}, + winopts = { -- border = "none", -- border = "thicccc", border = { " ", " ", " ", " ", " ", " ", " ", " " }, @@ -17,7 +15,7 @@ return { title_pos = "center", }, }, - hls = { + hls = { border = hls.bg, preview_border = hls.bg, preview_title = hls.sel, @@ -26,11 +24,15 @@ return { -- TODO: not working with `scrollbar = "border"` when `border = "none" -- scrollborder_f = "@function", }, - fzf_colors = { + fzf_colors = { ["gutter"] = { "bg", hls.bg }, ["bg"] = { "bg", hls.bg }, ["bg+"] = { "bg", hls.sel }, ["fg+"] = { "fg", hls.sel }, -- ["fg+"] = { "fg", "", "reverse:-1" }, }, + defaults = { + git_icons = false, + file_icons = false, + }, } diff --git a/lua/fzf-lua/profiles/fzf-vim.lua b/lua/fzf-lua/profiles/fzf-vim.lua index 3aea3118..673e25af 100644 --- a/lua/fzf-lua/profiles/fzf-vim.lua +++ b/lua/fzf-lua/profiles/fzf-vim.lua @@ -152,6 +152,4 @@ return { git_icons = false, exec_empty_query = true, }, - -- global_git_icons = false, - -- global_file_icons = false, } diff --git a/lua/fzf-lua/profiles/max-perf.lua b/lua/fzf-lua/profiles/max-perf.lua index 65167ccb..d6a756dd 100644 --- a/lua/fzf-lua/profiles/max-perf.lua +++ b/lua/fzf-lua/profiles/max-perf.lua @@ -6,6 +6,8 @@ return { tags = { previewer = "bat" }, btags = { previewer = "bat" }, files = { fzf_opts = { ["--ansi"] = false } }, - global_git_icons = false, - global_file_icons = false, + defaults = { + git_icons = false, + file_icons = false, + }, } diff --git a/lua/fzf-lua/profiles/telescope.lua b/lua/fzf-lua/profiles/telescope.lua index 9e1f92da..478abf5c 100644 --- a/lua/fzf-lua/profiles/telescope.lua +++ b/lua/fzf-lua/profiles/telescope.lua @@ -6,9 +6,9 @@ local function hl_validate(hl) end return { - desc = "match telescope default highlights|keybinds", - fzf_opts = { ["--layout"] = "default", ["--marker"] = "+" }, - winopts = { + desc = "match telescope default highlights|keybinds", + fzf_opts = { ["--layout"] = "default", ["--marker"] = "+" }, + winopts = { width = 0.8, height = 0.9, preview = { @@ -19,7 +19,7 @@ return { flip_columns = 120, }, }, - hls = { + hls = { normal = hl_validate "TelescopeNormal", border = hl_validate "TelescopeBorder", title = hl_validate "TelescopeTitle", @@ -34,7 +34,7 @@ return { cursorlinenr = hl_validate "TelescopePreviewLine", search = hl_validate "IncSearch", }, - fzf_colors = { + fzf_colors = { ["fg"] = { "fg", "TelescopeNormal" }, ["bg"] = { "bg", "TelescopeNormal" }, ["hl"] = { "fg", "TelescopeMatching" }, @@ -49,7 +49,7 @@ return { ["marker"] = { "fg", "TelescopeSelectionCaret" }, ["header"] = { "fg", "TelescopeTitle" }, }, - keymap = { + keymap = { builtin = { [""] = "toggle-help", [""] = "toggle-fullscreen", @@ -77,7 +77,7 @@ return { ["ctrl-q"] = "select-all+accept", }, }, - actions = { + actions = { files = { ["default"] = actions.file_edit_or_qf, ["ctrl-x"] = actions.file_split, @@ -93,9 +93,9 @@ return { ["ctrl-t"] = actions.buf_tabedit, } }, - buffers = { + buffers = { keymap = { builtin = { [""] = false } }, actions = { ["ctrl-x"] = false, ["ctrl-d"] = { actions.buf_del, actions.resume } }, }, - global_git_icons = false, + defaults = { git_icons = false }, } diff --git a/scripts/init.lua b/scripts/init.lua index 5a685c65..5214b95f 100644 --- a/scripts/init.lua +++ b/scripts/init.lua @@ -5,7 +5,7 @@ vim.cmd("set packpath=" .. packpath) vim.o.termguicolors = true -require "fzf-lua".setup { global_git_icons = false } +require "fzf-lua".setup { defaults = { git_icons = false } } vim.api.nvim_set_keymap("n", "", [[lua require"fzf-lua".buffers()]], {}) vim.api.nvim_set_keymap("n", "", [[lua require"fzf-lua".builtin()]], {})