Skip to content

Commit

Permalink
Remove dependency on syntax_tree (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Sep 25, 2023
1 parent ad3c909 commit 9facb66
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ group :development do
gem "tapioca", "~> 0.11", require: false, platforms: NON_WINDOWS_PLATFORMS
gem "rdoc", require: false
gem "psych", "~> 5.1", require: false

gem "syntax_tree", ">= 6.1.1", "< 7"
end
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ PATH
ruby-lsp (0.11.0)
language_server-protocol (~> 3.17.0)
sorbet-runtime (>= 0.5.5685)
syntax_tree (>= 6.1.1, < 7)
yarp (>= 0.12, < 0.13)

GEM
Expand Down Expand Up @@ -132,6 +131,7 @@ DEPENDENCIES
rubocop-sorbet (~> 0.7)
ruby-lsp!
sorbet-static-and-runtime
syntax_tree (>= 6.1.1, < 7)
tapioca (~> 0.11)

BUNDLED WITH
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/internal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# frozen_string_literal: true

require "sorbet-runtime"
require "syntax_tree"
require "yarp"
require "language_server-protocol"
require "bundler"
Expand Down
11 changes: 5 additions & 6 deletions lib/ruby_lsp/requests/formatting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ class Formatting < BaseRequest
class Error < StandardError; end
class InvalidFormatter < StandardError; end

@formatters = T.let(
{
"syntax_tree" => Support::SyntaxTreeFormattingRunner.instance,
},
T::Hash[String, Support::FormatterRunner],
)
@formatters = T.let({}, T::Hash[String, Support::FormatterRunner])

class << self
extend T::Sig
Expand All @@ -52,6 +47,10 @@ def register_formatter(identifier, instance)
register_formatter("rubocop", Support::RuboCopFormattingRunner.instance)
end

if defined?(Support::SyntaxTreeFormattingRunner)
register_formatter("syntax_tree", Support::SyntaxTreeFormattingRunner.instance)
end

extend T::Sig

sig { params(document: Document, formatter: String).void }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# typed: strict
# frozen_string_literal: true

require "syntax_tree/cli"
begin
require "syntax_tree"
require "syntax_tree/cli"
rescue LoadError
return
end

require "singleton"

module RubyLsp
Expand Down
1 change: 0 additions & 1 deletion ruby-lsp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Gem::Specification.new do |s|

s.add_dependency("language_server-protocol", "~> 3.17.0")
s.add_dependency("sorbet-runtime", ">= 0.5.5685")
s.add_dependency("syntax_tree", ">= 6.1.1", "< 7")
s.add_dependency("yarp", ">= 0.12", "< 0.13")

s.required_ruby_version = ">= 3.0"
Expand Down

0 comments on commit 9facb66

Please sign in to comment.