Well, yes.
Most plant mass comes from air and water, not the ground. Carbon, hydrogen, oxygen, and nitrogen all come from the atmosphere. This is why farms don't dig themselves into the ground. If air and water can be made from asteroids, that's most of the raw materials problem by quantity. Hydroponics already works.
Direct synthesis of food from hydrocarbons has never really caught on, although it's been done experimentally and is an area of active research.[1] DARPA has a project.[2] "To address vulnerabilities in food supply chains across a variety of operational and humanitarian scenarios, Cornucopia will demonstrate the capacity to produce all four human dietary macronutrients (protein, carbohydrate, fat, and dietary fiber) in ratios that target Military Dietary Reference Intake (MDRI) daily requirements for complete nutrition. Outputs will be in multiple food formats (e.g., shake, bar, gel, jerky) that meet military nutritional standards and palatability requirements in a system minimizing inputs, handling, and footprint."
[1] https://www.sciencedirect.com/science/article/abs/pii/S09242...