In your situation you will need to prime the walls and ceilings first. Then work on the woodwork. The main reason for this is caulking the gaps of the woodwork to the adjacent surfaces. Tooling caulking and its adhesion is much better over a good primer.
Once the plaster is primed you can prime the trim with a good undercoater, fill nail holes, sand smooth, vacuum to remove the dust and finally caulk it in. Now you can paint. This is how I like to do it. I then mask off the trim, solid if spraying, then paint the ceilings and walls.
The nice thing about painting the woodwork first is you don't have to be super careful with the walls. A nice straight line will come from the masking.