mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-02-12 15:19:12 +01:00
Add ClangFormat to prettybat
This commit is contained in:
parent
24313f8281
commit
0621d14951
@ -20,17 +20,20 @@ See `man bat` for more information.
|
|||||||
|
|
||||||
## Languages
|
## Languages
|
||||||
|
|
||||||
| Language | Formatter |
|
| Language | Formatter |
|
||||||
| -------------------- | ----------------------------------------------- |
|
| -------------------- | ----------------------------------------------------------- |
|
||||||
| JavaScript (JS, JSX) | [prettier](https://prettier.io/) |
|
| JavaScript (JS, JSX) | [prettier](https://prettier.io/) |
|
||||||
| TypeScript (TS, TSX) | [prettier](https://prettier.io/) |
|
| TypeScript (TS, TSX) | [prettier](https://prettier.io/) |
|
||||||
| CSS, SCSS, SASS | [prettier](https://prettier.io/) |
|
| CSS, SCSS, SASS | [prettier](https://prettier.io/) |
|
||||||
| Markdown | [prettier](https://prettier.io/) |
|
| Markdown | [prettier](https://prettier.io/) |
|
||||||
| JSON | [prettier](https://prettier.io/) |
|
| JSON | [prettier](https://prettier.io/) |
|
||||||
| YAML | [prettier](https://prettier.io/) |
|
| YAML | [prettier](https://prettier.io/) |
|
||||||
| HTML | [prettier](https://prettier.io/) |
|
| HTML | [prettier](https://prettier.io/) |
|
||||||
| Rust | [rustfmt](https://github.com/rust-lang/rustfmt) |
|
| Rust | [rustfmt](https://github.com/rust-lang/rustfmt) |
|
||||||
| Bash | [shfmt](https://github.com/mvdan/sh) |
|
| Bash | [shfmt](https://github.com/mvdan/sh) |
|
||||||
|
| 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) |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ source "${LIB}/print.sh"
|
|||||||
# Formatters:
|
# Formatters:
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FORMATTERS=("prettier" "rustfmt" "shfmt")
|
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat")
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
@ -40,6 +40,24 @@ formatter_prettier_process() {
|
|||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
formatter_clangformat_supports() {
|
||||||
|
case "$1" in
|
||||||
|
.c|.cpp|.cxx|\
|
||||||
|
.h|.hpp|\
|
||||||
|
.m)
|
||||||
|
return 0;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
formatter_clangformat_process() {
|
||||||
|
clang-format "$1" 2>/dev/null
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
formatter_rustfmt_supports() {
|
formatter_rustfmt_supports() {
|
||||||
[[ "$1" = ".rs" ]]
|
[[ "$1" = ".rs" ]]
|
||||||
return $?
|
return $?
|
||||||
@ -135,6 +153,7 @@ process_file() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local formatter="$(map_extension_to_formatter "$fext")"
|
local formatter="$(map_extension_to_formatter "$fext")"
|
||||||
|
echo "FORMATTER >>> $formatter"
|
||||||
if [[ "$formatter" = "none" ]]; then
|
if [[ "$formatter" = "none" ]]; then
|
||||||
if [[ -z "$OPT_LANGUAGE" ]]; then
|
if [[ -z "$OPT_LANGUAGE" ]]; then
|
||||||
print_file "$file"
|
print_file "$file"
|
||||||
|
Loading…
Reference in New Issue
Block a user