Annoyingly making .git as root always
niksingh710 opened this issue · comments
Description
if my dir strcuture is like this
now i opened this after changing my current dir to hypr expecting nvim tree going to take hypr as my root dir but it changes to the root of .git
it is annoying most of the times.
Neovim version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Operating system and version
Arch linux 6.7.4-zen1-1-zen
Windows variant
No response
nvim-tree version
821a7ac
Options
pickers = {
find_files = {
follow = true,
},
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
undo = {
mappings = {
n = {
-- IMPORTANT: Note that telescope-undo must be available when telescope is configured if
-- you want to replicate these defaults and use the following actions. This means
-- installing as a dependency of telescope in it's `requirements` and loading this
-- extension from there instead of having the separate plugin definition as outlined
-- above.
["y"] = require("telescope-undo.actions").yank_additions,
["Y"] = require("telescope-undo.actions").yank_deletions,
["<cr>"] = require("telescope-undo.actions").restore,
},
},
side_by_side = true,
layout_strategy = "vertical",
layout_config = {
preview_height = 0.8,
},
},
},
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
prompt_prefix = " ",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
mappings = {
n = {
q = action.close,
x = action.select_horizontal,
v = action.select_vertical,
},
},
},
Steps to reproduce
Go in sub dir of any git projects (for me the dotfiles dir having multiple sub dirs)
and open a file in that sub dir via nvim.
now nvimTree will make the .git
location of the parent or super parent as root dir.
Expected behavior
No response
Actual behavior
No response
That configuration snippet is not from nvim-tree and I'm not quite sure how I would reproduce this.
Please provide a "Clean Room" Replication as per the bug report instructions.
The above, along with steps to reproduce, will allow us to replicate.
It may be useful to provide the above demonstrated repo in which to reproduce, as it may have its own configuration, submodules etc. etc.
it was something that was highjacking it.
it was something that was highjacking it.
Great news!
Please tell us what was hijacking, to assist future users with similar issues.
the behaviour is
dir
├── .git
├── a
├── b
└── c
if this is the structure and a
is soft linked to my home path.
a i open neovim like nvim ~/a/somefile
the root of nvim-tree will be the dir
dir (because it contains .git
in it i guess)
expected behaviour is to keep a
as the path of the root.
as nvim-tree make .git
as root dir below is the workaround now m using.
["<leader><cr>"] = {
function()
local curdir = vim.fn.expand("%:p:h")
vim.api.nvim_set_current_dir(curdir)
end,
"Change dir",
},
That makes sense. nvim isn't changing its cwd when you open the file directly, rather than ~a
.
Glad you found a workaround!