You'll need to set exposure control to manual. Toggle thru shutter speeds to the slowest. B (bulb) should be last. Depending on how dark the sky is and how bright the lightning flashes are, I'd start at f5.6 & f8. Open the shutter & hold open til a strike. Close it & check. Adjust the f stop to get the right balance. You may also need to play with ISO. Keep that as low as possible to avoid too bright a sky & reduce noise. The lightning will give enough light to add detail to the clouds & ground in many cases. Its pretty much trial & error, but this should give you a starting place. Good luck.
BTW, too wide an aperture will leave the lightning bolts looking soft & out of focus. And focus at infinity.