packages feed

nixfmt 0.3.0 → 0.4.0

raw patch · 5 files changed

+28/−10 lines, 5 filesdep ~basedep ~megaparsecnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, megaparsec

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -7,6 +7,11 @@  # Revision history for nixfmt +## 0.4.0 -- 2020-02-10+* Report non-conforming files on the same line to aid line-oriented processing+* Fix help, summary, and version flag contents.+* Fix indentation of leading comments in parens+ ## 0.3.0 -- 2019-08-29  * Added check flag for use in CI.
README.md view
@@ -15,10 +15,16 @@  ## Installation -* Optional: `cachix use nixfmt`-* `nix-env -f https://github.com/serokell/nixfmt/archive/master.tar.gz -i`+- `nixfmt` is in nixpkgs master as of 2019-09-04:  +      nix-env -iA nixpkgs.nixfmt +- To get the most recent version, install from master:++      # Optional: use cachix to get cached builds even for master+      cachix use nixfmt+      nix-env -f https://github.com/serokell/nixfmt/archive/master.tar.gz -i+ ## Development  ### With Nix@@ -30,7 +36,7 @@  ### Without Nix -Haskell dependencies will be bulit by Cabal.+Haskell dependencies will be built by Cabal.  * Build with `cabal new-build` 
main/Main.hs view
@@ -12,11 +12,13 @@ import Data.Bifunctor (first) import Data.Either (lefts) import Data.Text (Text)+import Data.Version (showVersion) import GHC.IO.Encoding (utf8)+import Paths_nixfmt (version) import System.Console.CmdArgs   (Data, Typeable, args, cmdArgs, help, summary, typ, (&=)) import System.Exit (ExitCode(..), exitFailure, exitSuccess)-import System.IO (hPutStr, hSetEncoding, stderr)+import System.IO (hPutStrLn, hSetEncoding, stderr) import System.Posix.Process (exitImmediately) import System.Posix.Signals (Handler(..), installHandler, keyboardSignal) @@ -42,7 +44,8 @@     , width = 80 &= help "Maximum width in characters"     , check = False &= help "Check whether files are formatted"     , quiet = False &= help "Do not report errors"-    } &= summary "Format Nix source code"+    } &= summary ("nixfmt v" ++ showVersion version)+    &= help "Format Nix source code"  format' :: Width -> FilePath -> Text -> Either String Text format' w path = first errorBundlePretty . format w path@@ -68,7 +71,7 @@         Left err -> Left err         Right formatted             | formatted == contents -> Right ()-            | otherwise             -> Left $ tPath ++ ":\nnot formatted"+            | otherwise             -> Left $ tPath ++ ": not formatted"  stdioTarget :: Target stdioTarget = Target TextIO.getContents "<stdin>" TextIO.putStr@@ -89,7 +92,7 @@ toOperation Nixfmt{ width = w } = formatTarget w  toWriteError :: Nixfmt -> String -> IO ()-toWriteError Nixfmt{ quiet = False } = hPutStr stderr+toWriteError Nixfmt{ quiet = False } = hPutStrLn stderr toWriteError Nixfmt{ quiet = True } = const $ return ()  toJobs :: Nixfmt -> [IO Result]
nixfmt.cabal view
@@ -6,7 +6,7 @@ -- SPDX-License-Identifier: MPL-2.0  name:                nixfmt-version:             0.3.0+version:             0.4.0 synopsis:            An opinionated formatter for Nix description:   A formatter for Nix that ensures consistent and clear formatting by forgetting@@ -29,8 +29,11 @@ executable nixfmt   main-is:             Main.hs   other-modules:+    Paths_nixfmt     System.IO.Utf8     System.IO.Atomic+  autogen-modules:+    Paths_nixfmt   other-extensions:    DeriveDataTypeable   hs-source-dirs:      main   if impl(ghcjs)
src/Nixfmt/Pretty.hs view
@@ -111,8 +111,9 @@         <> nest 2 (pretty leading <> sepBy hardline binders) <> line         <> pretty parclose -prettyTerm (Parenthesized paropen expr parclose)-    = base $ pretty paropen <> nest 2 (group expr) <> pretty parclose+prettyTerm (Parenthesized (Ann paropen trailing leading) expr parclose)+    = base $ pretty paropen <> pretty trailing+        <> nest 2 (pretty leading <> group expr) <> pretty parclose  instance Pretty Term where     pretty l@(List _ _ _) = group $ prettyTerm l