Skip to content

Format .cabal files with cabal-gild#4229

Open
fendor wants to merge 1 commit intohaskell:masterfrom
fendor:enhance/format-with-cabal-gild
Open

Format .cabal files with cabal-gild#4229
fendor wants to merge 1 commit intohaskell:masterfrom
fendor:enhance/format-with-cabal-gild

Conversation

@fendor
Copy link
Copy Markdown
Collaborator

@fendor fendor commented May 13, 2024

Compare with #4230

Closes #4228

@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from b3b4bd4 to dff31ba Compare May 13, 2024 09:52
directory,
extra,
filepath,
ghcide ==2.8.0.0,
Copy link
Copy Markdown
Collaborator

@jhrcek jhrcek May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more reason I prefer cabal-gild, is that it doesn't try to preserve version constraint indentation.
This leads to more diff friendly format (adding/removing dependency with longer than longest name, doesn't lead to indentation changes for other version constraints)
e.g.

short >=1.0
longer >= 2.0   < Adding longer dependency re-indents version constraint for shorter, which makes for longer diffs

@soulomoon
Copy link
Copy Markdown
Collaborator

can cabal-gild have , prefixing line breaking for items?

Copy link
Copy Markdown

@tfausak tfausak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 I'm the author/maintainer of Gild. Let me know if I can do anything to help here!

@fendor fendor force-pushed the enhance/format-with-cabal-gild branch 2 times, most recently from ac4506d to 7bda10f Compare May 15, 2024 07:35
@fendor
Copy link
Copy Markdown
Collaborator Author

fendor commented May 15, 2024

Reformatted the .cabal files with cabal-gild-1.3.1.0 for accurate comparison.

@fendor fendor marked this pull request as draft June 13, 2024 21:51
@VeryMilkyJoe VeryMilkyJoe force-pushed the enhance/format-with-cabal-gild branch from 5eb7a78 to cefc2d9 Compare June 8, 2025 17:21
@fendor fendor marked this pull request as ready for review June 8, 2025 17:22
@fendor
Copy link
Copy Markdown
Collaborator Author

fendor commented Jun 8, 2025

@VeryMilkyJoe Thanks for rebasing this, I think we should merge this PR now and see how annoying it is for future contributors.

Formatted with cabal-gild-1.5.0.1

@fendor fendor changed the title Draft: Format .cabal files with cabal-gild Format .cabal files with cabal-gild Jun 8, 2025
@michaelpj
Copy link
Copy Markdown
Collaborator

Shipit!

Copy link
Copy Markdown

@tfausak tfausak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug-reports: https://github.com/haskell/haskell-language-server/issues
tested-with: GHC == {9.12.2, 9.10.1, 9.8.4, 9.6.7}
bug-reports: https://github.com/haskell/haskell-language-server/issues
tested-with: ghc ==9.12.2 || ==9.10.1 || ==9.8.4 || ==9.6.7
Copy link
Copy Markdown

@tfausak tfausak Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with version 1.5.0.3, Gild will correctly leave this in set notation. See tfausak/cabal-gild#118.

Chart,
Chart-diagrams,
aeson,
base >=4 && <5,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note here: Starting with version 1.5.0.3, Gild will correctly retain the wildcard version constraint. tfausak/cabal-gild#118

hls-plugin-api ==2.11.0.0,
hls-test-utils ==2.11.0.0,

if flag(isolatecabalfmttests)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cabal converts flag names to lowercase. Gild does the same in order to make this conversion obvious. However it could retain the case from the input if desired. See #4230 (comment).

if os(darwin)
ghc-options: -optl-Wl,-ld_classic
if os(osx)
ghc-options: "-optl-Wl,-ld_classic"
Copy link
Copy Markdown

@tfausak tfausak Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder why this got quoted. Maybe because there's a comma in it?

Also note that darwin and osx are aliases. Gild canonicalizes operating systems (and architectures).

, semanticTokens
, notes
import:
-- plugins
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note here about comment placement.

directory,
extra,
filepath,
ghcide,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I don't think it changes the semantics, but starting with version 1.5.0.3, Gild would keep this as ghcide:{ghcide}. See tfausak/cabal-gild#115.

@VeryMilkyJoe VeryMilkyJoe force-pushed the enhance/format-with-cabal-gild branch from cefc2d9 to 2c69e4c Compare June 9, 2025 14:00
@fendor fendor force-pushed the enhance/format-with-cabal-gild branch 2 times, most recently from c37cf33 to 4c62386 Compare March 5, 2026 07:55
@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from 4c62386 to ade3516 Compare March 5, 2026 10:47
@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from ade3516 to 5b9c894 Compare March 5, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format all .cabal files in the repo with a cabal formatter

5 participants