rtts / djhtml

Django/Jinja template indenter
GNU General Public License v3.0
572 stars 32 forks source link

option to set tabwidth on pre-commit #67

Closed JanMalte closed 1 year ago

JanMalte commented 1 year ago

Please provide an option to set the tabwidth for pre-commit usage.

Or even read the .editorconfig

JaapJoris commented 1 year ago

This is already an option, although admittedly ill-documented.

With pre-commit, you can set a number of options of each hook, including the entry option which contains the command to run. When you look at the default entry points of DjHTML you will see that these commands are djhtml -i, djcss -i and djjs -i. If you want to override that, place the following inside your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/rtts/djhtml
    rev: v1.5.2
    hooks:
      - id: djhtml
        # Use tabwidth 3 for HTML files
        entry: djhtml -i -t 3
      - id: djcss
        # Use tabwidth 5 for CSS files
        entry: djcss -i -t 5
      - id: djjs
        # Use tabwidth 7 for JS files
        entry: djjs -i -t 7

I have added this missing documentation the README, so I will now close this issue. Thank you very much for bringing this to my attention!