Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for setting up vscode integration #201

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
```
12 changes: 12 additions & 0 deletions script/install_shim.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions script/tests/test_cli_interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -59,5 +72,6 @@ test_i_flag() {
}

test_single_file_stdout
test_stdin_stdout
test_dir_no_i_flag
test_i_flag