Compare commits

..

2 Commits

2 changed files with 11 additions and 12 deletions

View File

@ -7,15 +7,6 @@ local themes = require "telescope.themes"
local M = {} local M = {}
function M.tcd(dir)
vim.cmd('tcd ' .. dir)
end
function M.tabnew_tcd(dir)
vim.cmd('tabnew ' .. dir)
vim.cmd('tcd ' .. dir)
end
local function enter(prompt_bufnr, action) local function enter(prompt_bufnr, action)
local selected = action_state.get_selected_entry() local selected = action_state.get_selected_entry()
actions.close(prompt_bufnr) actions.close(prompt_bufnr)
@ -24,7 +15,7 @@ end
function M.tab_change_dir(opts) function M.tab_change_dir(opts)
opts = opts or {} opts = opts or {}
local action = opts.action or M.tcd local action = opts.action or vim.cmd.tc
local prompt_title = opts.prompt_title or "Tab change directory" local prompt_title = opts.prompt_title or "Tab change directory"
local cmd = { 'find', os.getenv('HOME'), '-maxdepth', '5', '-type', 'd', '-not', '-path', '*/.git*' } local cmd = { 'find', os.getenv('HOME'), '-maxdepth', '5', '-type', 'd', '-not', '-path', '*/.git*' }
local dropdown = themes.get_dropdown(); local dropdown = themes.get_dropdown();
@ -41,4 +32,13 @@ function M.tab_change_dir(opts)
change_dir:find() change_dir:find()
end end
local function tabnew_tcd(dir)
vim.cmd.tabnew(dir)
vim.cmd.tc(dir)
end
function M.tab_change_dir_newtab()
M.tab_change_dir({ action = tabnew_tcd, prompt_title = "Tab change directory (new tab)" })
end
return M return M

View File

@ -42,8 +42,7 @@ key('n', '<leader>td', function()
end, { desc = '[T]ab change [d]irectory' }) end, { desc = '[T]ab change [d]irectory' })
key('n', '<leader>tD', function() key('n', '<leader>tD', function()
local cd = require('lupan.cd') require('lupan.cd').tab_change_dir_newtab()
cd.tab_change_dir({ action = cd.tabnew_tcd, prompt_title = "Tab change directory (new tab)" })
end, { desc = '[T]ab change [D]irectory (new tab)' }) end, { desc = '[T]ab change [D]irectory (new tab)' })
-- Diagnostic keymaps -- Diagnostic keymaps