66 lines
1.3 KiB
Bash
66 lines
1.3 KiB
Bash
function root() {
|
|
echo "$(git rev-parse --show-toplevel)"
|
|
}
|
|
|
|
wfroot() {
|
|
dir="$1"
|
|
cat "$dir/.root"
|
|
}
|
|
|
|
function custom_formatter() {
|
|
root="$1"
|
|
file_type="$2"
|
|
|
|
maybe="$root/.would-reformat/$file_type"
|
|
if [[ -f "$maybe" ]] ; then
|
|
echo "$maybe"
|
|
return
|
|
fi
|
|
|
|
echo "use-default"
|
|
}
|
|
|
|
# FIXME: This needs to be made customizable
|
|
function sniff_file_type() {
|
|
ff=$1
|
|
shift
|
|
file_type=
|
|
|
|
if [[ $ff == *.py ]]; then
|
|
file_type="python"
|
|
elif [[ $ff == *.js ]]; then
|
|
file_type="javascript"
|
|
elif [[ $ff == *.ts ]]; then
|
|
file_type="typescript"
|
|
elif [[ $ff == *.vue ]]; then
|
|
file_type="vue"
|
|
elif [[ $ff == *.css ]]; then
|
|
file_type="css"
|
|
elif [[ $ff == *.php ]]; then
|
|
file_type="php"
|
|
elif [[ $ff == *.html ]]; then
|
|
file_type="html"
|
|
elif [[ $ff == *.jsx ]]; then
|
|
file_type="jsx"
|
|
elif [[ $ff == *.tsx ]]; then
|
|
file_type="tsx"
|
|
elif [[ $ff == *.css ]] ; then
|
|
file_type="css"
|
|
elif [[ $ff == *.scss ]] ; then
|
|
file_type="scss"
|
|
elif [[ $ff = *.sh ]]; then
|
|
file_type="sh"
|
|
elif [[ $ff = *.go ]] ; then
|
|
file_type="golang"
|
|
elif [[ $ff = *.dart ]] ; then
|
|
file_type="dart"
|
|
fi
|
|
|
|
echo $file_type
|
|
}
|
|
|
|
|
|
function wrflog() {
|
|
echo "$@" >> /tmp/wrflog
|
|
}
|