local function custom_mapping(bufnr)
  local api = require("nvim-tree.api")

  local function opts(desc)
    return {
      desc = "nvim-tree: " .. desc,
      buffer = bufnr,
      noremap = true,
      silent = true,
      nowait = true
    }
  end

  -- default mappings
  api.config.mappings.default_on_attach(bufnr)

  -- custom mappings
  vim.keymap.set('n', 's', api.node.open.vertical, opts('Open: Vertical Split'))
  vim.keymap.set('n', 'u', api.node.navigate.parent_close, opts('Close Directory'))
end

require("nvim-tree").setup({
  view = {
    width = {},
  },
  on_attach = custom_mapping,
})

-- Tree
vim.keymap.set("n", [[<C-\>]], ":NvimTreeToggle<CR>")
vim.keymap.set("n", [[<leader>\]], ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>ff", ":NvimTreeFindFile<CR>")

