Class: Browsable::LSP::Handlers::Initialize

Inherits:
Object
  • Object
show all
Defined in:
lib/browsable/lsp/handlers/initialize.rb

Overview

Handles the ‘initialize` request: advertises the server’s capabilities.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.workspace_root(params) ⇒ Object

Best-effort extraction of the workspace root from initialize params. browsable’s Config is then loaded relative to it.



21
22
23
24
25
26
# File 'lib/browsable/lsp/handlers/initialize.rb', line 21

def self.workspace_root(params)
  uri = params["rootUri"] || params.dig("workspaceFolders", 0, "uri")
  return params["rootPath"] if uri.nil?

  uri.to_s.sub(%r{\Afile://}, "")
end

Instance Method Details

#call(_params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/browsable/lsp/handlers/initialize.rb', line 8

def call(_params)
  {
    capabilities: {
      # 1 = Full document sync — the client resends the whole buffer on
      # every change. Simple and fine for the file sizes browsable sees.
      textDocumentSync: { openClose: true, change: 1 }
    },
    serverInfo: { name: "browsable-lsp", version: Browsable::LSP::VERSION }
  }
end