Add Elixir mix format support

This commit is contained in:
Noah Betzen 2023-11-02 11:50:09 -07:00 committed by Ethan P
parent a686d6742c
commit bc534e9dd2
2 changed files with 40 additions and 17 deletions

View File

@ -22,7 +22,7 @@ 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/) |
@ -37,6 +37,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) | | Objective-C | [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) |
| Python | [black](https://black.readthedocs.io/) | | Python | [black](https://black.readthedocs.io/) |
| Elixir | [mix format](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html) |

View File

@ -22,7 +22,7 @@ hook_version
# Formatters: # Formatters:
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat" "black") FORMATTERS=("prettier" "rustfmt" "shfmt" "clangformat" "black", "mix_format")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -118,6 +118,26 @@ formatter_black_process() {
return $? return $?
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
formatter_mix_format_supports() {
case "$1" in
.ex | \
.exs | \
.eex | \
.heex)
return 0
;;
esac
return 1
}
formatter_mix_format_process() {
mix format
return $?
}
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Functions: # Functions:
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@ -145,6 +165,8 @@ map_language_to_extension() {
rust | rs) ext=".rs" ;; rust | rs) ext=".rs" ;;
graphql | gql) ext=".graphql" ;; graphql | gql) ext=".graphql" ;;
python | py) ext=".py" ;; python | py) ext=".py" ;;
elixir | ex) ext=".ex" ;;
exs) ext=".exs" ;;
esac esac
echo "$ext" echo "$ext"