Class: RubyLsp::ClientCapabilities
- Inherits:
-
Object
- Object
- RubyLsp::ClientCapabilities
- Defined in:
- lib/ruby_lsp/client_capabilities.rb
Overview
This class stores all client capabilities that the Ruby LSP and its add-ons depend on to ensure that we’re not enabling functionality unsupported by the editor connecting to the server
Instance Attribute Summary collapse
-
#supports_code_lens_refresh ⇒ Object
readonly
: bool.
-
#supports_diagnostic_refresh ⇒ Object
readonly
: bool.
-
#supports_progress ⇒ Object
readonly
: bool.
-
#supports_request_delegation ⇒ Object
readonly
: bool.
-
#supports_watching_files ⇒ Object
readonly
: bool.
-
#window_show_message_supports_extra_properties ⇒ Object
readonly
: bool.
Instance Method Summary collapse
-
#apply_client_capabilities(capabilities) ⇒ Object
: (Hash[Symbol, untyped] capabilities) -> void.
-
#initialize ⇒ ClientCapabilities
constructor
: -> void.
-
#supports_rename? ⇒ Boolean
: -> bool.
Constructor Details
#initialize ⇒ ClientCapabilities
: -> void
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 17 def initialize # The editor supports watching files. This requires two capabilities: dynamic registration and relative pattern # support @supports_watching_files = false #: bool # The editor supports request delegation. This is an experimental capability since request delegation has not been # standardized into the LSP spec yet @supports_request_delegation = false #: bool # The editor supports extra arbitrary properties for `window/showMessageRequest`. Necessary for add-ons to show # dialogs with user interactions = false #: bool # Which resource operations the editor supports, like renaming files @supported_resource_operations = [] #: Array[String] # The editor supports displaying progress requests @supports_progress = false #: bool # The editor supports server initiated refresh for diagnostics @supports_diagnostic_refresh = false #: bool # The editor supports server initiated refresh for code lenses @supports_code_lens_refresh = false #: bool end |
Instance Attribute Details
#supports_code_lens_refresh ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def supports_code_lens_refresh @supports_code_lens_refresh end |
#supports_diagnostic_refresh ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def supports_diagnostic_refresh @supports_diagnostic_refresh end |
#supports_progress ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def supports_progress @supports_progress end |
#supports_request_delegation ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def supports_request_delegation @supports_request_delegation end |
#supports_watching_files ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def supports_watching_files @supports_watching_files end |
#window_show_message_supports_extra_properties ⇒ Object (readonly)
: bool
9 10 11 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 9 def end |
Instance Method Details
#apply_client_capabilities(capabilities) ⇒ Object
: (Hash[Symbol, untyped] capabilities) -> void
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 44 def apply_client_capabilities(capabilities) workspace_capabilities = capabilities[:workspace] || {} file_watching_caps = workspace_capabilities[:didChangeWatchedFiles] if file_watching_caps&.dig(:dynamicRegistration) && file_watching_caps&.dig(:relativePatternSupport) @supports_watching_files = true end @supports_request_delegation = capabilities.dig(:experimental, :requestDelegation) || false supported_resource_operations = workspace_capabilities.dig(:workspaceEdit, :resourceOperations) @supported_resource_operations = supported_resource_operations if supported_resource_operations supports_additional_properties = capabilities.dig( :window, :showMessage, :messageActionItem, :additionalPropertiesSupport, ) = supports_additional_properties || false progress = capabilities.dig(:window, :workDoneProgress) @supports_progress = progress if progress @supports_diagnostic_refresh = workspace_capabilities.dig(:diagnostics, :refreshSupport) || false @supports_code_lens_refresh = workspace_capabilities.dig(:codeLens, :refreshSupport) || false end |
#supports_rename? ⇒ Boolean
: -> bool
72 73 74 |
# File 'lib/ruby_lsp/client_capabilities.rb', line 72 def supports_rename? @supported_resource_operations.include?("rename") end |