[][src]Trait tower_lsp::LanguageServer

pub trait LanguageServer: Send + Sync + 'static {
    type ShutdownFuture: Future<Item = (), Error = Error> + Send;
    type SymbolFuture: Future<Item = Option<Vec<SymbolInformation>>, Error = Error> + Send;
    type ExecuteFuture: Future<Item = Option<Value>, Error = Error> + Send;
    type CompletionFuture: Future<Item = Option<CompletionResponse>, Error = Error> + Send;
    type HoverFuture: Future<Item = Option<Hover>, Error = Error> + Send;
    type HighlightFuture: Future<Item = Option<Vec<DocumentHighlight>>, Error = Error> + Send;
    fn initialize(
        &self,
        printer: &Printer,
        params: InitializeParams
    ) -> Result<InitializeResult>;
fn shutdown(&self) -> Self::ShutdownFuture;
fn symbol(&self, params: WorkspaceSymbolParams) -> Self::SymbolFuture;
fn execute_command(
        &self,
        p: &Printer,
        params: ExecuteCommandParams
    ) -> Self::ExecuteFuture;
fn completion(&self, params: CompletionParams) -> Self::CompletionFuture;
fn hover(&self, params: TextDocumentPositionParams) -> Self::HoverFuture;
fn document_highlight(
        &self,
        params: TextDocumentPositionParams
    ) -> Self::HighlightFuture; fn initialized(&self, printer: &Printer, params: InitializedParams) { ... }
fn did_change_workspace_folders(
        &self,
        p: &Printer,
        params: DidChangeWorkspaceFoldersParams
    ) { ... }
fn did_change_configuration(
        &self,
        printer: &Printer,
        params: DidChangeConfigurationParams
    ) { ... }
fn did_change_watched_files(
        &self,
        printer: &Printer,
        params: DidChangeWatchedFilesParams
    ) { ... }
fn did_open(&self, printer: &Printer, params: DidOpenTextDocumentParams) { ... }
fn did_change(&self, printer: &Printer, params: DidChangeTextDocumentParams) { ... }
fn did_save(&self, printer: &Printer, params: DidSaveTextDocumentParams) { ... }
fn did_close(&self, printer: &Printer, params: DidCloseTextDocumentParams) { ... } }

Trait implemented by language server backends.

This interface allows servers adhering to the Language Server Protocol to be implemented in a safe and easily testable way without exposing the low-level implementation details.

Associated Types

type ShutdownFuture: Future<Item = (), Error = Error> + Send

Response returned when a server shutdown is requested.

type SymbolFuture: Future<Item = Option<Vec<SymbolInformation>>, Error = Error> + Send

Response returned when a workspace symbol action is requested.

type ExecuteFuture: Future<Item = Option<Value>, Error = Error> + Send

Response returned when an execute command action is requested.

type CompletionFuture: Future<Item = Option<CompletionResponse>, Error = Error> + Send

Response returned when a completion action is requested.

type HoverFuture: Future<Item = Option<Hover>, Error = Error> + Send

Response returned when a hover action is requested.

type HighlightFuture: Future<Item = Option<Vec<DocumentHighlight>>, Error = Error> + Send

Response returned when a document highlight action is requested.

Loading content...

Required methods

fn initialize(
    &self,
    printer: &Printer,
    params: InitializeParams
) -> Result<InitializeResult>

The initialize request is the first request sent from the client to the server.

fn shutdown(&self) -> Self::ShutdownFuture

The shutdown request asks the server to gracefully shut down, but to not exit.

This request is often later followed by an exit notification, which will cause the server to exit immediately.

fn symbol(&self, params: WorkspaceSymbolParams) -> Self::SymbolFuture

The workspace/symbol request is sent from the client to the server to list project-wide symbols matching the given query string.

fn execute_command(
    &self,
    p: &Printer,
    params: ExecuteCommandParams
) -> Self::ExecuteFuture

The workspace/executeCommand request is sent from the client to the server to trigger command execution on the server.

In most cases, the server creates a WorkspaceEdit structure and applies the changes to the workspace using Printer::apply_edit() before returning from this function.

fn completion(&self, params: CompletionParams) -> Self::CompletionFuture

The textDocument/completion request is sent from the client to the server to compute completion items at a given cursor position.

If computing full completion items is expensive, servers can additionally provide a handler for the completion item resolve request (completionItem/resolve). This request is sent when a completion item is selected in the user interface.

fn hover(&self, params: TextDocumentPositionParams) -> Self::HoverFuture

The textDocument/hover request asks the server for hover information at a given text document position.

Such hover information typically includes type signature information and inline documentation for the symbol at the given text document position.

fn document_highlight(
    &self,
    params: TextDocumentPositionParams
) -> Self::HighlightFuture

The textDocument/documentHighlight request is sent from the client to the server to resolve appropriate highlights for a given text document position.

For programming languages, this usually highlights all textual references to the symbol scoped to this file.

This request differs slightly from textDocument/references in that this one is allowed to be more fuzzy.

Loading content...

Provided methods

fn initialized(&self, printer: &Printer, params: InitializedParams)

The initialized notification is sent from the client to the server after the client received the result of the initialize request but before the client sends anything else.

The server can use the initialized notification for example to dynamically register capabilities with the client.

fn did_change_workspace_folders(
    &self,
    p: &Printer,
    params: DidChangeWorkspaceFoldersParams
)

The workspace/didChangeWorkspaceFolders notification is sent from the client to the server to inform about workspace folder configuration changes.

The notification is sent by default if both of these boolean fields were set to true in the initialize method:

  • InitializeParams::capabilities::workspace::workspace_folders
  • InitializeResult::capabilities::workspace::workspace_folders::supported

This notification is also sent if the server has registered itself to receive this notification.

fn did_change_configuration(
    &self,
    printer: &Printer,
    params: DidChangeConfigurationParams
)

The workspace/didChangeConfiguration notification is sent from the client to the server to signal the change of configuration settings.

fn did_change_watched_files(
    &self,
    printer: &Printer,
    params: DidChangeWatchedFilesParams
)

The workspace/didChangeWatchedFiles notification is sent from the client to the server when the client detects changes to files watched by the language client.

It is recommended that servers register for these file events using the registration mechanism. This can be done here or in the initialized method using Printer::register_capability().

fn did_open(&self, printer: &Printer, params: DidOpenTextDocumentParams)

The textDocument/didOpen notification is sent from the client to the server to signal that a new text document has been opened by the client.

The document's truth is now managed by the client and the server must not try to read the document’s truth using the document's URI. "Open" in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor.

fn did_change(&self, printer: &Printer, params: DidChangeTextDocumentParams)

The textDocument/didChange notification is sent from the client to the server to signal changes to a text document.

This notification will contain a distinct version tag and a list of edits made to the document for the server to interpret.

fn did_save(&self, printer: &Printer, params: DidSaveTextDocumentParams)

The textDocument/didSave notification is sent from the client to the server when the document was saved in the client.

fn did_close(&self, printer: &Printer, params: DidCloseTextDocumentParams)

The textDocument/didClose notification is sent from the client to the server when the document got closed in the client.

The document's truth now exists where the document's URI points to (e.g. if the document's URI is a file URI, the truth now exists on disk).

Loading content...

Implementations on Foreign Types

impl<S: ?Sized + LanguageServer> LanguageServer for Box<S>[src]

type ShutdownFuture = S::ShutdownFuture

type SymbolFuture = S::SymbolFuture

type ExecuteFuture = S::ExecuteFuture

type CompletionFuture = S::CompletionFuture

type HoverFuture = S::HoverFuture

type HighlightFuture = S::HighlightFuture

Loading content...

Implementors

Loading content...