Skip to content

An experiment of formatting .cabal files

License

Notifications You must be signed in to change notification settings

VeryMilkyJoe/cabal-fmt

This branch is 2 commits ahead of, 49 commits behind phadej/cabal-fmt:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cfe78a3 · Aug 5, 2021

History

80 Commits
Feb 14, 2021
Aug 30, 2020
Feb 14, 2021
Dec 16, 2018
Aug 5, 2021
Oct 24, 2020
Dec 16, 2018
Apr 4, 2019
Dec 16, 2018
Aug 10, 2019
Nov 9, 2020
Dec 16, 2018
Aug 30, 2020
Jun 30, 2020
Jul 28, 2021
Aug 9, 2019
Aug 10, 2019

Repository files navigation

cabal-fmt

Synopsis

$ cabal install cabal-fmt
$ ...
$ cabal-fmt --inplace example.cabal

Output

Turns this...

cabal-version: 2.4
name: cabal-fmt
version: 0

-- An example formatter
executable cabal-fmt
    default-language: Haskell2010
    hs-source-dirs: src 
    main-is: CabalFmt.hs
    -- build depends will be in
    -- a nice tabular format
    build-depends: base >=4.11 && <4.13, pretty >=1.1.3.6 && <1.2, bytestring, Cabal ^>=2.5, containers ^>=0.5.11.0 || ^>=0.6.0.1
    -- extensions will be sorted
    other-extensions:
      DeriveFunctor FlexibleContexts ExistentialQuantification OverloadedStrings
      RankNTypes

...into this:

cabal-version: 2.4
name:          cabal-fmt
version:       0

-- An example formatter
executable cabal-fmt
  default-language: Haskell2010
  hs-source-dirs:   src
  main-is:          CabalFmt.hs

  -- build depends will be in
  -- a nice tabular format
  build-depends:
    , base        >=4.11 && <4.13
    , bytestring
    , Cabal       ^>=2.5
    , containers  ^>=0.5.11.0 || ^>=0.6.0.1
    , pretty      ^>=1.1.3.6

  -- extensions will be sorted
  other-extensions:
    DeriveFunctor
    ExistentialQuantification
    FlexibleContexts
    OverloadedStrings
    RankNTypes

Editor Integration

Emacs

If you have cabal-fmt in your $PATH, you can auto-format .cabal files in your project by putting this in the project directory's .dir-locals.el:

((haskell-cabal-mode
  (eval .
    (add-hook 'before-save-hook
      (lambda () (haskell-mode-buffer-apply-command "cabal-fmt")) nil t))))

Vim

There are currently two options, both requiring cabal-fmt to be in your $PATH:

About

An experiment of formatting .cabal files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Haskell 99.4%
  • Makefile 0.6%