Skip to content

Commit d41ca62

Browse files
committed
fix: hide the base dir update on bufenter behind an option
1 parent 5bca200 commit d41ca62

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last
3737
let g:nvim_tree_auto_ignore_ft = [ 'startify', 'dashboard' ] "empty by default, don't auto open tree on specific filetypes.
3838
let g:nvim_tree_quit_on_open = 1 "0 by default, closes the tree when you open a file
3939
let g:nvim_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer
40+
let g:nvim_tree_follow_update_path = 1 "0 by default, will update the path of the current dir if the file is not inside the tree.
41+
Default is 0
4042
let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
4143
let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
4244
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ Can be `0` or `1`. When `1`, will update the cursor to update to the correct
172172
location in the tree on |BufEnter|.
173173
Default is 0
174174

175+
|g:nvim_tree_follow_update_path| *g:nvim_tree_follow_update_path*
176+
177+
Can be `0` or `1`. When `1`, will update the path of the current dir if the
178+
file is not inside the tree. Works only with |g:nvim_tree_follow| = 1.
179+
Default is 0
180+
175181
|g:nvim_tree_auto_open| *g:nvim_tree_auto_open*
176182

177183
Can be `0` or `1`. When `1`, will open the tree when the package is loaded.

lua/nvim-tree.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ local function is_file_readable(fname)
223223
end
224224

225225
local function update_base_dir_with_filepath(filepath)
226+
if vim.g.nvim_tree_follow_update_path ~= 1 then
227+
return
228+
end
226229
if not vim.startswith(filepath, lib.Tree.cwd or vim.loop.cwd()) then
227230
lib.change_dir(vim.fn.fnamemodify(filepath, ':p:h'))
228231
end

0 commit comments

Comments
 (0)