trim first, then carpet.ues scrap baseboard as a spacer under the trim and then the carpet installer will lay down the tack strips -pading and then carpeting and tuck it under the baseboard