IANA-immunologist, but it stands to reason (to me) that vaccine, then natural infection, is probably the optimal in terms of developing a strong and long lasting immune response.
The vaccines are generally relying on injecting or manufacturing inside the body, the covid spike protein, and relaying on the body recognising this as foreign and responding. This generates very high levels of antibodies, but to only this spike protein. Which is a very good target protein for covid, obviously, but any protein can be altered when the virus mutates.
Natural immunity works differently, in that cells in the body (forgive the paraphrasing, any reading experts) special cells will essentially encounter covid, rip it up into little pieces, then wander about until other cells encounter a bit of the ripped-up virus that they know they can attach to / attack.
So what you get with natural immunity is an immune response that could be called "broader", i.e. not targeted squarely at the single spike protein.
So, for my money, the best someone can do is get vaccinated, then get a mild case of covid (thanks to the vaccine).
Thus ends my naive immunological mental model of how this all works.