1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:10:04 +08:00

perf(neo-tree): add force_change_cwd opt

This commit is contained in:
wsdjeg 2023-06-15 13:03:33 +08:00
parent a7194fbafa
commit 0166de7597
3 changed files with 28 additions and 15 deletions

View File

@ -191,6 +191,11 @@ 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)
local nt = require("neo-tree")
if nt.config.force_change_cwd then
args.dir = cwd
do_show_or_focus(args, state, true)
else
inputs.confirm("File not in cwd. Change cwd to " .. cwd .. "?", function(response)
if response == true then
args.dir = cwd
@ -199,6 +204,7 @@ handle_reveal = function(args, state)
end
do_show_or_focus(args, state, true)
end)
end
return
else
do_show_or_focus(args, state, true)

View File

@ -542,6 +542,11 @@ M.reveal_current_file = function(source_name, callback, force_cwd)
end
elseif not utils.is_subpath(cwd, path) then
cwd, _ = utils.split_path(path)
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
@ -550,6 +555,7 @@ M.reveal_current_file = function(source_name, callback, force_cwd)
M.focus(source_name, nil, callback)
end
end)
end
return
end
if path then

View File

@ -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