Class: Daytona::LspServer
- Inherits:
-
Object
- Object
- Daytona::LspServer
- Defined in:
- lib/daytona/lsp_server.rb
Defined Under Namespace
Modules: Language Classes: Position
Instance Attribute Summary collapse
- #language_id ⇒ Symbol readonly
- #path_to_project ⇒ String readonly
- #sandbox_id ⇒ String readonly
- #toolbox_api ⇒ DaytonaToolboxApiClient::LspApi readonly
Instance Method Summary collapse
-
#completions(path:, position:) ⇒ DaytonaApiClient::CompletionList
Gets completion suggestions at a position in a file.
-
#did_close(path) ⇒ void
Notify the language server that a file has been closed.
-
#did_open(path) ⇒ void
Notifies the language server that a file has been opened.
-
#document_symbols(path) ⇒ Array<DaytonaToolboxApiClient::LspSymbol]
Gets symbol information (functions, classes, variables, etc.) from a document.
-
#initialize(language_id:, path_to_project:, toolbox_api:, sandbox_id:) ⇒ LspServer
constructor
A new instance of LspServer.
-
#sandbox_symbols(query) ⇒ Array<DaytonaToolboxApiClient::LspSymbol]
Searches for symbols matching the query string across all files in the Sandbox.
-
#start ⇒ void
Starts the language server.
-
#stop ⇒ void
Stops the language server.
Constructor Details
#initialize(language_id:, path_to_project:, toolbox_api:, sandbox_id:) ⇒ LspServer
Returns a new instance of LspServer.
34 35 36 37 38 39 |
# File 'lib/daytona/lsp_server.rb', line 34 def initialize(language_id:, path_to_project:, toolbox_api:, sandbox_id:) @language_id = language_id @path_to_project = path_to_project @toolbox_api = toolbox_api @sandbox_id = sandbox_id end |
Instance Attribute Details
#language_id ⇒ Symbol (readonly)
19 20 21 |
# File 'lib/daytona/lsp_server.rb', line 19 def language_id @language_id end |
#path_to_project ⇒ String (readonly)
22 23 24 |
# File 'lib/daytona/lsp_server.rb', line 22 def path_to_project @path_to_project end |
#sandbox_id ⇒ String (readonly)
28 29 30 |
# File 'lib/daytona/lsp_server.rb', line 28 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::LspApi (readonly)
25 26 27 |
# File 'lib/daytona/lsp_server.rb', line 25 def toolbox_api @toolbox_api end |
Instance Method Details
#completions(path:, position:) ⇒ DaytonaApiClient::CompletionList
Gets completion suggestions at a position in a file
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/daytona/lsp_server.rb', line 46 def completions(path:, position:) toolbox_api.completions( DaytonaToolboxApiClient::LspCompletionParams.new( language_id:, path_to_project:, uri: uri(path), position: DaytonaApiClient::Position.new(line: position.line, character: position.character) ) ) end |
#did_close(path) ⇒ void
This method returns an undefined value.
Notify the language server that a file has been closed. This method should be called when a file is closed in the editor to allow the language server to clean up any resources associated with that file.
63 64 65 66 67 |
# File 'lib/daytona/lsp_server.rb', line 63 def did_close(path) toolbox_api.did_close( DaytonaToolboxApiClient::LspDocumentRequest.new(language_id:, path_to_project:, uri: uri(path)) ) end |
#did_open(path) ⇒ void
This method returns an undefined value.
Notifies the language server that a file has been opened. This method should be called when a file is opened in the editor to enable language features like diagnostics and completions for that file. The server will begin tracking the file’s contents and providing language features.
76 77 78 79 80 |
# File 'lib/daytona/lsp_server.rb', line 76 def did_open(path) toolbox_api.did_open( DaytonaToolboxApiClient::LspDocumentRequest.new(language_id:, path_to_project:, uri: uri(path)) ) end |
#document_symbols(path) ⇒ Array<DaytonaToolboxApiClient::LspSymbol]
Gets symbol information (functions, classes, variables, etc.) from a document.
86 |
# File 'lib/daytona/lsp_server.rb', line 86 def document_symbols(path) = toolbox_api.document_symbols(language_id, path_to_project, uri(path)) |
#sandbox_symbols(query) ⇒ Array<DaytonaToolboxApiClient::LspSymbol]
Searches for symbols matching the query string across all files in the Sandbox.
93 |
# File 'lib/daytona/lsp_server.rb', line 93 def sandbox_symbols(query) = toolbox_api.workspace_symbols(query, language_id, path_to_project) |
#start ⇒ void
This method returns an undefined value.
Starts the language server. This method must be called before using any other LSP functionality. It initializes the language server for the specified language and project.
100 101 102 103 104 |
# File 'lib/daytona/lsp_server.rb', line 100 def start toolbox_api.start( DaytonaToolboxApiClient::LspServerRequest.new(language_id:, path_to_project:) ) end |
#stop ⇒ void
This method returns an undefined value.
Stops the language server. This method should be called when the LSP server is no longer needed to free up system resources.
111 112 113 114 115 |
# File 'lib/daytona/lsp_server.rb', line 111 def stop toolbox_api.stop( DaytonaToolboxApiClient::LspServerRequest.new(language_id:, path_to_project:) ) end |