diff --git a/README.md b/README.md index 8f01510a..fced1950 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,17 @@ e.g.: * `RUBYFMT_DISABLE_SZUSH=1`: disables the backend render queue writer, very useful for debugging, literally useless if you're not developing rubyfmt itself. + +## Editor Support + +### Visual Studio Code + +Rubyfmt is a supported formatter in the popular [vscode ruby extension](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby). After installing the extension and following the instructions above to ensure `rubyfmt` is available in your shell's `PATH`, add the following to vscode's `settings.json` file: + +``` json + "ruby.useLanguageServer": true, + "ruby.format": "rubyfmt", + "[ruby]": { + "editor.formatOnSave": true + }, +``` \ No newline at end of file diff --git a/script/install_shim.sh b/script/install_shim.sh new file mode 100755 index 00000000..bc455deb --- /dev/null +++ b/script/install_shim.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e +if [ $# -eq 0 ] + then + echo "Please pass a file location to install the shim script" + exit 1 +fi + +echo "#!/usr/bin/env bash +export RUBYFMT_USE_RELEASE=1 +$(which ruby) --disable=all $(pwd)/rubyfmt.rb \$@" > $1 +chmod +x $1 \ No newline at end of file diff --git a/script/tests/test_cli_interface.sh b/script/tests/test_cli_interface.sh index 5d3c9054..402eb688 100755 --- a/script/tests/test_cli_interface.sh +++ b/script/tests/test_cli_interface.sh @@ -16,6 +16,19 @@ test_single_file_stdout() { ) } +test_stdin_stdout() { + ( + cd "$(mktemp -d)" + + echo "a 1,2,3" > a_ruby_file.rb + echo "a(1, 2, 3)" > expected.rb + + cat a_ruby_file.rb | f_rubyfmt > out.rb + + diff_files out.rb expected.rb + ) +} + test_dir_no_i_flag() { ( cd "$(mktemp -d)" @@ -59,5 +72,6 @@ test_i_flag() { } test_single_file_stdout +test_stdin_stdout test_dir_no_i_flag test_i_flag