This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
neovim/plugins/explorer/nvim-tree.lua

27 lines
755 B
Lua
Raw Permalink Normal View History

-- See: https://github.com/kyazdani42/nvim-tree.lua/blob/master/doc/nvim-tree-lua.txt
2022-11-19 00:56:53 +03:00
require("nvim-tree").setup(@nvimTreeLuaSettings@)
vim.keymap.set("n", "<leader>nt", "<Cmd>NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", "<Cmd>NvimTreeFindFile<CR>")
2023-02-03 02:22:57 +03:00
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 })