Class: RubyLsp::Ree::Addon
- Inherits:
-
Addon
- Object
- Addon
- RubyLsp::Ree::Addon
- Defined in:
- lib/ruby_lsp/ruby_lsp_ree/addon.rb
Instance Method Summary collapse
- #activate(global_state, message_queue) ⇒ Object
- #create_completion_listener(response_builder, node_context, dispatcher, uri) ⇒ Object
- #create_definition_listener(response_builder, uri, node_context, dispatcher) ⇒ Object
- #create_hover_listener(response_builder, node_context, dispatcher) ⇒ Object
- #deactivate ⇒ Object
- #name ⇒ Object
- #register_additional_file_watchers(global_state, message_queue) ⇒ Object
- #workspace_did_change_watched_files(changes) ⇒ Object
Instance Method Details
#activate(global_state, message_queue) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 16 def activate(global_state, ) @global_state = global_state @settings = global_state.settings_for_addon(name) || {} = @template_applicator = RubyLsp::Ree::ReeTemplateApplicator.new global_state.register_formatter("ree_formatter", RubyLsp::Ree::ReeFormatter.new( , @settings[:formatter], @global_state.index )) register_additional_file_watchers(global_state, ) end |
#create_completion_listener(response_builder, node_context, dispatcher, uri) ⇒ Object
44 45 46 47 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 44 def create_completion_listener(response_builder, node_context, dispatcher, uri) index = @global_state.index RubyLsp::Ree::CompletionListener.new(response_builder, node_context, index, dispatcher, uri) end |
#create_definition_listener(response_builder, uri, node_context, dispatcher) ⇒ Object
39 40 41 42 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 39 def create_definition_listener(response_builder, uri, node_context, dispatcher) index = @global_state.index RubyLsp::Ree::DefinitionListener.new(response_builder, node_context, index, dispatcher, uri) end |
#create_hover_listener(response_builder, node_context, dispatcher) ⇒ Object
49 50 51 52 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 49 def create_hover_listener(response_builder, node_context, dispatcher) index = @global_state.index RubyLsp::Ree::HoverListener.new(response_builder, node_context, index, dispatcher) end |
#deactivate ⇒ Object
32 33 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 32 def deactivate end |
#name ⇒ Object
35 36 37 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 35 def name "Ree Addon" end |
#register_additional_file_watchers(global_state, message_queue) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 54 def register_additional_file_watchers(global_state, ) # Clients are not required to implement this capability return unless global_state.supports_watching_files << Request.new( id: "ruby-lsp-ree-file-create-watcher", method: "client/registerCapability", params: Interface::RegistrationParams.new( registrations: [ Interface::Registration.new( id: "workspace/didCreateWatchedFilesRee", method: "workspace/didChangeWatchedFiles", register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( watchers: [ Interface::FileSystemWatcher.new( glob_pattern: "**/*.rb", kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE, ), ], ), ), ], ), ) end |
#workspace_did_change_watched_files(changes) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ruby_lsp/ruby_lsp_ree/addon.rb', line 80 def workspace_did_change_watched_files(changes) if changes.size == 1 && changes[0][:type] == Constant::FileChangeType::CREATED $stderr.puts("file created #{changes[0][:uri]}") return unless @template_applicator.template_dir_exists? @template_applicator.apply(changes[0]) elsif changes.size == 2 && changes.any?{ _1[:type] == Constant::FileChangeType::CREATED } && changes.any?{ _1[:type] == Constant::FileChangeType::DELETED } $stderr.puts("file renamed #{changes[0][:uri]} #{changes[1][:uri]}") RubyLsp::Ree::ReeRenameHandler.call(changes) end end |