Have you tried LaTeX yet? I just started using it seriously and I don't think I'll ever go back. It's amazing for writing. And since it's good old plain text, it's highly compatible with git. I love being able to import sub-documents into one large structure; it's like writing modular code, but with papers.