  Magnetohydrodynamic (MHD) spectroscopy is central to many astrophysical
disciplines, ranging from helio- to asteroseismology, over solar coronal (loop)
seismology, to the study of waves and instabilities in jets, accretion disks,
or solar/stellar atmospheres. MHD spectroscopy quantifies all linear (standing
or travelling) wave modes, including overstable (i.e. growing) or damped modes,
for a given configuration that achieves force and thermodynamic balance. Here,
we present Legolas, a novel, open-source numerical code to calculate the full
MHD spectrum of one-dimensional equilibria with flow, that balance pressure
gradients, Lorentz forces, centrifugal effects and gravity, enriched with
non-adiabatic aspects like radiative losses, thermal conduction and
resistivity. The governing equations use Fourier representations in the
ignorable coordinates, and the set of linearised equations are discretised
using Finite Elements in the important height or radial variation, handling
Cartesian and cylindrical geometries using the same implementation. A weak
Galerkin formulation results in a generalised (non-Hermitian) matrix eigenvalue
problem, and linear algebraic algorithms calculate all eigenvalues and
corresponding eigenvectors. We showcase a plethora of well-established results,
ranging from p- and g-modes in magnetised, stratified atmospheres, over modes
relevant for coronal loop seismology, thermal instabilities and discrete
overstable Alfv\'en modes related to solar prominences, to stability studies
for astrophysical jet flows. We encounter (quasi-)Parker, (quasi-)interchange,
current-driven and Kelvin-Helmholtz instabilities, as well as non-ideal
quasi-modes, resistive tearing modes, up to magneto-thermal instabilities. The
use of high resolution sheds new light on previously calculated spectra,
revealing interesting spectral regions that have yet to be investigated.
