Closed hamdanal closed 2 years ago
Thanks for this, and I'm glad the tool works for you.
I'm sorry, I'm unclear what you would like or need me to do. Does the yaml file you describe need to live in this repository? Or is it something that users create in their own repositories?
If something needs to be created, and you know what needs to be done, please do feel free to submit a pull request to the develop branch :)
Does the yaml file you describe need to live in this repository? Or is it something that users create in their own repositories?
Yes. The .pre-commit-hooks.yaml
needs to be created in the root of this repository. This gives necessary information to the pre-commit
framework on how to install and run latexindent
for the users.
If something needs to be created, and you know what needs to be done, please do feel free to submit a pull request to the develop branch :)
Unfortunately I don't know enough about perl (I don't know anything to be frank) to submit a PR. If you are interested in adding this functionality, I can gladly help creating the .pre-commit-hooks.yaml
file but the repository first needs a Makefile.PL
or Build.PL
installation file according to the pre-commit docs.
OK, thanks for the follow up.
I'm happy to explore this and to try to get it moving. I'm new to the pre commit
stuff but from my early reading I can see it being helpful. I found the following post interesting
https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/
I'd certainly welcome your assistance with any part that you can, including the documentation.
I guess the first step is for me to create Makefile.pl
.
No problem and thank you for being interactive.
I guess the first step is for me to create Makefile.pl.
Indeed. Please ping me here when this is done so that I can proceed with the creation of the hook file and adding an entry in the docs. We need also to discuss the default command line arguments to use when running the tool with pre-commit
. For instance using the --silent
and --overwrite
flags seems to make sense in this context.
This looks helpful as a demonstration that has a Makefile.pl
OK, will do. Development is slow at the moment, but it's on the list :) all help welcome!
Possibly helpful (search for perl on page) :
Thanks.
I found this project https://github.com/perltidy/perltidy interesting. It has a Makefile.PL
file and defines a pre-commit hook.
Here is a preliminary version of the hook that we should define:
- id: latexindent.pl
name: latexindent.pl
description: Perl script to add indentation (leading horizontal space) to LaTeX files.
minimum_pre_commit_version: 2.1.0
entry: latexindent.pl --silent --overwrite
language: perl
types_or: [tex, sty, cls, bib]
Notes:
language: perl
tells pre-commit that this is a perl tool and to use the Makefile.PL
file to install the tool;types_or: [tex, sty, cls, bib]
tells pre-commit to run the tool for any of these file types (from https://latexindentpl.readthedocs.io/en/latest/sec-introduction.html#lst-fileextensionpreference-demo);entry: latexindent.pl --silent --overwrite
runs the tool with these defaults. Users can add extra arguments in their projectsThat looks good, nicely done. Perhaps the Makefile.pl
can be adapted for this too.
First step would be to implement Makefile.pl
on a dummy repository to demonstrate concept.
I would love to use this !!
It seems that pre-commit can use conda : https://pre-commit.com/#new-hooks In that case things might be simple : one can just use the feedstock on conda forge (does require https://github.com/cmhughes/latexindent.pl/issues/303 to be merged for macOS ARM users)
This is implemented as of https://github.com/cmhughes/latexindent.pl/pull/322
A huge thank you to @tdegeus for their work on this, and for all of their time in answering my questions! I've got a few minor documentation tweaks to do, and then I'll get the next release published, which will include this feature.
I'll leave this open until that happens. Thank you again!
This is resolved as of https://github.com/cmhughes/latexindent.pl/releases/tag/V3.15
Thank you very much to @tdegeus for this contribution, fantastic stuff! :) I've uploaded to ctan
as well.
This is an amazing tool, thank you for your work. I could not follow the issue template as it is designed for issues that concern written code or bug reports while this is a feature request related to the tool usage. Here goes:
pre-commit is a famous framework for managing and maintaining pre-commit hooks such as linters and code formatters. It supports most of the famous programming languages including perl. It would be very helpful to be able to run
latexindent
as a pre-commit hook. The support can be added by creating a.pre-commit-hooks.yaml
file in the root of this repository which will tellpre-commit
how to install and runlatexindent
.Here an example hook file https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml for the famous python formatter black for reference.