-- ~/.config/nvim/lua/plugins/nvim-ufo.lua
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",
    },
  },
  config = function()
    require("ufo").setup({
      provider_selector = function(_, filetype)
        -- File-types that constantly throw UfoFallbackException → skip TS
        local noisy = { "html", "css", "json", "yaml", "txt", "md" }
        if vim.tbl_contains(noisy, filetype) then
          return { "lsp", "indent" } -- 2 providers max → no warning
        end
      end,
    })
  end,
}
