I am Peruvian but have a permanent residence in Mexico. I'm going to study abroad in Spain so I have a Type D visa. I want to visit the UK but don't know if i need to apply for the standard visa. Mexicans don't need the visa and I don't know if same thing applies to me if I have a permanent residency.
I am a Peruvian living in Mexico with Mexican Permanent Residency and I want to visit the UK - Mexican nationals do not need a visa, do I need a visa?
Yes, you do - you hold Mexican residency but only your nationality counts in this case, so you would apply to the UK for a Standard Visitor Visa (or whichever visa you need) under your Peruvian nationality.
Under UK requirements, you are still a Peruvian national, you just happen to be living in a different country.
While some countries accept permanent residence status as enough for you to apply under the requirements from those countries rather than your country of nationality, the UK does not - you are considered based on the nationality as depicted on your travel document.
If you had a Mexican travel document which stated your nationality as Mexican, then you could visit the UK under the visa rules for Mexicans.