In the book Condensed Matter Field Theory (A. Altland & B. Simons)(page 498, 2nd edition) they suggest the following Hamiltonian and Lagrangian for a particle on a ring in the presence of a magnetic field (with a vector potential $A$): \begin{align} \mathcal{H} &= \frac{1}{2} \left( -i \partial_{\phi} - A \right)^2\tag{9.1} \\ \mathcal{L} &= \frac{1}{2}\dot{\phi}^2-i A \dot{\phi}\;.\tag{9.4} \end{align}
They also suggest as an exercise for the student to verify that the Legendre transform indeed gives the above results, so I've tried!
The momentum is given by \begin{align} \pi &= \frac{\partial\mathcal{L}}{\partial \dot{\phi}} = \dot{\phi}- i A\;, \end{align} then, the Legendre transform of $\mathcal{L}$ is \begin{align} \mathcal{H} &= \pi \dot{\phi} - \mathcal{L} \\ &= \dot{\phi}^2 - i A\dot{\phi} - \frac{1}{2}\dot{\phi}^2 + i A \dot{\phi} \\ &= \frac{1}{2} \dot{\phi}^2 \\ &= \frac{1}{2} \left( \pi + i A \right)^2 \; . \end{align} Now, finally, $\pi\mapsto-i\nabla$ in the position representation ($\hbar=1$) where for a particle which constrained to live on a ring, only the angular derivative survives, such that \begin{align} \mathcal{H} &= \frac{1}{2} \left( -i \partial_\phi +iA \right)^2 \\ &= \frac{1}{2} \left( A - \partial_\phi \right)^2 \;, \end{align} which is obviously not the given Hamiltonian. For a plus-minus issue: I wouldn't bother... but the lack of the imaginary part is a matter of a big deal.
I feel that that I'm missing something extremely simple (or something subtle? idk), but either way, I would be grateful if anyone could point out the missing link.