diff --git a/README.md b/README.md index b8b2d65..4df7f3d 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ require('telescope').setup{ [""] = { before_action = function(selection) print("before C-s") end, action = function(selection) - vim.cmd("edit " .. selection.path) + vim.cmd.edit(selection.path) end }, -- Opens the selected entry in a new split @@ -109,7 +109,7 @@ t.setup({ [""] = { before_action = function(selection) print("before C-s") end, action = function(selection) - vim.cmd("edit " .. selection.path) + vim.cmd.edit(selection.path) end }, [""] = { action = z_utils.create_basic_command("split") }, @@ -136,7 +136,7 @@ vim.keymap.set("n", "cd", t.extensions.zoxide.list) mappings = { default = { action = function(selection) - vim.cmd("cd " .. selection.path) + vim.cmd.edit(selection.path) end, after_action = function(selection) print("Directory changed to " .. selection.path) @@ -156,7 +156,12 @@ vim.keymap.set("n", "cd", t.extensions.zoxide.list) action = function(selection) builtin.find_files({ cwd = selection.path }) end - } + }, + [""] = { + action = function(selection) + vim.cmd.tcd(selection.path) + end + }, } } ``` @@ -166,6 +171,7 @@ vim.keymap.set("n", "cd", t.extensions.zoxide.list) | Action | Description | Command executed | | ------- | ---------------------------------------------------- | ------------------------------------------------ | | `` | Change current directory to selection | `cd ` | +| `` | Change current tab's directory to selection | `tcd ` | | `` | Open selection in a split | `split ` | | `` | Open selection in a vertical split | `vsplit ` | | `` | Open selection in current window | `edit ` | diff --git a/lua/telescope/_extensions/zoxide/config.lua b/lua/telescope/_extensions/zoxide/config.lua index 1406c97..ab54410 100644 --- a/lua/telescope/_extensions/zoxide/config.lua +++ b/lua/telescope/_extensions/zoxide/config.lua @@ -12,7 +12,7 @@ local default_config = { mappings = { default = { action = function(selection) - vim.cmd("cd " .. selection.path) + vim.cmd.cd(selection.path) end, after_action = function(selection) print("Directory changed to " .. selection.path) @@ -32,7 +32,12 @@ local default_config = { action = function(selection) builtin.find_files({ cwd = selection.path }) end - } + }, + [""] = { + action = function(selection) + vim.cmd.tcd(selection.path) + end + }, } } diff --git a/lua/telescope/_extensions/zoxide/utils.lua b/lua/telescope/_extensions/zoxide/utils.lua index aa0224f..3a24a9e 100644 --- a/lua/telescope/_extensions/zoxide/utils.lua +++ b/lua/telescope/_extensions/zoxide/utils.lua @@ -2,7 +2,7 @@ local utils = {} utils.create_basic_command = function(command) return function(selection) - vim.cmd(command .. " " .. selection.path) + vim.cmd[command](selection.path) end end