Compare commits
2 Commits
01229cc7b0
...
c42f1f0370
Author | SHA1 | Date | |
---|---|---|---|
c42f1f0370 | |||
b8e5ff313f |
@ -7,6 +7,15 @@ 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)
|
||||||
@ -15,7 +24,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 vim.cmd.tc
|
local action = opts.action or M.tcd
|
||||||
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();
|
||||||
@ -32,13 +41,4 @@ 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
|
||||||
|
@ -42,7 +42,8 @@ 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()
|
||||||
require('lupan.cd').tab_change_dir_newtab()
|
local cd = require('lupan.cd')
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user