https://github.com/phadej/cabal-fmt
An experiment of formatting .cabal files
https://github.com/phadej/cabal-fmt
Last synced: about 1 year ago
JSON representation
An experiment of formatting .cabal files
- Host: GitHub
- URL: https://github.com/phadej/cabal-fmt
- Owner: phadej
- License: gpl-3.0
- Created: 2018-12-16T20:29:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T03:32:12.000Z (about 2 years ago)
- Last Synced: 2025-03-26T13:11:09.739Z (over 1 year ago)
- Language: Haskell
- Size: 179 KB
- Stars: 108
- Watchers: 7
- Forks: 25
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome - phadej/cabal-fmt
README
# cabal-fmt
## Synopsis
```sh
$ cabal install cabal-fmt
$ ...
$ cabal-fmt --inplace example.cabal
```
## Output
Turns this...
```cabal
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
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 && <1.2
-- 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`:
```elisp
((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`:
- [`vim-cabalfmt`](https://github.com/sdiehl/vim-cabalfmt), a standalone plugin
- [`neoformat`](https://github.com/sbdchd/neoformat), a general formatter with `cabal-fmt` support