Skip to content

Commit 69c55bf

Browse files
committed
feat(zoxide): cd action scope (closes #2338)
1 parent e9d1683 commit 69c55bf

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,8 @@ previewers = {
13481348
},
13491349
zoxide = {
13501350
cmd = "zoxide query --list --score",
1351-
git_root = false, -- auto-detect git root
1351+
scope = "global", -- cd action scope "local|win|tab"
1352+
git_root = false, -- auto-detect git root
13521353
formatter = "path.dirname_first",
13531354
fzf_opts = {
13541355
["--no-multi"] = true,

lua/fzf-lua/actions.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,9 @@ M.cd = function(selected, opts)
11761176
local git_root = opts.git_root and path.git_root({ cwd = cwd }, true) or nil
11771177
cwd = git_root or cwd
11781178
if uv.fs_stat(cwd) then
1179-
vim.cmd("cd " .. cwd)
1179+
local cmd = (opts.scope == "local" or opts.scope == "win") and "lcd"
1180+
or opts.scope == "tab" and "tcd" or "cd"
1181+
vim.cmd(cmd .. " " .. cwd)
11801182
utils.io_system({ "zoxide", "add", "--", cwd })
11811183
utils.info(("cwd set to %s'%s'"):format(git_root and "git root " or "", cwd))
11821184
else

lua/fzf-lua/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@ M.defaults.zoxide = {
13801380
fn_transform = [[return require("fzf-lua.make_entry").zoxide]],
13811381
fn_preprocess = [[return require("fzf-lua.make_entry").preprocess]],
13821382
cmd = "zoxide query --list --score",
1383+
scope = "global",
13831384
git_root = false,
13841385
formatter = "path.dirname_first",
13851386
fzf_opts = {

0 commit comments

Comments
 (0)