diff --git a/CHANGELOG.md b/CHANGELOG.md index 9529e6b..07605ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ 1087](https://github.com/tweag/ormolu/issues/1087). * Improve comment placement in if-then-else blocks. [Issue 998](https://github.com/tweag/ormolu/issues/998). +* Now command line options for fixity overrides and module re-exports + overwrite information from `.ormolu` files. [Issue + 1030](https://github.com/tweag/ormolu/issues/1030). ## Ormolu 0.7.3.0 diff --git a/app/Main.hs b/app/Main.hs index a44765c..9765391 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -168,15 +168,17 @@ formatOne ConfigFileOpts {..} mode reqSourceType rawConfig mpath = fromMaybe ModuleSource (reqSourceType <|> mdetectedSourceType) - let mfixityOverrides = fst <$> mdotOrmolu - mmoduleReexports = snd <$> mdotOrmolu return $ refineConfig sourceType mcabalInfo - mfixityOverrides - mmoduleReexports - rawConfig + (Just (cfgFixityOverrides rawConfig)) + (Just (cfgModuleReexports rawConfig)) + ( rawConfig + { cfgFixityOverrides = maybe defaultFixityOverrides fst mdotOrmolu, + cfgModuleReexports = maybe defaultModuleReexports snd mdotOrmolu + } + ) handleDiff originalInput formattedInput fileRepr = case diffText originalInput formattedInput fileRepr of Nothing -> return ExitSuccess diff --git a/fixity-tests/default.nix b/fixity-tests/default.nix index bb4c8f9..be9a420 100644 --- a/fixity-tests/default.nix +++ b/fixity-tests/default.nix @@ -16,6 +16,8 @@ ormolu --check-idempotence --mode inplace --no-cabal --no-dot-ormolu --fixity 'infixr 8 .=' --fixity 'infixr 5 :>' test-0-with-fixity-info-manual.hs cp test-0-input.hs test-0-with-fixity-info-dotormolu.hs ormolu --check-idempotence --mode inplace --no-cabal -p base test-0-with-fixity-info-dotormolu.hs + cp test-0-input.hs test-0-cli-overrides-dotormolu.hs + ormolu --check-idempotence --mode inplace --no-cabal -p base --fixity 'infixr 5 .=' test-0-cli-overrides-dotormolu.hs cp test-1-input.hs test-1-no-extra-info.hs ormolu --check-idempotence --mode inplace --no-cabal --no-dot-ormolu test-1-no-extra-info.hs cp test-1-input.hs test-1-with-fixity-info-manual.hs @@ -33,11 +35,13 @@ ''; checkPhase = '' echo test-0-no-extra-info.hs - diff --color=always test-0-no-extra-info-expected.hs test-0-no-extra-info.hs + diff --color=always test-0-ugly-expected.hs test-0-no-extra-info.hs echo test-0-with-fixity-info-manual.hs diff --color=always test-0-with-fixity-info-expected.hs test-0-with-fixity-info-manual.hs echo test-0-with-fixity-info-dotormolu.hs diff --color=always test-0-with-fixity-info-expected.hs test-0-with-fixity-info-dotormolu.hs + echo test-0-cli-overrides-dotormolu.hs + diff --color=always test-0-ugly-expected.hs test-0-cli-overrides-dotormolu.hs echo test-1-no-extra-info.hs diff --color=always test-1-no-extra-info-expected.hs test-1-no-extra-info.hs echo test-1-with-fixity-info-manual.hs diff --git a/fixity-tests/test-0-no-extra-info-expected.hs b/fixity-tests/test-0-ugly-expected.hs similarity index 100% rename from fixity-tests/test-0-no-extra-info-expected.hs rename to fixity-tests/test-0-ugly-expected.hs