Heat the oil in a large pot over medium heat. When hot, add the carrots, celery, and onions and cook until softened, about 6 minutes. Add the walnuts and cook until toasty smelling, about 2 minutes, stirring constantly, then add the tomato paste, garlic, Italian seasoning, red pepper flakes, black pepper, and salt, and cook until fragrant, about 1 minute.
Add the wine, scraping up any browned bits on the bottom of the pot, and cook until slightly reduced, about 2 minutes.
Add the lentils, broth, tomatoes, and sugar. Stir well, then bring to a boil over high heat. Reduce the heat to medium-low and simmer, uncovered, stirring occasionally, until the sauce thickens and the lentils are soft, about 40 minutes. If the sauce is thickening too quickly, cover the pot.
Optional: For a smoother sauce, use an immersion blender to partially blend the sauce, leaving some chunks intact, or transfer 2 cups of the sauce to a blender, puree, and return to the pot.
Stir in the fresh basil and serve over cooked pasta with vegan parmesan.