I recently tried to program a raw ATmega328P chip with my Leonardo and met the good-old timeout error messages. After spending a day researching (and unsuccessful attempts) I decided to take the matter in my own hands and solve the issue on the newest release of Arduino IDE. I really wanted to share this with you guys, so if someone has this issue in the future, this is what worked for me.
Specs: Arduino Leonardo, Windows 10 1709, Arduino IDE 1.8.5 and the target chip is ATmega328P-PU.
Open the following file with and elevated WordPad (Notepad will not display the line breaks correctly):
C:\Program Files (x86)\Arduino\hardware\arduino\avr\programmers.txt
Go to the end of the file, add an empty line and then the below:
arduinoispleo.name=Arduino as ISP (Leonardo)
arduinoispleo.communication=serial
arduinoispleo.protocol=arduino
arduinoispleo.speed=19200
arduinoispleo.program.tool=avrdude
arduinoispleo.program.extra_params=-P{serial.port}
Save the file and theoretically when you re-start the Arduino IDE, you'll see a new programmer in the menu, named Arduino as ISP (Leonardo). Now select Arduino/Genuino UNO as board, select the port of your Arduino Leonardo and the new programmer we just created. If you wired everything up correctly, burning the bootloader or uploading sketches will now succeed! Just be careful, when you upload always hold SHIFT first, otherwise you will simply try overwrite the ArduinoISP sketch on your Leonardo