There are two main options: minimally invasive surgery and thoracotomy.
For minimally invasive surgery, doctors will use either video-assisted thoracoscopic surgery (VATS) or robotic-assisted thoracic surgery (RATS, or robotic VATS).
During VATS the doctor makes small cuts in your chest. Then the doctor guides a small video camera through a cut between your ribs and to your lungs. It allows the doctor to see inside your chest without having to make a big cut. Then the doctor cuts away the segment of your lungs that’s causing problems.
During RATS the doctor uses robotic instruments and a 3D camera. This allows the doctor to make very small, precise cuts.
If minimally invasive surgery isn’t possible, the doctor will do a thoracotomy. This is open lung surgery. That means the doctor will make a single large cut between your ribs to open up your chest. Then they'll remove the lung segment.