Skip to content

Commit

Permalink
feat(tmux): fzf v0.53 native tmux integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Aug 29, 2024
1 parent 9226c5a commit 715e721
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lua/fzf-lua/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,20 @@ function M.normalize_opts(opts, globals, __resume_key)
opts.multiline = nil
end

-- are we using fzf-tmux, if so get available columns
opts._is_fzf_tmux = vim.env.TMUX and opts.fzf_bin:match("fzf%-tmux$")
-- Are we using fzf-tmux? if so get available columns
opts._is_fzf_tmux = vim.env.TMUX
-- pre fzf v0.53 uses the fzf-tmux script
and opts.fzf_bin:match("fzf%-tmux$") and 1
-- fzf v0.53 added native tmux integration
or opts.__FZF_VERSION and opts.__FZF_VERSION >= 0.53 and opts.fzf_opts["--tmux"] and 2
if opts._is_fzf_tmux then
local out = utils.io_system({ "tmux", "display-message", "-p", "#{window_width}" })
opts._tmux_columns = tonumber(out:match("%d+"))
opts.winopts.split = nil
if opts._is_fzf_tmux == 2 then
-- native tmux integration is implemented using tmux popups
opts._is_fzf_tmux_popup = true
end
end

-- refresh highlights if background/colorscheme changed (#1092)
Expand Down
6 changes: 5 additions & 1 deletion lua/fzf-lua/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,17 @@ M.build_fzf_cli = function(opts)
-- build the cli args
local cli_args = {}
-- fzf-tmux args must be included first
if opts._is_fzf_tmux then
if opts._is_fzf_tmux == 1 then
for k, v in pairs(opts.fzf_tmux_opts or {}) do
table.insert(cli_args, k)
if type(v) == "string" and #v > 0 then
table.insert(cli_args, v)
end
end
elseif opts._is_fzf_tmux == 2 then
-- "--height" specified after "--tmux" will take priority and cause
-- the job to spawn in the background without a visible interface
opts.fzf_opts["--height"] = nil
end
for k, v in pairs(opts.fzf_opts) do
-- flag can be set to `false` to negate a default
Expand Down
2 changes: 1 addition & 1 deletion lua/fzf-lua/profiles/fzf-tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return {
desc = "fzf-native run inside a tmux popup",
fzf_bin = "fzf-tmux",
fzf_opts = { ["--border"] = "rounded" },
fzf_tmux_opts = { ["-p"] = "80%,90%" },
fzf_tmux_opts = { ["-p"] = "80%,60%" },
winopts = { preview = { default = "bat" } },
manpages = { previewer = "man_native" },
helptags = { previewer = "help_native" },
Expand Down

0 comments on commit 715e721

Please sign in to comment.