While the answers in this, as well the linked previous post concentrate on giving you advice on the technical side of your work, it seems to me that you problems don´t root in technical difficulties at all but are mainly of a social matter.
As @TolMera suggests in his answer to that other question you should first think hard if you want to solve this conflict or if you are better off working elsewhere.
If you decide you want to improve you work environment, let´s look at what we have.
- You want to keep up you good technical work and not be disturbed by the ability nor the attitude of you colleagues.
- Your colleague wants to secure his position and probably feels quite threatened by you. He also probably feels that something is taken away from him since he works there longer than you and feels some kind of "ownership" of the code. He wants to keep his status.
- Your team-lead want´s to meet his deadlines and at the same time does not want to go against you colleague as they probably formed some sort of bond (friendship?). Also he does not seem to be willing to get too much concerned with the root-cause of the issues.
Did I get anything wrong?
Now, you can concentrate on making yourself "invincible" by being technically superior and start going to War, but then it is inevitable that someone will loose this. OR, you could try to solve this and make everybody happy. First step is realizing there is three of you and you are all part of the problem.
- In joining a company you can´t automatically expect them to get all their coding-styles up to your standards, even if superior. It´s rather you who has to adopt their standards and improve from there. In fact, expect some things will never improve to where you want them.
- It is not only producing good code that makes you an asset for the company, but also getting along, sharing you knowledge etc.
- Getting from outright destructive team-environments to a pleasant and fruitful work environment requires a lot of skill in social engineering. I would argue this is the single most valuable skill for a professional programmer.
If you can accept that, start concentrating on the positives and try to go from there. You can basically choose between two routes.
A: Be Gentle:
Start complaining less and complimenting more. If you colleague makes a lot of errors, compliment him when he does none instead of complaining when he does. He never documents anything? Thank him when you do find a piece of documentation and state that it was helpful to you. Acknowledge his achievements providing functionality over the years.
Stop blaming individuals entirely, if you are hindered by legacy code put it in general terms as "There are just a lot more lines of code which have to be considered and can brake than before. Try to always offer a solution: Weekly pair-programming sessions, refactoring, tests etc.
Help you colleague to improve his programming skills. For example ask his opinion on a solution you just thought of. Be open, how would he solve it? What are the advantages and disadvantages of your vs his solutions? Treat him as equal and acknowledge that his solutions also get the job done, even if you think them inferior. Resist the urge to lecture him. See it as part of your job not only to create great programs but also to form a group of "friends and equals" who together create great programs.
Just tell them that you have a problem with work in general. You are not happy how thing run currently and you think to have a fruitful relationship some thing need to change. Still, do not blame. It´s not "he has to make fewer errors" - it´s "we need to improve quality of the code" etc. Don´t expect everything to be solved that way, but the should be a clear perspective of improvement. Actively be part of that improvement. Again, concentrate on solutions the strengthen collaboration.
B has the risk of escalating the wrong way and you may find yourself off worse than before (or even out of a job) while A requires a lot of patience and effort from you. Both are only viable if there is a minimal willingness of the other parties to improve. If not ... search for a new job.