@@ -65,6 +65,7 @@ import Text.Regex.TDFA
6565
6666
6767import qualified Data.Text ()
68+ import Distribution.Parsec.Error
6869import qualified Ide.Plugin.Cabal.CabalAdd as CabalAdd
6970
7071data Log
@@ -220,8 +221,9 @@ cabalRules recorder plId = do
220221 fields <- use_ ParseCabalFields file
221222 let commonSections = Maybe. mapMaybe (\ case
222223 commonSection@ (Syntax. Section (Syntax. Name _ " common" ) _ _) -> Just commonSection
223- _ -> Nothing )
224- fields
224+ _ -> Nothing
225+ )
226+ fields
225227 pure ([] , Just commonSections)
226228
227229 define (cmapWithPrio LogShake recorder) $ \ ParseCabalFile file -> do
@@ -247,7 +249,19 @@ cabalRules recorder plId = do
247249 let warningDiags = fmap (Diagnostics. warningDiagnostic file) pWarnings
248250 case pm of
249251 Left (_cabalVersion, pErrorNE) -> do
250- let errorDiags = NE. toList $ NE. map (Diagnostics. errorDiagnostic file) pErrorNE
252+ let regex :: T. Text
253+ -- We don't support the cabal version, this should not be an error, as the
254+ -- user did not do anything wrong. Instead we cast it to a warning
255+ regex = " Unsupported cabal-version [0-9]+.[0-9]*"
256+ errorDiags =
257+ NE. toList $
258+ NE. map
259+ ( \ pe@ (PError pos text) ->
260+ if text =~ regex
261+ then Diagnostics. warningDiagnostic file (Syntax. PWarning Syntax. PWTOther pos text)
262+ else Diagnostics. errorDiagnostic file pe
263+ )
264+ pErrorNE
251265 allDiags = errorDiags <> warningDiags
252266 pure (allDiags, Nothing )
253267 Right gpd -> do
0 commit comments