diff --git a/bundle/neo-tree.nvim/lua/neo-tree/command/init.lua b/bundle/neo-tree.nvim/lua/neo-tree/command/init.lua index 4d6747c8d..abb721e5e 100644 --- a/bundle/neo-tree.nvim/lua/neo-tree/command/init.lua +++ b/bundle/neo-tree.nvim/lua/neo-tree/command/init.lua @@ -191,14 +191,20 @@ handle_reveal = function(args, state) elseif not utils.is_subpath(cwd, path) then -- force was not specified, so we need to ask the user cwd, _ = utils.split_path(path) - inputs.confirm("File not in cwd. Change cwd to " .. cwd .. "?", function(response) - if response == true then - args.dir = cwd - else - args.reveal_file = nil - end + local nt = require("neo-tree") + if nt.config.force_change_cwd then + args.dir = cwd do_show_or_focus(args, state, true) - end) + else + inputs.confirm("File not in cwd. Change cwd to " .. cwd .. "?", function(response) + if response == true then + args.dir = cwd + else + args.reveal_file = nil + end + do_show_or_focus(args, state, true) + end) + end return else do_show_or_focus(args, state, true) diff --git a/bundle/neo-tree.nvim/lua/neo-tree/sources/manager.lua b/bundle/neo-tree.nvim/lua/neo-tree/sources/manager.lua index 8a277a2e2..c9118ea16 100644 --- a/bundle/neo-tree.nvim/lua/neo-tree/sources/manager.lua +++ b/bundle/neo-tree.nvim/lua/neo-tree/sources/manager.lua @@ -542,14 +542,20 @@ M.reveal_current_file = function(source_name, callback, force_cwd) end elseif not utils.is_subpath(cwd, path) then cwd, _ = utils.split_path(path) - inputs.confirm("File not in cwd. Change cwd to " .. cwd .. "?", function(response) - if response == true then - state.path = cwd - M.focus(source_name, path, callback) - else - M.focus(source_name, nil, callback) - end - end) + local nt = require("neo-tree") + if nt.config.force_change_cwd then + state.path = cwd + M.focus(source_name, path, callback) + else + inputs.confirm("File not in cwd. Change cwd to " .. cwd .. "?", function(response) + if response == true then + state.path = cwd + M.focus(source_name, path, callback) + else + M.focus(source_name, nil, callback) + end + end) + end return end if path then diff --git a/lua/config/neo-tree.lua b/lua/config/neo-tree.lua index 126a902d1..ca808fd16 100644 --- a/lua/config/neo-tree.lua +++ b/lua/config/neo-tree.lua @@ -3,6 +3,7 @@ require('neo-tree').setup({ close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab popup_border_style = 'rounded', enable_git_status = true, + force_change_cwd = true, -- force change cmd when switch project enable_diagnostics = true, open_files_do_not_replace_types = { 'terminal', 'trouble', 'qf' }, -- when opening files, do not use windows containing these filetypes or buftypes sort_case_insensitive = false, -- used when sorting files and directories in the tree