Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Get modern rubyfmt working
Browse files Browse the repository at this point in the history
Per #627, the previous behavior of the rubyfmt formatter class included
an embedded version of the rubyfmt script. This isn't really a workable
solution anymore as the program has evolved beyond a simple ruby script
to include native modules.  This instead changes the formatter class to
rely on a `rubyfmt` executable on the user's `$PATH`.  Because rubyfmt
is not currently installable via bundler and is in a pre-release state,
users are expected to have followed the necessary installation
instructions from the [project
README](https://github.com/penelopezone/rubyfmt/blob/master/README.md#how-do-i-use-it).
The current instructions recommend adding an alias, but vscode will not
respect that (or at least vscode-ruby doesn't). Instead I have a
[commit](fables-tales/rubyfmt@19d5946)
submitted in [a PR](fables-tales/rubyfmt#201)
which will make it easier to install an actual executable shim script.
  • Loading branch information
wadetandy committed Jun 7, 2020
1 parent 0485919 commit 2a5e129
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3,795 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Improvements:
- Support SLIM heredocs [#274](https://github.com/rubyide/vscode-ruby/issues/274)
- Support heredocs defined inline during a method call [#183](https://github.com/rubyide/vscode-ruby/issues/183)
- Drop `spawn-rx` for custom version which allows greater control over failed commands
- Support [RubyFMT](https://github.com/samphippen/rubyfmt) as a formatter [#445](https://github.com/rubyide/vscode-ruby/issues/445)
- Support [RubyFMT](https://github.com/penelopezone/rubyfmt) as a formatter [#445](https://github.com/rubyide/vscode-ruby/issues/445)
- Add command palette entries for viewing extension and language server logs (`Ruby: Show Output Channel` and `Ruby: Show Language Server Output Channel`)
- Support multiline and keyword option YARD comments [#371](https://github.com/rubyide/vscode-ruby/pull/371)
- Improve/Fix Block Parameter Highlighting [#514](https://github.com/rubyide/vscode-ruby/pull/514)
Expand Down
2 changes: 1 addition & 1 deletion docs/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The language server currently supports formatting via the following formatters:
- [RuboCop](https://github.com/rubocop-hq/rubocop)
- [Standard](https://github.com/testdouble/standard)
- [Rufo](https://github.com/ruby-formatter/rufo)
- [RubyFMT](https://github.com/samphippen/rubyfmt)
- [RubyFMT](https://github.com/penelopezone/rubyfmt)

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/language-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The server is built to be extensible, accurate, and performant with such feature
- Automatic Ruby environment detection with support for rvm, rbenv, chruby, and asdf
- Robust language feature extraction powered by the [tree-sitter](https://tree-sitter.github.io/tree-sitter/) project
- Lint support via RuboCop, Reek, and Standard
- Format support via RuboCop, Standard, and Rufo
- Format support via RuboCop, Standard, Rubyfmt, and Rufo
- Semantic code folding support
- Semantic highlighting support
- Intellisense support
Expand Down
9 changes: 4 additions & 5 deletions packages/language-server-ruby/src/formatters/RubyFMT.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import path from 'path';
import { URI } from 'vscode-uri'
import BaseFormatter from './BaseFormatter';

const RUBYFMT_PATH = path.resolve(__dirname, 'rubyfmt.rb');

export default class RubyFMT extends BaseFormatter {
get cmd(): string {
return 'ruby';
return 'rubyfmt';
}

get args(): string[] {
return ['--disable=gems', RUBYFMT_PATH];
const documentPath = URI.parse(this.document.uri);
return [documentPath.fsPath];
}

get useBundler(): boolean {
Expand Down
Loading

0 comments on commit 2a5e129

Please sign in to comment.