Your shifter needs to match the number of gears in your cassette. A 9 or 10 speed shifter pulls a different amount of cable than a 7 speed and won't line up your rear derailleur. You could try it, but would most likely find that it feels like the chain is always needing to finish a shift-like it's stuck between gears.
The rear derailleur doesn't matter. It moves whatever amount the shifter tells it to.