Skip to content

Commit

Permalink
Merge pull request #17 from mawkler/tcd
Browse files Browse the repository at this point in the history
Add `<C-t>` mapping that does `:tcd` instead of `:cd`
  • Loading branch information
jvgrootveld authored Feb 8, 2023
2 parents 856af0d + 4fd4ae2 commit 6896634
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require('telescope').setup{
["<C-s>"] = {
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
Expand Down Expand Up @@ -109,7 +109,7 @@ t.setup({
["<C-s>"] = {
before_action = function(selection) print("before C-s") end,
action = function(selection)
vim.cmd("edit " .. selection.path)
vim.cmd.edit(selection.path)
end
},
["<C-q>"] = { action = z_utils.create_basic_command("split") },
Expand All @@ -136,7 +136,7 @@ vim.keymap.set("n", "<leader>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)
Expand All @@ -156,7 +156,12 @@ vim.keymap.set("n", "<leader>cd", t.extensions.zoxide.list)
action = function(selection)
builtin.find_files({ cwd = selection.path })
end
}
},
["<C-t>"] = {
action = function(selection)
vim.cmd.tcd(selection.path)
end
},
}
}
```
Expand All @@ -166,6 +171,7 @@ vim.keymap.set("n", "<leader>cd", t.extensions.zoxide.list)
| Action | Description | Command executed |
| ------- | ---------------------------------------------------- | ------------------------------------------------ |
| `<CR>` | Change current directory to selection | `cd <path>` |
| `<C-t>` | Change current tab's directory to selection | `tcd <path>` |
| `<C-s>` | Open selection in a split | `split <path>` |
| `<C-v>` | Open selection in a vertical split | `vsplit <path>` |
| `<C-e>` | Open selection in current window | `edit <path>` |
Expand Down
9 changes: 7 additions & 2 deletions lua/telescope/_extensions/zoxide/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,7 +32,12 @@ local default_config = {
action = function(selection)
builtin.find_files({ cwd = selection.path })
end
}
},
["<C-t>"] = {
action = function(selection)
vim.cmd.tcd(selection.path)
end
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/zoxide/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6896634

Please sign in to comment.