26 lines
755 B
Lua
26 lines
755 B
Lua
-- See: https://github.com/kyazdani42/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt
|
|
require("nvim-tree").setup(@nvimTreeLuaSettings@)
|
|
|
|
vim.keymap.set("n", "<leader>nt", "<Cmd>NvimTreeToggle<CR>")
|
|
vim.keymap.set("n", "<leader>nf", "<Cmd>NvimTreeFindFile<CR>")
|
|
|
|
local function open_nvim_tree(data)
|
|
-- buffer is a [No Name]
|
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
|
-- buffer is a directory
|
|
local directory = vim.fn.isdirectory(data.file) == 1
|
|
|
|
if not no_name and not directory then
|
|
return
|
|
end
|
|
|
|
-- change to the directory
|
|
if directory then
|
|
vim.cmd.cd(data.file)
|
|
end
|
|
|
|
-- open the tree
|
|
require("nvim-tree.api").tree.open()
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|