Class: RubyLsp::RubyLspRubyfmt::RubyFmtFormatterRunner
- Inherits:
-
Object
- Object
- RubyLsp::RubyLspRubyfmt::RubyFmtFormatterRunner
- Includes:
- RubyLsp::Requests::Support::FormatterRunner, Singleton
- Defined in:
- lib/ruby_lsp/ruby-lsp-rubyfmt/addon.rb
Overview
Custom formatting runner
Instance Method Summary collapse
-
#initialize ⇒ RubyFmtFormatterRunner
constructor
Use the initialize method to perform any sort of ahead of time work.
-
#run(uri, document) ⇒ Object
The main part of the interface is implementing the run method.
Constructor Details
#initialize ⇒ RubyFmtFormatterRunner
Use the initialize method to perform any sort of ahead of time work. For example, reading configurations for yourformatter since they are unlikely to change between requests
33 34 |
# File 'lib/ruby_lsp/ruby-lsp-rubyfmt/addon.rb', line 33 def initialize end |
Instance Method Details
#run(uri, document) ⇒ Object
The main part of the interface is implementing the run method. It receives the URI and the document being formatted. IMPORTANT: This method must return the formatted document source without mutating the original one in document
39 40 41 42 |
# File 'lib/ruby_lsp/ruby-lsp-rubyfmt/addon.rb', line 39 def run(uri, document) output, _status = Open3.capture2("rubyfmt", stdin_data: document.source) output end |