refactor: revert set_last_win_as_target default and move autocmd
- Changed the default value of `set_last_win_as_target` back to `false` to maintain original behavior. - Moved the autocmd for `set_last_win_as_target` to `open-file.lua` for better organization.
This commit is contained in:
parent
d8716196f0
commit
e5553859cd
@ -570,7 +570,7 @@ Following is the default configuration. See |nvim-tree-opts| for details. >lua
|
|||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
use_system_clipboard = true,
|
use_system_clipboard = true,
|
||||||
set_last_win_as_target = true,
|
set_last_win_as_target = false,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
enable = true,
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
@ -1441,7 +1441,7 @@ the target window for `nvim-tree`. When enabled, the last active window will be
|
|||||||
set as the target for file actions (like opening files), ensuring better window
|
set as the target for file actions (like opening files), ensuring better window
|
||||||
management. When disabled, the default behavior applies.
|
management. When disabled, the default behavior applies.
|
||||||
|
|
||||||
Type: `boolean`, Default: `true`
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
*nvim-tree.actions.change_dir*
|
*nvim-tree.actions.change_dir*
|
||||||
vim |current-directory| behaviour.
|
vim |current-directory| behaviour.
|
||||||
|
|||||||
@ -232,17 +232,6 @@ local function setup_autocommands(opts)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.actions.set_last_win_as_target then
|
|
||||||
create_nvim_tree_autocmd("BufLeave", {
|
|
||||||
callback = function()
|
|
||||||
local buf_name = vim.api.nvim_buf_get_name(0)
|
|
||||||
if not string.find(buf_name, "NvimTree_") then
|
|
||||||
require("nvim-tree.lib").set_target_win()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||||
@ -440,7 +429,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
use_system_clipboard = true,
|
use_system_clipboard = true,
|
||||||
set_last_win_as_target = true,
|
set_last_win_as_target = false,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
enable = true,
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
|
|||||||
@ -426,6 +426,15 @@ function M.setup(opts)
|
|||||||
opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper()
|
opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper()
|
||||||
end
|
end
|
||||||
M.window_picker = opts.actions.open_file.window_picker
|
M.window_picker = opts.actions.open_file.window_picker
|
||||||
|
if opts.actions.set_last_win_as_target then
|
||||||
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
|
callback = function()
|
||||||
|
if utils.is_nvim_tree_buf then
|
||||||
|
lib.set_target_win()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user