Add support for .dart files
This commit is contained in:
@@ -35,10 +35,11 @@ saving a file and to run `do-reformat.sh` when you hit `<F1>`.
|
|||||||
- css
|
- css
|
||||||
- cscc
|
- cscc
|
||||||
- sh
|
- sh
|
||||||
|
- dart
|
||||||
|
|
||||||
Python and go use `black` and `gofmt` respectively. The rest use `prettier`.
|
Python uses `black`; go uses `gofmt`; dart uses `dart format`. The rest use
|
||||||
Adding new programming languages is easy, assuming they have a formatter with
|
`prettier`. Adding new programming languages is easy, assuming they have a
|
||||||
a dry run mode.
|
formatter with a dry run mode.
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ function sniff_file_type() {
|
|||||||
file_type="sh"
|
file_type="sh"
|
||||||
elif [[ $ff = *.go ]] ; then
|
elif [[ $ff = *.go ]] ; then
|
||||||
file_type="golang"
|
file_type="golang"
|
||||||
|
elif [[ $ff = *.dart ]] ; then
|
||||||
|
file_type="dart"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $file_type
|
echo $file_type
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ elif [[ $file_type == "golang" ]] ; then
|
|||||||
out=$(gofmt -w "$file" 2>/dev/null)
|
out=$(gofmt -w "$file" 2>/dev/null)
|
||||||
retval="$?"
|
retval="$?"
|
||||||
success_retval=0
|
success_retval=0
|
||||||
|
elif [[ $file_type == "dart" ]] ; then
|
||||||
|
out=$(dart format $file)
|
||||||
|
retval="$?"
|
||||||
|
success_retval=0
|
||||||
else
|
else
|
||||||
echo -n "ignoring"
|
echo -n "ignoring"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -58,6 +58,15 @@ elif [[ $file_type == "golang" ]] ; then
|
|||||||
# success
|
# success
|
||||||
retval="$exitval"
|
retval="$exitval"
|
||||||
fi
|
fi
|
||||||
|
elif [[ $file_type == "dart" ]] ; then
|
||||||
|
success_retval=0
|
||||||
|
would_reformat_retval=1
|
||||||
|
# probably others too :(
|
||||||
|
syntax_error_retval=65
|
||||||
|
|
||||||
|
out=$(dart format -o none --set-exit-if-changed $file)
|
||||||
|
exitval="$?"
|
||||||
|
retval="$exitval"
|
||||||
else
|
else
|
||||||
echo -n "ignoring"
|
echo -n "ignoring"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user