In a large saucepan or casserole dish, heat the olive oil over a medium heat. Add the onions and saute for 5 minutes.
Add the garlic to the pan and cook for 5 more minutes.
Stir in the thyme, oregano and sugar and cook for 2 more minutes.
Add the lentils, followed by the chopped tomatoes. Fill one of the empty cans with water and add that, too.
Leave to simmer for 25 minutes. Then stir in the salt and pepper.
For the vegetables: 15 minutes before the sauce has finished simmering, heat the oil for the vegetables in a large frying over a medium-high heat. Fry the courgettes and mushrooms for 10-12 minutes. The pan will be a little crowded but the mushrooms will cook down. The courgettes shouldn't be crunchy and raw, but not mushy either.
For the pasta:
While the sauce and vegetables are cooking, bring 2 litres (8 cups) of water to a boil in a large pot. Dissolve 1½ tsp fine salt in the water. Now add the pasta, bring back to a boil, then down to a simmer, and cook for 1 minute less than the packet says for al dente. Reserve 1 ladleful of pasta water then drain.
When everything has finished cooking, stir the vegetables and pasta into the sauce. If the sauce is looking a little dry, add some of the pasta water to loosen.
Sprinkle over the basil leaves then serve into wide bowls with an extra grind of black pepper.