Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 140c392

Browse files
committed
Add 120 line width plugin
1 parent b5024c3 commit 140c392

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/syntax_tree/formatter.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Formatter < PrettierPrint
1414
# Note that we're keeping this in a global-ish hash instead of just
1515
# overriding methods on classes so that other plugins can reference this if
1616
# necessary. For example, the RBS plugin references the quote style.
17-
OPTIONS = { quote: "\"", trailing_comma: false }
17+
OPTIONS = { quote: "\"", trailing_comma: false, line_width: 80 }
1818

1919
COMMENT_PRIORITY = 1
2020
HEREDOC_PRIORITY = 2
@@ -23,15 +23,18 @@ class Formatter < PrettierPrint
2323

2424
# These options are overridden in plugins to we need to make sure they are
2525
# available here.
26-
attr_reader :quote, :trailing_comma
26+
attr_reader :quote, :trailing_comma, :line_width
2727
alias trailing_comma? trailing_comma
2828

2929
def initialize(
3030
source,
3131
*args,
3232
quote: OPTIONS[:quote],
33-
trailing_comma: OPTIONS[:trailing_comma]
33+
trailing_comma: OPTIONS[:trailing_comma],
34+
line_width: OPTIONS[:line_width]
3435
)
36+
# Loads custom line_width plugin
37+
args[1] = line_width
3538
super(*args)
3639

3740
@source = source
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# frozen_string_literal: true
2+
3+
SyntaxTree::Formatter::OPTIONS[:line_width] = 120

0 commit comments

Comments
 (0)