Skip to content

Commit a49b02e

Browse files
authored
Reload the runner if structure.sql changes (#341)
Closes #326
1 parent 2a30aca commit a49b02e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lib/ruby_lsp/ruby_lsp_rails/addon.rb

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

3738
sig { override.void }
@@ -96,6 +97,32 @@ def workspace_did_change_watched_files(changes)
9697
end
9798
end
9899

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

0 commit comments

Comments
 (0)