Skip to content

Commit fedcb03

Browse files
committed
Reload the runner if structure.sql changes
Closes #326
1 parent f768913 commit fedcb03

File tree

4 files changed

+221
-122
lines changed

4 files changed

+221
-122
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PATH
1010
remote: .
1111
specs:
1212
ruby-lsp-rails (0.3.5)
13-
ruby-lsp (>= 0.16.0, < 0.17.0)
13+
ruby-lsp (>= 0.16.5, < 0.17.0)
1414
sorbet-runtime (>= 0.5.9897)
1515

1616
GEM
@@ -223,9 +223,9 @@ GEM
223223
rubocop (~> 1.51)
224224
rubocop-sorbet (0.8.1)
225225
rubocop (>= 0.90.0)
226-
ruby-lsp (0.16.4)
226+
ruby-lsp (0.16.5)
227227
language_server-protocol (~> 3.17.0)
228-
prism (>= 0.22.0, < 0.25)
228+
prism (>= 0.23.0, < 0.28)
229229
sorbet-runtime (>= 0.5.10782)
230230
ruby-progressbar (1.13.0)
231231
ruby2_keywords (0.0.5)

lib/ruby_lsp/ruby_lsp_rails/addon.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def activate(global_state, message_queue)
3131
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}")
3232
# Start booting the real client in a background thread. Until this completes, the client will be a NullClient
3333
Thread.new { @client = RunnerClient.create_client }
34+
register_additional_file_watchers(global_state: global_state, message_queue: message_queue)
3435
end
3536

3637
sig { override.void }
@@ -95,6 +96,32 @@ def workspace_did_change_watched_files(changes)
9596
end
9697
end
9798

99+
sig { params(global_state: GlobalState, message_queue: Thread::Queue).void }
100+
def register_additional_file_watchers(global_state:, message_queue:)
101+
return unless global_state.supports_watching_files
102+
103+
message_queue << Request.new(
104+
id: "ruby-lsp-rails-file-watcher",
105+
method: "client/registerCapability",
106+
params: Interface::RegistrationParams.new(
107+
registrations: [
108+
Interface::Registration.new(
109+
id: "workspace/didChangeWatchedFilesRails",
110+
method: "workspace/didChangeWatchedFiles",
111+
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
112+
watchers: [
113+
Interface::FileSystemWatcher.new(
114+
glob_pattern: "**/*structure.sql",
115+
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
116+
),
117+
],
118+
),
119+
),
120+
],
121+
),
122+
)
123+
end
124+
98125
sig { override.returns(String) }
99126
def name
100127
"Ruby LSP Rails"

ruby-lsp-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
2323
Dir["lib/**/*", "LICENSE.txt", "Rakefile", "README.md"]
2424
end
2525

26-
spec.add_dependency("ruby-lsp", ">= 0.16.0", "< 0.17.0")
26+
spec.add_dependency("ruby-lsp", ">= 0.16.5", "< 0.17.0")
2727
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
2828
end

0 commit comments

Comments
 (0)