There are at least three things that affects Li-Ion battery's lifetime: time, heat and charge level. Time will inevitably move forward, so there's nothing you can do about that. The higher the temperature of the battery is the faster it will degrade. Too low and too high charge level also causes degradation.
Heat is problematic in the sense that if you use the device, it will heat up and cause the battery to also heat up. You can reduce this by making sure there are no pointless applications using CPU or GPU. You might also want to lift the laptop off the table so that air can more easily circulate around it.
If you use the laptop plugged in all the time the battery's charge level will be around 100% all the time. It's impossible to say what is too low and too high, but if you want to be safe you might want to avoid less than 20% and no higher than 80%. Too high charge level with elevated temperature is double bad for the battery. There are applications that can limit the max charge to something lower,
AlDente being one such app. It has a nice menubar item that allows you to easily change the max charge if you for example want to top the battery to 100%.