Skip to content

[NvChad] How to make the passed-in folder argument as root, instead of the current directory where nvim is launched from? #2363

Answered by ugoa
ugoa asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you. I follow the link and it worked.

I am using NvChad and here is what config I added in case anyone is wondering.

In ~/.config/nvim/lua/custom/init.lua:

vim.api.nvim_create_autocmd("VimEnter", {
  callback = function(data)
    local directory = vim.fn.isdirectory(data.file) == 1

    if not directory then
      return
    end

    -- change to the directory
    vim.cmd.cd(data.file)

    -- open the tree
    require("nvim-tree.api").tree.open()
  end,
})

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ugoa
Comment options

Answer selected by ugoa
@alex-courtis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants