nvim-tree
will open in the root directory, but not the current directory.
#3108
Answered
by
alex-courtis
FlawlessCasual17
asked this question in
Q&A
-
Is there something wrong with my key binds. Why won't -- current directory
local cwd = vim.uv.cwd()
-- root directory
local root = LazyVim.root()
local ntree_api = require('nvim-tree.api').tree
local function open_at_root() ntree_api.toggle({ path = root }) end
local function open_at_cwd() ntree_api.toggle({ path = cwd }) end
vim.keymap.set('n', '<leader>e', open_at_root, opts('Explorer nvim-tree (root)'))
vim.keymap.set('n', '<leader>E', open_at_cwd, opts('Explorer nvim-tree (cwd)')) |
Beta Was this translation helpful? Give feedback.
Answered by
alex-courtis
Apr 19, 2025
Replies: 1 comment 1 reply
-
It looks like Changing to this worked: local function open_at_cwd() ntree_api.toggle({ path = vim.uv.cwd() }) end |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
FlawlessCasual17
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like
cwd
is set only once, at startup.Changing to this worked: