@@ -8,7 +8,8 @@ local nvim_tree_callback = require'nvim-tree.config'.nvim_tree_callback
|
||||
local M = {
|
||||
mappings = {
|
||||
{ key = {"<CR>", "o", "<2-LeftMouse>"}, action = "edit" },
|
||||
{ key = {"O"}, action = "edit_no_picker" },
|
||||
{ key = "<C-e>", action = "edit_in_place" },
|
||||
{ key = "O", action = "edit_no_picker" },
|
||||
{ key = {"<2-RightMouse>", "<C-]>"}, action = "cd" },
|
||||
{ key = "<C-v>", action = "vsplit" },
|
||||
{ key = "<C-x>", action = "split"},
|
||||
@@ -96,9 +97,10 @@ function M.on_keypress(action)
|
||||
end
|
||||
elseif node.name == ".." then
|
||||
return require'nvim-tree.actions.change-dir'.fn("..")
|
||||
elseif action == "cd" and node.nodes ~= nil then
|
||||
return require'nvim-tree.actions.change-dir'.fn(lib.get_last_group_node(node).absolute_path)
|
||||
elseif action == "cd" then
|
||||
if node.nodes ~= nil then
|
||||
require'nvim-tree.actions.change-dir'.fn(lib.get_last_group_node(node).absolute_path)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -154,6 +154,12 @@ function M.fn(mode, filename)
|
||||
return
|
||||
end
|
||||
|
||||
if mode == "edit_in_place" then
|
||||
vim.cmd("edit " .. vim.fn.fnameescape(filename))
|
||||
require"nvim-tree.view".abandon_current_window()
|
||||
return
|
||||
end
|
||||
|
||||
local tabpage = api.nvim_get_current_tabpage()
|
||||
local win_ids = api.nvim_tabpage_list_wins(tabpage)
|
||||
|
||||
|
||||
@@ -194,12 +194,20 @@ local function set_current_win()
|
||||
M.View.tabpages[current_tab] = { winnr = a.nvim_get_current_win() }
|
||||
end
|
||||
|
||||
function M.open_in_current_win()
|
||||
create_buffer(a.nvim_get_current_buf())
|
||||
function M.open_in_current_win(opts)
|
||||
opts = opts or { hijack_current_buf = true, resize = true }
|
||||
create_buffer(opts.hijack_current_buf and a.nvim_get_current_buf())
|
||||
set_current_win()
|
||||
set_window_options_and_buffer()
|
||||
M.reposition_window()
|
||||
M.resize()
|
||||
if opts.resize then
|
||||
M.reposition_window()
|
||||
M.resize()
|
||||
end
|
||||
end
|
||||
|
||||
function M.abandon_current_window()
|
||||
local tab = a.nvim_get_current_tabpage()
|
||||
M.View.tabpages[tab] = { winnr = nil }
|
||||
end
|
||||
|
||||
function M.is_visible(opts)
|
||||
|
||||
Reference in New Issue
Block a user