Description
Generating a new package with cabal 3.12
via
$ mkdir test-hls-cabal
$ cd test-hls-cabal
$ cabal init --lib -n
Generates a .cabal
file with cabal-version: 3.12
, which haskell-language-server-2.9.0.1
built with ghc-9.6.5
, which is linked against Cabal-3.10.3.0
. Consequentially, HLS highlights the whole .cabal
file as incorrect, as it doesn't recognise 3.12
as a valid cabal-version
.
This is bad user-experience.
I am not sure whether we can fix that for good, as older HLS versions will never get linked against a newer Cabal
version.
However, what we could do is to be more lenient when it comes to parsing .cabal
files.
We can scan the .cabal
file for the line cabal-version:
(scanSpecVersion
) and if the version is not known to us, we parse the cabal file with the newest CabalSpecVersion available to the HLS binary.
The cabal
features may still break if users actually need new cabal-the-spec-features, but for many future changes, we likely only display warnings and many other IDE features keep working.
The only real disadvantage is that we can't reliably report incorrect cabal-version
numbers any more. Also, the proposed behaviour might be unexpected to users.
The last resort I can think of, is to simply not provide any IDE features if the cabal-version is seemingly too new for the Cabal version linked into HLS.