Class: RubyLsp::Standard::Addon
- Inherits:
-
Addon
- Object
- Addon
- RubyLsp::Standard::Addon
- Defined in:
- lib/ruby_lsp/standard/addon.rb
Instance Method Summary collapse
- #activate(global_state, message_queue) ⇒ 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
11 12 13 14 15 16 17 18 19 |
# File 'lib/ruby_lsp/standard/addon.rb', line 11 def activate(global_state, ) @logger = ::Standard::Lsp::Logger.new(prefix: "[Standard Ruby]") @logger.puts "Activating Standard Ruby LSP addon v#{::Standard::VERSION}" RuboCop::LSP.enable @wraps_built_in_lsp_standardizer = WrapsBuiltinLspStandardizer.new global_state.register_formatter("standard", @wraps_built_in_lsp_standardizer) register_additional_file_watchers(global_state, ) @logger.puts "Initialized Standard Ruby LSP addon #{::Standard::VERSION}" end |
#deactivate ⇒ Object
21 22 23 |
# File 'lib/ruby_lsp/standard/addon.rb', line 21 def deactivate @wraps_built_in_lsp_standardizer = nil end |
#name ⇒ Object
7 8 9 |
# File 'lib/ruby_lsp/standard/addon.rb', line 7 def name "Standard Ruby" end |
#register_additional_file_watchers(global_state, message_queue) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby_lsp/standard/addon.rb', line 25 def register_additional_file_watchers(global_state, ) return unless global_state.supports_watching_files << Request.new( id: "standard-file-watcher", method: "client/registerCapability", params: Interface::RegistrationParams.new( registrations: [ Interface::Registration.new( id: "workspace/didChangeWatchedFilesStandard", method: "workspace/didChangeWatchedFiles", register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( watchers: [ Interface::FileSystemWatcher.new( glob_pattern: "**/.standard{,_todo}.yml", kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE ) ] ) ) ] ) ) end |
#workspace_did_change_watched_files(changes) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/ruby_lsp/standard/addon.rb', line 50 def workspace_did_change_watched_files(changes) if changes.any? { |change| change[:uri].end_with?(".standard.yml") } @wraps_built_in_lsp_standardizer.init! @logger.puts "Re-initialized Standard Ruby LSP addon #{::Standard::VERSION} due to .standard.yml file change" end end |