Skip to content
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

Reload the runner if structure.sql changes #341

Merged
merged 4 commits into from
May 2, 2024
Merged
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
27 changes: 27 additions & 0 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def activate(global_state, message_queue)
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}")
# Start booting the real client in a background thread. Until this completes, the client will be a NullClient
Thread.new { @client = RunnerClient.create_client }
register_additional_file_watchers(global_state: global_state, message_queue: message_queue)
end

sig { override.void }
Expand Down Expand Up @@ -96,6 +97,32 @@ def workspace_did_change_watched_files(changes)
end
end

sig { params(global_state: GlobalState, message_queue: Thread::Queue).void }
def register_additional_file_watchers(global_state:, message_queue:)
Earlopain marked this conversation as resolved.
Show resolved Hide resolved
return unless global_state.supports_watching_files

message_queue << Request.new(
id: "ruby-lsp-rails-file-watcher",
method: "client/registerCapability",
params: Interface::RegistrationParams.new(
registrations: [
Interface::Registration.new(
id: "workspace/didChangeWatchedFilesRails",
method: "workspace/didChangeWatchedFiles",
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
watchers: [
Interface::FileSystemWatcher.new(
glob_pattern: "**/*structure.sql",
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
),
],
),
),
],
),
)
end

sig { override.returns(String) }
def name
"Ruby LSP Rails"
Expand Down
Loading