Sha256: 612a8fb6f6fed0ea46842075b439299cc8719c5c758b4220a2541fc4276a51f9
Contents?: true
Size: 1.11 KB
Versions: 10
Compression:
Stored size: 1.11 KB
Contents
# typed: strict # frozen_string_literal: true require "syntax_tree/cli" require "singleton" module RubyLsp module Requests module Support # :nodoc: class SyntaxTreeFormattingRunner extend T::Sig include Singleton include Support::FormatterRunner sig { void } def initialize @options = T.let( begin opts = SyntaxTree::CLI::Options.new opts.parse(SyntaxTree::CLI::ConfigFile.new.arguments) opts end, SyntaxTree::CLI::Options, ) end sig { override.params(uri: String, document: Document).returns(T.nilable(String)) } def run(uri, document) relative_path = Pathname.new(URI(uri).path).relative_path_from(T.must(WORKSPACE_URI.path)) return if @options.ignore_files.any? { |pattern| File.fnmatch(pattern, relative_path) } SyntaxTree.format( document.source, @options.print_width, options: @options.formatter_options, ) end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems