feat: allow not changing the cwd when changing directories (#1019)
This commit is contained in:
parent
3486c48225
commit
0fcd6614b5
@ -166,6 +166,7 @@ require'nvim-tree'.setup {
|
|||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
change_dir = {
|
change_dir = {
|
||||||
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
},
|
},
|
||||||
open_file = {
|
open_file = {
|
||||||
|
|||||||
@ -132,6 +132,7 @@ function.
|
|||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
change_dir = {
|
change_dir = {
|
||||||
|
enable = true,
|
||||||
global = false,
|
global = false,
|
||||||
},
|
},
|
||||||
open_file = {
|
open_file = {
|
||||||
@ -397,6 +398,11 @@ Here is a list of the options available in the setup call:
|
|||||||
*nvim-tree.actions*
|
*nvim-tree.actions*
|
||||||
|actions|: configuration for various actions
|
|actions|: configuration for various actions
|
||||||
|
|
||||||
|
- |actions.change_dir.enable|: change the working directory when changing
|
||||||
|
directories in the tree.
|
||||||
|
type: `boolean`
|
||||||
|
default: `true`
|
||||||
|
|
||||||
- |actions.change_dir.global|: use `:cd` instead of `:lcd` when changing
|
- |actions.change_dir.global|: use `:cd` instead of `:lcd` when changing
|
||||||
directories. Consider that this might cause issues with
|
directories. Consider that this might cause issues with
|
||||||
the |update_cwd| options.
|
the |update_cwd| options.
|
||||||
|
|||||||
@ -358,6 +358,7 @@ local DEFAULT_OPTS = {
|
|||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
change_dir = {
|
change_dir = {
|
||||||
|
enable = true,
|
||||||
global = vim.g.nvim_tree_change_dir_global == 1,
|
global = vim.g.nvim_tree_change_dir_global == 1,
|
||||||
},
|
},
|
||||||
open_file = {
|
open_file = {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ local M = {
|
|||||||
current_tab = a.nvim_get_current_tabpage(),
|
current_tab = a.nvim_get_current_tabpage(),
|
||||||
options = {
|
options = {
|
||||||
global = false,
|
global = false,
|
||||||
|
change_cwd = true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ function M.fn(name, with_open)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.force_dirchange(foldername, with_open)
|
function M.force_dirchange(foldername, with_open)
|
||||||
if vim.tbl_isempty(vim.v.event) then
|
if M.options.change_cwd and vim.tbl_isempty(vim.v.event) then
|
||||||
if M.options.global then
|
if M.options.global then
|
||||||
vim.cmd('cd '..vim.fn.fnameescape(foldername))
|
vim.cmd('cd '..vim.fn.fnameescape(foldername))
|
||||||
else
|
else
|
||||||
@ -39,6 +40,7 @@ function M.force_dirchange(foldername, with_open)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(options)
|
function M.setup(options)
|
||||||
|
M.options.change_cwd = options.actions.change_dir.enable
|
||||||
M.options.global = options.actions.change_dir.global
|
M.options.global = options.actions.change_dir.global
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user