Skip to content

Commit

Permalink
Watch for YAML file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jan 17, 2025
1 parent 27a3728 commit 17812c5
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def workspace_did_change_watched_files(changes)

offer_to_run_pending_migrations
end

if changes.any? { |c| c[:uri].end_with?(".yml") || c[:uri].end_with?(".yaml") }
# TODO
end
end

sig { override.returns(String) }
Expand Down Expand Up @@ -223,19 +227,30 @@ def register_additional_file_watchers(global_state:, outgoing_queue:)
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,
),
],
watchers: [structure_sql_file_watcher, yaml_file_watcher],
),
),
],
),
)
end

sig { returns(Interface::FileSystemWatcher) }
def structure_sql_file_watcher
Interface::FileSystemWatcher.new(
glob_pattern: "**/*structure.sql",
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
)
end

sig { returns(Interface::FileSystemWatcher) }
def yaml_file_watcher
Interface::FileSystemWatcher.new(
glob_pattern: "**/*.yml", # TODO: also YAML
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
)
end

sig { void }
def offer_to_run_pending_migrations
return unless @outgoing_queue
Expand Down

0 comments on commit 17812c5

Please sign in to comment.