Place racks in upper and lower thirds of oven; preheat to 400° Bake setting. (Lower rack to bake the gratin and the upper rack for broiling the gratin topping at the end.)
Spray or oil a 13'x9" baking dish and arrange squash.
Heat 2 tablespoons oil in a large pan over medium heat. Add onion, garlic, and ½ teaspoon salt and cook until onion is softened and starting to turn golden brown, 8–10 minutes. Stir in red pepper flakes and thyme followed by fresh or frozen spinach/kale, and cook, stirring until greens are wilted, approx. 1 minute. Using tongs, scatter onion mixture over squash. No need to clean pan.
In the same pan, combine cream, approx. three-quarters of Parmesan, and 1½ teaspoons kosher salt in pan and cook, stirring occasionally, until hot but not simmering over medium-low heat, about 3 minutes. Carefully pour over squash, using tongs to coat evenly and get onion mixture into all the crevices.
Cover tightly with foil, transfer to lower rack of oven, and bake until squash is just shy of tender, 25–30 minutes. Then remove foil and continue to cook until cream is thickened and no longer liquidy and squash is very tender, 18-20 minutes. Total bake time is 43-50 minutes depending on the thickness of the squash slices.
While squash is baking, rough chop the nuts.
Heat broiler. Scatter nuts and remaining Parmesan over gratin and drizzle lightly with some olive oil. Transfer gratin to top rack and broil until bubbling and browned at the edges, about 3 minutes. Set a timer to avoid burning!
Serve hot right from the baking dish!