mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-04 21:40:44 +01: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) |
|
||||
| Objective-C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
|
||||
| Python | [black](https://black.readthedocs.io/) |
|
||||
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ hook_version
|
||||
# Formatters:
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat")
|
||||
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat" "black")
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@ -90,6 +90,26 @@ formatter_shfmt_process() {
|
||||
return $?
|
||||
}
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
formatter_black_supports() {
|
||||
case "$1" in
|
||||
.py | \
|
||||
.py3 | \
|
||||
.pyw | \
|
||||
.pyi)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
formatter_black_process() {
|
||||
black --code "$(cat -)"
|
||||
return $?
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Functions:
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -115,6 +135,7 @@ map_language_to_extension() {
|
||||
yaml | yml) ext=".yml" ;;
|
||||
rust | rs) ext=".rs" ;;
|
||||
graphql | gql) ext=".graphql" ;;
|
||||
python | py) ext=".py" ;;
|
||||
esac
|
||||
|
||||
echo "$ext"
|
||||
|
Loading…
Reference in New Issue
Block a user