diff --git a/lua/fzf-lua/core.lua b/lua/fzf-lua/core.lua index b302a10..ae49e6c 100644 --- a/lua/fzf-lua/core.lua +++ b/lua/fzf-lua/core.lua @@ -51,7 +51,7 @@ M.build_fzf_cli = function(opts) [[ %s --layout=%s --bind=%s --prompt=%s]] .. [[ --preview-window='%s%s' --preview=%s]] .. [[ --height=100%% --ansi]] .. - [[ %s %s %s %s]], + [[ %s %s %s %s %s]], opts.fzf_args or config.globals.fzf_args or '', opts.fzf_layout or config.globals.fzf_layout, utils._if(opts.fzf_binds, opts.fzf_binds, @@ -64,6 +64,7 @@ M.build_fzf_cli = function(opts) utils._if(opts.fzf_bin and opts.fzf_bin:find('sk')~=nil, "--inline-info", "--info=inline"), utils._if(actions.expect(opts.actions), actions.expect(opts.actions), ''), utils._if(opts.nomulti, '--no-multi', '--multi'), + utils._if(opts.fzf_cli_args, opts.fzf_cli_args, ''), utils._if(opts.cli_args, opts.cli_args, '') ) -- print(cli) diff --git a/lua/fzf-lua/init.lua b/lua/fzf-lua/init.lua index 331e7cc..6a3cf68 100644 --- a/lua/fzf-lua/init.lua +++ b/lua/fzf-lua/init.lua @@ -5,6 +5,7 @@ end local fzf = require "fzf" local config = require "fzf-lua.config" + local M = {} function M.setup(opts) @@ -13,6 +14,9 @@ function M.setup(opts) for k, _ in pairs(globals.winopts) do if opts[k] ~= nil then globals.winopts[k] = opts[k] end end + -- empty BAT_CONFIG_PATH so we don't conflict + -- with '$XDG_DATA_HOME/bat/config' + vim.env.BAT_CONFIG_PATH = '' -- override the bat preview theme if set by caller if globals.bat_theme and #globals.bat_theme > 0 then vim.env.BAT_THEME = globals.bat_theme diff --git a/lua/fzf-lua/providers/grep.lua b/lua/fzf-lua/providers/grep.lua index 55966b2..6e65861 100644 --- a/lua/fzf-lua/providers/grep.lua +++ b/lua/fzf-lua/providers/grep.lua @@ -168,6 +168,16 @@ M.live_grep = function(opts) opts.search = nil end +local function set_search_header(opts) + if not opts then opts = {} end + if opts.no_header then return opts end + if not opts.search_header then opts.search_header = "Seaching for:" end + opts.fzf_cli_args = opts.fzf_cli_args or '' + opts.fzf_cli_args = string.format([[%s --header="%s '%s'"]], + opts.fzf_cli_args, opts.search_header, opts.search) + return opts +end + M.grep_last = function(opts) if not opts then opts = {} end opts.continue_last_search = true @@ -177,18 +187,21 @@ end M.grep_cword = function(opts) if not opts then opts = {} end opts.search = vim.fn.expand("") + opts = set_search_header(opts) return M.grep(opts) end M.grep_cWORD = function(opts) if not opts then opts = {} end opts.search = vim.fn.expand("") + opts = set_search_header(opts) return M.grep(opts) end M.grep_visual = function(opts) if not opts then opts = {} end opts.search = utils.get_visual_selection() + opts = set_search_header(opts) return M.grep(opts) end