mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 19:57:46 +02:00
Add python formatter black to prettybat
This commit is contained in:
parent
eb69d61ff8
commit
165fc69d34
@ -35,6 +35,7 @@ See `man bat` for more information.
|
|||||||
| C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
| C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
||||||
| C++ | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
| C++ | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
||||||
| Objective-C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
| Objective-C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
||||||
|
| Python | [black](https://black.readthedocs.io/) |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ hook_version
|
|||||||
# Formatters:
|
# Formatters:
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat")
|
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat" "black")
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
@ -90,6 +90,26 @@ formatter_shfmt_process() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
formatter_black_supports() {
|
||||||
|
case "$1" in
|
||||||
|
.py | \
|
||||||
|
.py3 | \
|
||||||
|
.pyw | \
|
||||||
|
.pyi)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
formatter_black_process() {
|
||||||
|
black --code "$(cat -)"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Functions:
|
# Functions:
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@ -115,6 +135,7 @@ map_language_to_extension() {
|
|||||||
yaml | yml) ext=".yml" ;;
|
yaml | yml) ext=".yml" ;;
|
||||||
rust | rs) ext=".rs" ;;
|
rust | rs) ext=".rs" ;;
|
||||||
graphql | gql) ext=".graphql" ;;
|
graphql | gql) ext=".graphql" ;;
|
||||||
|
python | py) ext=".py" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "$ext"
|
echo "$ext"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user