Skip to content

Conversation

ncaq
Copy link

@ncaq ncaq commented Jul 10, 2025

cabal-fmt and cabal-gild can discover module and autocomplete.

-- cabal-gild: discover ./src
exposed-modules:

The current system, treefmt can't detect change haskell module.
I write to depend to haskell module file.

`cabal-fmt` and `cabal-gild` can discover module and autocomplete.
```cabal
-- cabal-gild: discover ./src
exposed-modules:
```
The current system, treefmt can't detect change haskell module.
I write to depend to haskell module file.
@ncaq
Copy link
Author

ncaq commented Jul 10, 2025

Maybe I mistake.
cabal-gild it's don't work.

@ncaq ncaq marked this pull request as draft July 10, 2025 15:12
@ncaq ncaq force-pushed the auto-complete-cabal-module branch 2 times, most recently from fe63af5 to 0dc9aa3 Compare September 16, 2025 06:15
- Drop file filtering loops in cabal-fmt.nix and cabal-gild.nix
- Use git ls-files -z | xargs to run formatter on all .cabal files
- Avoid strict detection of cabal file args to simplify wrapper logic
@ncaq ncaq force-pushed the auto-complete-cabal-module branch from 0dc9aa3 to 5216610 Compare September 16, 2025 06:20
@ncaq ncaq marked this pull request as ready for review September 16, 2025 06:23
@ncaq
Copy link
Author

ncaq commented Sep 16, 2025

I tested my product and cabal-gild.
My way code, correct way in this project?

# For example, module completion by `cabal-fmt: discover`.
# It is difficult to determine this strictly.
# Since formatting with cabal-fmt doesn't take much time, we execute it speculatively.
text = ''${pkgs.git}/bin/git ls-files -z "*.cabal"|${pkgs.parallel}/bin/parallel --null "${lib.getExe cfg.package} --inplace {}"'';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how many formatters we have that format other files besides the one we passed it. It looks like the formatter specification does allow this:

It SHOULD processes only the specified files. Files that are not passed SHOULD never be formatted.

Not your ptoblem, but I'm just realizing this might be an issue for the nascent Stdin Spec: numtide/treefmt#586

Actual problem: this assumes we're in a git repo, but we expect formatters to work in plain source archives as well.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure how many formatters we have that format other files besides the one we passed it. It looks like the formatter specification does allow this:

I miss to check of https://github.com/numtide/treefmt/blob/c24e1f1b4fc3087f4cbfef4a0ad076bd86b129f0/docs/site/reference/formatter-spec.md?plain=1#L46.

However, cabal need format cause other module change.
I think that should not must, I want to allow exception.
Is it no good?
I want to auto fix cabal module by claude code hook.
I have no idea smart solution.

Actual problem: this assumes we're in a git repo, but we expect formatters to work in plain source archives as well.

I think to depend git that ok because nix depend git already.
I use git ls-files because I want to respect git ignore of real rule.
If prefer plain repo more than respect gitignore, I can use find.

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.

2 participants