return {
  "kevinhwang91/nvim-ufo",
  dependencies = "kevinhwang91/promise-async",
  event = { "BufReadPost", "BufNewFile" },
  keys = {
    {
      "zR",
      function()
        require("ufo").openAllFolds()
      end,
      desc = "Ufo: open all folds",
    },
    {
      "zM",
      function()
        require("ufo").closeAllFolds()
      end,
      desc = "Ufo: close all folds",
    },
    {
      "zr",
      function()
        require("ufo").openFoldsExceptKinds()
      end,
      desc = "Ufo: open outer folds",
    },

    ------------------------------------------------------------------
    -- 1. Close everything *outside* the current fold hierarchy
    ------------------------------------------------------------------
    {
      "zX",
      function()
        require("ufo").closeAllFolds() -- close every fold
        vim.cmd("normal! l") -- ONE right press
        vim.cmd("normal! zo") -- open fold under cursor
        vim.cmd("normal! zz") -- keep it centred
      end,
      desc = "Close folds outside current (+1 right)",
    },
    ------------------------------------------------------------------
    -- 3. helpers you already had
    ------------------------------------------------------------------
    { "zt", "za", desc = "Toggle fold under cursor" },
  },

  config = function()
    require("ufo").setup({
      foldlevel = 99,
      foldlevelstart = 99,
      provider_selector = function(_, ft)
        -- Silence the fallback spam by skipping Treesitter for noisy types
        local noisy = { "html", "css", "json", "yaml", "txt", "markdown", "zsh" }
        if vim.tbl_contains(noisy, ft) then
          return { "lsp", "indent" } -- max 2 providers
        end
        return { "lsp" }
      end,
    })
  end,
}
