Skip to content

Extract base client and server class to ruby-lsp #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -25,3 +25,5 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo"
gem "tzinfo-data"
end

gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "add-on-client-server-framework"
37 changes: 19 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -6,6 +6,17 @@ GIT
rdoc (6.6.3.1)
psych (>= 4.0.0)

GIT
remote: https://github.com/Shopify/ruby-lsp.git
revision: dcb22575770cb200e812bdc0355805a6078d4069
branch: add-on-client-server-framework
specs:
ruby-lsp (0.17.18)
language_server-protocol (~> 3.17.0)
prism (~> 1.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)

PATH
remote: .
specs:
@@ -118,7 +129,7 @@ GEM
reline (>= 0.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.0)
logger (1.6.1)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
@@ -146,8 +157,6 @@ GEM
nio4r (2.7.3)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
@@ -156,7 +165,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
prism (0.30.0)
prism (1.0.0)
psych (5.1.2)
stringio
public_suffix (5.0.5)
@@ -202,10 +211,10 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rbi (0.1.13)
prism (>= 0.18.0, < 1.0.0)
rbi (0.2.0)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)
rbs (3.5.2)
rbs (3.5.3)
logger
regexp_parser (2.9.0)
reline (0.5.7)
@@ -234,11 +243,6 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.3)
rubocop (>= 0.90.0)
ruby-lsp (0.17.12)
language_server-protocol (~> 3.17.0)
prism (>= 0.29.0, < 0.31)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sorbet (0.5.11406)
@@ -255,16 +259,15 @@ GEM
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x64-mingw-ucrt)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
stringio (3.1.0)
strscan (3.1.0)
tapioca (0.13.3)
tapioca (0.16.2)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (>= 0.1.4, < 0.2)
rbi (~> 0.2)
sorbet-static-and-runtime (>= 0.5.11087)
spoom (>= 1.2.0)
thor (>= 1.2.0)
@@ -273,8 +276,6 @@ GEM
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2024.1)
tzinfo (>= 1.0.0)
unicode-display_width (2.5.0)
webmock (3.23.1)
addressable (>= 2.8.0)
@@ -292,7 +293,6 @@ GEM

PLATFORMS
arm64-darwin
x64-mingw-ucrt
x86_64-darwin
x86_64-linux

@@ -307,6 +307,7 @@ DEPENDENCIES
rubocop-rake (~> 0.6.0)
rubocop-shopify (~> 2.15)
rubocop-sorbet (~> 0.8)
ruby-lsp!
ruby-lsp-rails!
sorbet-static-and-runtime
sqlite3 (< 2)
6 changes: 3 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def initialize

# We first initialize the client as a NullClient, so that we can start the server in a background thread. Until
# the real client is initialized, features that depend on it will not be blocked by using the NullClient
@rails_runner_client = T.let(NullClient.new, RunnerClient)
@rails_runner_client = T.let(NullClient.new(self), RunnerClient)
@global_state = T.let(nil, T.nilable(GlobalState))
end

@@ -36,9 +36,9 @@ def initialize
sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
def activate(global_state, message_queue)
@global_state = global_state
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}")
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}") unless ENV["RAILS_ENV"] == "test"
# Start booting the real client in a background thread. Until this completes, the client will be a NullClient
Thread.new { @rails_runner_client = RunnerClient.create_client }
Thread.new { @rails_runner_client = RunnerClient.create_client(self) }
register_additional_file_watchers(global_state: global_state, message_queue: message_queue)

@global_state.index.register_enhancement(IndexingEnhancement.new)
Loading