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

Commit 2a5e129

Browse files
committed
Get modern rubyfmt working
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.
1 parent 0485919 commit 2a5e129

File tree

6 files changed

+8
-3795
lines changed

6 files changed

+8
-3795
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Improvements:
7575
- Support SLIM heredocs [#274](https://github.com/rubyide/vscode-ruby/issues/274)
7676
- Support heredocs defined inline during a method call [#183](https://github.com/rubyide/vscode-ruby/issues/183)
7777
- Drop `spawn-rx` for custom version which allows greater control over failed commands
78-
- Support [RubyFMT](https://github.com/samphippen/rubyfmt) as a formatter [#445](https://github.com/rubyide/vscode-ruby/issues/445)
78+
- Support [RubyFMT](https://github.com/penelopezone/rubyfmt) as a formatter [#445](https://github.com/rubyide/vscode-ruby/issues/445)
7979
- Add command palette entries for viewing extension and language server logs (`Ruby: Show Output Channel` and `Ruby: Show Language Server Output Channel`)
8080
- Support multiline and keyword option YARD comments [#371](https://github.com/rubyide/vscode-ruby/pull/371)
8181
- Improve/Fix Block Parameter Highlighting [#514](https://github.com/rubyide/vscode-ruby/pull/514)

docs/formatting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The language server currently supports formatting via the following formatters:
55
- [RuboCop](https://github.com/rubocop-hq/rubocop)
66
- [Standard](https://github.com/testdouble/standard)
77
- [Rufo](https://github.com/ruby-formatter/rufo)
8-
- [RubyFMT](https://github.com/samphippen/rubyfmt)
8+
- [RubyFMT](https://github.com/penelopezone/rubyfmt)
99

1010
## Configuration
1111

docs/language-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The server is built to be extensible, accurate, and performant with such feature
77
- Automatic Ruby environment detection with support for rvm, rbenv, chruby, and asdf
88
- Robust language feature extraction powered by the [tree-sitter](https://tree-sitter.github.io/tree-sitter/) project
99
- Lint support via RuboCop, Reek, and Standard
10-
- Format support via RuboCop, Standard, and Rufo
10+
- Format support via RuboCop, Standard, Rubyfmt, and Rufo
1111
- Semantic code folding support
1212
- Semantic highlighting support
1313
- Intellisense support

packages/language-server-ruby/src/formatters/RubyFMT.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import path from 'path';
1+
import { URI } from 'vscode-uri'
22
import BaseFormatter from './BaseFormatter';
33

4-
const RUBYFMT_PATH = path.resolve(__dirname, 'rubyfmt.rb');
5-
64
export default class RubyFMT extends BaseFormatter {
75
get cmd(): string {
8-
return 'ruby';
6+
return 'rubyfmt';
97
}
108

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

1514
get useBundler(): boolean {

0 commit comments

Comments
 (0)