Add a config option to use :cd instead of :lcd (#874)

Fixes #829
This commit is contained in:
Sander van Harmelen 2022-01-21 12:29:30 +01:00 committed by GitHub
parent 14461373e0
commit 1ac3502290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -110,6 +110,7 @@ let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree
let g:nvim_tree_change_dir_global = 1 "0 by default, use :cd when changing directories.
let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker. let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker.
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font. let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target. let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target.

View File

@ -277,7 +277,7 @@ Here is a list of the options available in the setup call:
*nvim-tree.view* *nvim-tree.view*
- |view|: window / buffer setup - |view|: window / buffer setup
- |view.hide_root_folder|: hide the path of the current working - |view.hide_root_folder|: hide the path of the current working
directory on top of the tree directory on top of the tree
type: `boolean` type: `boolean`
default: `false` default: `false`
@ -485,6 +485,9 @@ default table is
["readme.md"] = true, ["readme.md"] = true,
} }
|g:nvim_tree_change_dir_global| *g:nvim_tree_change_dir_global*
Can be 0 or 1. When 1, use :cd instead of :lcd when changing directories.
|g:nvim_tree_disable_window_picker| *g:nvim_tree_disable_window_picker* |g:nvim_tree_disable_window_picker| *g:nvim_tree_disable_window_picker*

View File

@ -274,7 +274,11 @@ function M.change_dir(name)
end end
current_tab = new_tab current_tab = new_tab
vim.cmd('lcd '..vim.fn.fnameescape(foldername)) if vim.g.nvim_tree_change_dir_global == 1 then
vim.cmd('cd '..vim.fn.fnameescape(foldername))
else
vim.cmd('lcd '..vim.fn.fnameescape(foldername))
end
M.init(false, foldername) M.init(false, foldername)
end end